Please paste the code properly in ```
P.S. I see that the
return best_state
is also there, are you sure you are returning after several epochs? And not just after 1 epoch? Or whenever the acc > best_acc ? ( It can’t be figured out as you have no indentations in your question.)