Tell us what’s happening:
While training the model val_accuracy always stays at 0.5 while val_loss, loss and accuracy grow. I searched some possible Solutions but none of them change the problem.
Your code so far
base_model = tf.keras.applications.MobileNetV2(input_shape=(IMG_HEIGHT, IMG_WIDTH, 3), include_top=False, weights="imagenet")
base_model.trainable = False
model = Sequential([
base_model,
tf.keras.layers.GlobalAveragePooling2D(),
Dense(1)
])
model.summary()
model.compile(optimizer = tf.keras.optimizers.RMSprop(learning_rate=0.0001), loss = tf.losses.BinaryCrossentropy(from_logits=True), metrics=['accuracy'])
history = model.fit(train_data_gen, steps_per_epoch=total_train//batch_size, epochs=epochs, validation_data=val_data_gen, validation_steps=total_val//batch_size)
Epoch 1/15
15/15 [==============================] - 17s 1s/step - loss: 0.6744 - accuracy: 0.5887 - val_loss: 0.8840 - val_accuracy: 0.5000
Epoch 2/15
15/15 [==============================] - 16s 1s/step - loss: 0.6594 - accuracy: 0.6100 - val_loss: 0.8880 - val_accuracy: 0.5000
Epoch 3/15
15/15 [==============================] - 16s 1s/step - loss: 0.6456 - accuracy: 0.6218 - val_loss: 0.8851 - val_accuracy: 0.5000
Epoch 4/15
15/15 [==============================] - 16s 1s/step - loss: 0.6349 - accuracy: 0.6213 - val_loss: 0.8839 - val_accuracy: 0.5000
Epoch 5/15
15/15 [==============================] - 16s 1s/step - loss: 0.6273 - accuracy: 0.6298 - val_loss: 0.8965 - val_accuracy: 0.5000
Epoch 6/15
15/15 [==============================] - 16s 1s/step - loss: 0.6125 - accuracy: 0.6469 - val_loss: 0.9007 - val_accuracy: 0.5000
Epoch 7/15
15/15 [==============================] - 16s 1s/step - loss: 0.6037 - accuracy: 0.6287 - val_loss: 0.9031 - val_accuracy: 0.5000
Epoch 8/15
15/15 [==============================] - 16s 1s/step - loss: 0.6046 - accuracy: 0.6453 - val_loss: 0.9073 - val_accuracy: 0.5000
Epoch 9/15
15/15 [==============================] - 16s 1s/step - loss: 0.5900 - accuracy: 0.6592 - val_loss: 0.9126 - val_accuracy: 0.5000
Epoch 10/15
15/15 [==============================] - 16s 1s/step - loss: 0.5577 - accuracy: 0.6790 - val_loss: 0.9146 - val_accuracy: 0.5000
Epoch 11/15
15/15 [==============================] - 16s 1s/step - loss: 0.5597 - accuracy: 0.6843 - val_loss: 0.9205 - val_accuracy: 0.5000
Epoch 12/15
15/15 [==============================] - 16s 1s/step - loss: 0.5453 - accuracy: 0.6790 - val_loss: 0.9286 - val_accuracy: 0.5000
Epoch 13/15
15/15 [==============================] - 16s 1s/step - loss: 0.5401 - accuracy: 0.6886 - val_loss: 0.9292 - val_accuracy: 0.5000
Epoch 14/15
15/15 [==============================] - 16s 1s/step - loss: 0.5431 - accuracy: 0.7041 - val_loss: 0.9327 - val_accuracy: 0.5000
Epoch 15/15
15/15 [==============================] - 16s 1s/step - loss: 0.5400 - accuracy: 0.6923 - val_loss: 0.9406 - val_accuracy: 0.5000
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
.
Challenge: Cat and Dog Image Classifier
Link to the challenge: