File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -220,6 +220,8 @@ def _hager_zhang_initial_quad_step_inner(
220
220
sum_term < 0 , alpha ** 2 * g_d_term / (2 * sum_term ), fallback_alpha
221
221
)
222
222
223
+ alpha = jnp .where (alpha > 0 , alpha , fallback_alpha )
224
+
223
225
return alpha
224
226
225
227
@@ -343,7 +345,7 @@ def line_search(
343
345
)
344
346
345
347
if varipeps_config .line_search_method is Line_Search_Methods .HAGERZHANG :
346
- if last_step_size is None :
348
+ if last_step_size is None or last_step_size <= 0 :
347
349
alpha = _hager_zhang_initial_zero (input_tensors , gradient , varipeps_config )
348
350
elif varipeps_config .line_search_hager_zhang_quad_step :
349
351
try :
@@ -371,6 +373,7 @@ def line_search(
371
373
last_step_size
372
374
if last_step_size is not None
373
375
and varipeps_config .line_search_use_last_step_size
376
+ and last_step_size > 0
374
377
else varipeps_config .line_search_initial_step_size
375
378
)
376
379
@@ -1001,6 +1004,9 @@ def line_search(
1001
1004
hager_zhang_upper_bound_des_grad - hager_zhang_lower_bound_des_grad
1002
1005
)
1003
1006
1007
+ if alpha <= 0 :
1008
+ tqdm .write ("Found negative alpha in secant operation!" )
1009
+
1004
1010
hz_secant_alpha = alpha
1005
1011
1006
1012
hz_secant_lower = hager_zhang_lower_bound
You can’t perform that action at this time.
0 commit comments