# Using EarlyStopping.jl

**URL:** <https://discourse.julialang.org/t/using-earlystopping-jl/121537>\
**Category:** General Usage\
**Tags:** question, package\
**Created:** [October 21, 2024, 3:38pm UTC](https://discourse.julialang.org/t/using-earlystopping-jl/121537 "2024-10-21T15:38:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![onedeeper](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/onedeeper/32/212517_2.png) [@onedeeper](https://discourse.julialang.org/u/onedeeper)\
**Post date:** [October 21, 2024, 3:38pm UTC](https://discourse.julialang.org/t/using-earlystopping-jl/121537/1 "2024-10-21T15:38:52Z")

</div>

Hi all,

I’m trying to use [EarlyStopping.jl](https://github.com/JuliaAI/EarlyStopping.jl).  
If I understood the documentation, the following should work, though it doesn’t seem to:

```julia
#add early stopping call back from EarlyStopping.jl
function callback!(p,l,early_stopper)
    return done!(early_stopper,l)
end

stopper = EarlyStopper(Patience(1), verbosity = 1)
callback!(p,l) = callback!(p,l,stopper)

opt_solve = Optimization.solve(opt,Optimisers.Adam(0.01),maxiters = 10000, callback = callback!)

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/1/31cc3cd30848652645adaf1a7e4afeb2ffedbc59.png)

I see the n\_increases number go up though. Anyone have experience a simpler use case or can tell me if I’m making a mistake with the closure ?

Thanks!
