A way to save the best model according to val loss?


Hi I’m trying to save the best model when the validation loss is minimum
this is not my code but I simplified the code for the convenience :slight_smile:

in this code I can’t understand the part where
if best_score > avg_val_loss:

since best_score value is np.inf
what does it mean by np.inf > avg_val_loss??

how can I save the model according to the validation loss?

any comment would help me!
thanks and have a nice day!

you could try:

best_score = 0
if best_score < avg_val_score:
    best_score = avg_val_score

thanks bro!
but what does it mean by “save the model when avg_val_loss is less than np.inf?”

sorry, I also can not understand it.

I think best_score > avg_val_loss always holds.
1 Like