Wassim Bouatay
Wassim Bouatay

Reputation: 193

Tensorflow Loss & Acc remain constant in CNN model

I have just started to learn CNN on Tensorflow. However, when I train the model the Loss and accuracy don't change.

enter image description here

I am using images of size 128x128x3 and the images are normalized (in [0,1]). And here is the compiler that I am using.

model.compile(optimizer=tf.keras.optimizers.Adam(lr=0.000001), loss='binary_crossentropy', metrics=['accuracy'])

And here is the summary of my model

enter image description here

I tried the following things but I always have the same values:

update

The layers' weights didn't change after fitting the model. I have the same initial weights.

Upvotes: 0

Views: 407

Answers (1)

Anurag Reddy
Anurag Reddy

Reputation: 1215

You could try this,

 model.compile(optimizer='adam',
          loss=tf.keras.losses.BinaryCrossentropy(from_logits=True),
          metrics=['accuracy'])

Also, remove the softmax activation from the last layer, a binary classification problem does not need a softmax. So, what softmax does in this case is clip the value always to 1 since there is only one probability and thus the network doesn't train. This link might help you understand softmax. Additionally, you can try using sigmoid activation at the final node. That clips the output to a value in the range of 0 to 1 and the network weights wont blow up because of a very high loss.

Upvotes: 1

Related Questions