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 26, 2023
1 parent f20e897 commit 6f3556e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/trustRegion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,15 @@ function retrospective_step!(cache::TrustRegionCache)
@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 6f3556e

Please sign in to comment.