How to evaluate metrics every batch instead of epoch?

I’d like to evaluate metrics for training every batch instead of every epoch. And I want to apply SaveModelCallback based on the best result of the batch in an epoch. How to do that? Thanks.

I’d like to evaluate metrics for training every batch instead of every epoch

Look into the callback system. To do something every batch, you’ll likely use the after_batch event and then do whatever evaluation you want there.

I want to apply SaveModelCallback based on the best result of the batch in an epoch

Again you’ll likely want something in the after_batch event. You can probably copy SaveModelCallback and instead of having it compare models in after_epoch and then save in after_fit, you’ll do the comparisons in after_batch and save whenever you want.

1 Like