8000 [MRG+1] FIX out of bounds array access in SAGA (#9376) · scikit-learn/scikit-learn@055d17b · GitHub
[go: up one dir, main page]

Skip to content

Commit 055d17b

Browse files
jnothmanogrisel
authored andcommitted
[MRG+1] FIX out of bounds array access in SAGA (#9376)
* FIX out of bounds array access in SAGA * FIX Fix boundary for condition
1 parent 28ad450 commit 055d17b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sklearn/linear_model/sag_fast.pyx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,10 +614,14 @@ cdef void lagged_update(double* weights, double wscale, int xnnz,
614614
last_update_ind = sample_itr - 1
615615
for lagged_ind in range(sample_itr - 1,
616616
last_update_ind - 1, -1):
617-
grad_step = (cumulative_sums[lagged_ind]
618-
- cumulative_sums[lagged_ind - 1])
619-
prox_step = (cumulative_sums_prox[lagged_ind]
620-
- cumulative_sums_prox[lagged_ind - 1])
617+
if lagged_ind > 0:
618+
grad_step = (cumulative_sums[lagged_ind]
619+
- cumulative_sums[lagged_ind - 1])
620+
prox_step = (cumulative_sums_prox[lagged_ind]
621+
- cumulative_sums_prox[lagged_ind - 1])
622+
else:
623+
grad_step = cumulative_sums[lagged_ind]
624+
prox_step = cumulative_sums_prox[lagged_ind]
621625
weights[idx] -= sum_gradient[idx] * grad_step
622626
weights[idx] = _soft_thresholding(weights[idx],
623627
prox_step)

0 commit comments

Comments
 (0)
0