Loss: nan, but accuracy is good?

Hi guys,

I am doing image segmentation, and I applied classic U-Net to the training.

However, the results show that loss: nan, but accuracy could be 0.8-0.9 which sounds pretty good.

I have changed the batch_size and the learning rate many times, but it still not work.

How can I figure out this loss: nan?

Many Thanks

What is your data distribution? Do you have 2 classes where 1 is ~80% of data?
I think this is your situation (exaclly 870k of majority class and 170k of second one). So when you will be predicting just majority class, you will have very nice accuracy.
In Summary, your model doesn’t learn anything useful.

Also, you have in your output much better metrics, like precision,recall, F1 score. Monitor this one, not pure accuracy (or accuracy per class)

Thanks so much for your help.

Maybe my network is not written correctly. I will check my network first.