Search code examples
tensorflowkerasmetricsloss

Retrive Maximum and Minium Loss and Metrics Values


during my training and validation, i get report of losses and metrics values at the end of each epoch, like this:

Epoch 1333/2000
191/191 - 3s - loss: 8818.4761 - nossa_metrica: 0.7923 - val_loss: 13217.6983 - val_nossa_metrica: 0.1557
Epoch 1334/2000
191/191 - 3s - loss: 8826.9803 - nossa_metrica: 0.8908 - val_loss: 13738.7320 - val_nossa_metrica: 0.1819
Epoch 1335/2000
191/191 - 3s - loss: 8823.2309 - nossa_metrica: 0.8967 - val_loss: 14265.0050 - val_nossa_metrica: 0.1822
Epoch 1336/2000
191/191 - 3s - loss: 8825.7040 - nossa_metrica: 0.8921 - val_loss: 13878.6077 - val_nossa_metrica: 0.1812

Is there anyway i can get the maximum and minimum values of all those 4 variables after the training/validation is over?


Solution

  • You can assign the output of the fit (or fit_generator) method to a variable and retrieve the elements that you want. For example, if you use model.fit() like below:

    history = model.fit(x_train, y_train, epochs=100)
    

    You can access the metrics using history.history, which is a dictionary that has a list for each of the four variables above. Then you can obtain each list's min and max as desired.

    min(history.history["loss"]), max(history.history["loss"])