Skip to content

Commit

Permalink
expose quadratic form structure explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
FHoltorf committed Sep 14, 2023
1 parent bf1b27d commit 332a3bf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/trustRegion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ function retrospective_step!(cache::TrustRegionCache{true})
@unpack H, g, step_size = cache

return -(get_loss(fu_prev) - get_loss(fu)) /
(step_size' * g + step_size' * H * step_size / 2)
(dot(step_size, g) + dot(step_size, H, step_size) / 2)
end

function retrospective_step!(cache::TrustRegionCache{false})
Expand All @@ -470,15 +470,15 @@ function retrospective_step!(cache::TrustRegionCache{false})
@unpack H, g, step_size = cache

return -(get_loss(fu_prev) - get_loss(fu)) /
(step_size' * g + step_size' * H * step_size / 2)
(dot(step_size, g) + dot(step_size, H, step_size) / 2)
end

function trust_region_step!(cache::TrustRegionCache)
@unpack fu_new, step_size, g, H, loss, max_trust_r, radius_update_scheme = cache
cache.loss_new = get_loss(fu_new)

# Compute the ratio of the actual reduction to the predicted reduction.
cache.r = -(loss - cache.loss_new) / (step_size' * g + step_size' * H * step_size / 2)
cache.r = -(loss - cache.loss_new) / (dot(step_size, g) + dot(step_size, H, step_size) / 2)
@unpack r = cache

if radius_update_scheme === RadiusUpdateSchemes.Simple
Expand Down

0 comments on commit 332a3bf

Please sign in to comment.