# Early stopping with Optim when the validation loss increases

**URL:** <https://discourse.julialang.org/t/early-stopping-with-optim-when-the-validation-loss-increases/53008>\
**Category:** Optimization (Mathematical)\
**Tags:** optim\
**Created:** [January 7, 2021, 8:55pm UTC](https://discourse.julialang.org/t/early-stopping-with-optim-when-the-validation-loss-increases/53008 "2021-01-07T20:55:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sobhan](https://avatars.discourse-cdn.com/v4/letter/s/258eb7/32.png) [@sobhan](https://discourse.julialang.org/u/sobhan)\
**Post date:** [January 7, 2021, 8:55pm UTC](https://discourse.julialang.org/t/early-stopping-with-optim-when-the-validation-loss-increases/53008/1 "2021-01-07T20:55:30Z")

</div>

I’m using Optim.jl to train a model but it keeps overfiting. is there nice way of implementing a early stopping callback that has the current x? I tried setting the callback in Optim.Options but i only get the iteration, loss and time. is it possible to access other optimizer states?

---

<div class="post-metadata">

**Author:** ![pkofod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pkofod/32/2179_2.png) [@pkofod](https://discourse.julialang.org/u/pkofod)\
**Post date:** [January 7, 2021, 10:17pm UTC](https://discourse.julialang.org/t/early-stopping-with-optim-when-the-validation-loss-increases/53008/2 "2021-01-07T22:17:56Z")

</div>

Yes, it should work if you set `extended_trace=true` in the options
