I was training a model with images and loss Binary crossentropy.
The loss seems to be genuine in 1st epoch. But in 2nd epoch after some amount of batches only it will raise nan loss but the accuracy increases. also i am using amp.
loss: 6.89388 ; accuracy: 0.72175: 100%|██████████| 3010/3010 [1:19:28<00:00, 1.58s/it]
loss: 0.56813 accuracy: 0.84400: 100%|██████████| 751/751 [05:47<00:00, 2.16it/s]
loss: nan ; accuracy: 0.84616: 100%|██████████| 3010/3010 [1:13:44<00:00, 1.47s/it]
loss: nan accuracy: 0.84765: 100%|██████████| 751/751 [05:46<00:00, 2.17it/s]
and when calculating AUC with 2nd epoch validation data
ValueError: Input contains NaN, infinity or a value too large for dtype('float32').