From 610fc451f08d194835297dc72b04f00013ea4675 Mon Sep 17 00:00:00 2001 From: Aaron Fenyes Date: Mon, 8 Jul 2024 14:19:25 -0700 Subject: [PATCH] Track slope in gradient descent history --- engine-proto/gram-test/Engine.jl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/engine-proto/gram-test/Engine.jl b/engine-proto/gram-test/Engine.jl index a874485..e8bda9c 100644 --- a/engine-proto/gram-test/Engine.jl +++ b/engine-proto/gram-test/Engine.jl @@ -65,15 +65,17 @@ end # a type for keeping track of gradient descent history struct DescentHistory{T} scaled_loss::Array{T} + slope::Array{T} stepsize::Array{T} backoff_steps::Array{Int64} function DescentHistory{T}( scaled_loss = Array{T}(undef, 0), + slope = Array{T}(undef, 0), stepsize = Array{T}(undef, 0), backoff_steps = Int64[] ) where T - new(scaled_loss, stepsize, backoff_steps) + new(scaled_loss, slope, stepsize, backoff_steps) end end @@ -113,10 +115,11 @@ function realize_gram( neg_grad = 4*Q*L*Δ_proj slope = norm(neg_grad) - # store current position and loss + # store current position, loss, and slope L_last = L loss_last = loss push!(history.scaled_loss, loss / scale_adjustment) + push!(history.slope, slope) # find a good step size using backtracking line search push!(history.stepsize, 0)