forked from JuliaNLSolvers/Optim.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrace.jl
More file actions
31 lines (31 loc) · 772 Bytes
/
trace.jl
File metadata and controls
31 lines (31 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# First order methods trace, used by AcceleratedGradientDescent,
# ConjugateGradient, GradientDescent, LBFGS and MomentumGradientDescent
function common_trace!(
tr,
d,
state,
iteration::Integer,
method::FirstOrderOptimizer,
options::Options,
curr_time = time(),
)
dt = Dict()
dt["time"] = curr_time
if options.extended_trace
dt["x"] = copy(state.x)
dt["g(x)"] = copy(gradient(d))
dt["Current step size"] = state.alpha
end
g_norm = Base.maximum(abs, gradient(d)) # Base.maximum !== maximum
update!(
tr,
iteration,
value(d),
g_norm,
dt,
options.store_trace,
options.show_trace,
options.show_every,
options.callback,
)
end