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(
220220 sum_term < 0 , alpha ** 2 * g_d_term / (2 * sum_term ), fallback_alpha
221221 )
222222
223+ alpha = jnp .where (alpha > 0 , alpha , fallback_alpha )
224+
223225 return alpha
224226
225227
@@ -343,7 +345,7 @@ def line_search(
343345 )
344346
345347 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 :
347349 alpha = _hager_zhang_initial_zero (input_tensors , gradient , varipeps_config )
348350 elif varipeps_config .line_search_hager_zhang_quad_step :
349351 try :
@@ -371,6 +373,7 @@ def line_search(
371373 last_step_size
372374 if last_step_size is not None
373375 and varipeps_config .line_search_use_last_step_size
376+ and last_step_size > 0
374377 else varipeps_config .line_search_initial_step_size
375378 )
376379
@@ -1001,6 +1004,9 @@ def line_search(
10011004 hager_zhang_upper_bound_des_grad - hager_zhang_lower_bound_des_grad
10021005 )
10031006
1007+ if alpha <= 0 :
1008+ tqdm .write ("Found negative alpha in secant operation!" )
1009+
10041010 hz_secant_alpha = alpha
10051011
10061012 hz_secant_lower = hager_zhang_lower_bound
You can’t perform that action at this time.
0 commit comments