Callback logs values for validation metrics are not very clear

Hi,

Prince here, (Removed by Moderator)

We have an integration with Keras that uses the Callback system and I have a question related to it:

  • Why are the loss and metric values on_test_end() logs the same as val_loss and val_metric values on_epoch_end() and on_train_end() when you pass a validation split or dataset?

Here is an output example:

on_test_end
test/epoch/loss ---> 6.655152320861816
test/epoch/mean_absolute_error ---> 2.1341843605041504

on_epoch_end
train/epoch/val_loss ---> 6.655152320861816
train/epoch/val_mean_absolute_error ---> 2.1341843605041504

on_train_end
train/epoch/val_loss ---> 6.655152320861816
train/epoch/val_mean_absolute_error ---> 2.1341843605041504

GitHub Issue: BUG: validation metrics not logged per epoch, only per batch · Issue #10 · neptune-ai/neptune-tensorflow-keras · GitHub

Hi @Prince_Canuma

Welcome to the TensorFlow Forum!

Could you please share the reproducible code to replicate the error and to understand the issue? There could be reason that validation_split is not working correctly. There is no train loss logged which should log as train/epoch/loss —> 0.24162766337394714, train/epoch/accuracy —> 0.9091500043869019.

I have tried replicating this issue with sample code and it’s working as expected using TensorFlow 2.14 and Python 3.10 in Google Colab. (Attached the replicated gist for your reference.)

on_test_end
test/epoch/loss ---> 0.3435165584087372
test/epoch/accuracy ---> 0.876800000667572

 on_epoch_end
train/epoch/loss ---> 0.24162766337394714             # <---------    
train/epoch/accuracy ---> 0.9091500043869019.         # <---------
train/epoch/val_loss ---> 0.3435165584087372
train/epoch/val_accuracy ---> 0.876800000667572

1875/1875 [==============================] - 7s 4ms/step - loss: 0.2416 - accuracy: 0.9092 - val_loss: 0.3435 - val_accuracy: 0.8768

 on_train_end
train/epoch/loss ---> 0.24162766337394714    #<-----------
train/epoch/accuracy ---> 0.9091500043869019 #<-----------
train/epoch/val_loss ---> 0.3435165584087372
train/epoch/val_accuracy ---> 0.876800000667572

<keras.src.callbacks.History at 0x7c4fb0eb5b10>

Thank you but it’s not necessary anymore. :slightly_smiling_face: