From 9c4b1d971b51918799b138b9f0c0c818fd2c27e0 Mon Sep 17 00:00:00 2001 From: Enzo Busseti Date: Wed, 5 Jun 2024 00:33:16 +0400 Subject: [PATCH] fixed issue with sparse direction; was overwriting a vector (Python is thinly disguised C) --- project_euromir/tests/lbfgs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project_euromir/tests/lbfgs.py b/project_euromir/tests/lbfgs.py index 1d1c27f..730178f 100644 --- a/project_euromir/tests/lbfgs.py +++ b/project_euromir/tests/lbfgs.py @@ -93,7 +93,7 @@ def lbfgs_multiply( rhos[i] = 1. / np.dot(past_steps[i], past_grad_diffs[i]) # using paper notation - q = current_gradient + q = np.copy(current_gradient) # right part, backward iteration alphas = np.empty(memory, dtype=float) @@ -218,7 +218,7 @@ def minimize_lbfgs( scale = np.dot(past_steps[-1], past_grad_diffs[-1]) / np.dot( past_grad_diffs[-1], past_grad_diffs[-1]) - direction[:] = - _lbfgs_multiply_dense( + direction[:] = - lbfgs_multiply( current_gradient=current_gradient, past_steps=past_steps[memory-i:], past_grad_diffs=past_grad_diffs[memory-i:],