JuliaNLSolvers / Optim.jl

Optimization functions for Julia
Other
1.12k stars 217 forks source link

Extended trace for Adam fails #1096

Open tam724 opened 4 months ago

tam724 commented 4 months ago

When running an optimization with Adam() and the extended trace enabled, the code fails. See the following MWE:

using Optim
f(x) = (x[1]-1)^2
 # runs without error
Optim.optimize(f, [0.0], Adam(), Optim.Options(extended_trace=false))
# fails with "type AdamState has no field alpha"
Optim.optimize(f, [0.0], Adam(), Optim.Options(extended_trace=true))

The problem is that common_trace! tries to access state.alpha, which is not a property of AdamState.

Tested on Optim v1.9.4 and julia v1.10.3.