How to query valid_loss?

Is it possible to query the validation loss within the python script? I think something like below would be useful for what I’m doing.

while valid_loss > 200:
    learn.fit_one_cycle(5, 2e-4)
    learn.fit_one_cycle(1, 2e-2)
    learn.fit_one_cycle(25, 2e-3)

In fastai this would probably be best handled via a callback. I’d start with EarlyStopping callback ( and try to modify it to fit your needs.

1 Like