Skip to content

Commit 2665d5d

Browse files
committed
rm opt_freq
1 parent 4362c2c commit 2665d5d

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

skglm/solvers/fista.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ class FISTA(BaseSolver):
1818
tol : float, default 1e-4
1919
Tolerance for convergence.
2020
21-
opt_freq : int, default 10
22-
Frequency for optimality condition check.
23-
2421
verbose : bool, default False
2522
Amount of verbosity. 0/False is silent.
2623
@@ -32,10 +29,9 @@ class FISTA(BaseSolver):
3229
https://epubs.siam.org/doi/10.1137/080716542
3330
"""
3431

35-
def __init__(self, max_iter=100, tol=1e-4, opt_freq=10, verbose=0):
32+
def __init__(self, max_iter=100, tol=1e-4, verbose=0):
3633
self.max_iter = max_iter
3734
self.tol = tol
38-
self.opt_freq = opt_freq
3935
self.verbose = verbose
4036

4137
def solve(self, X, y, datafit, penalty, w_init=None, Xw_init=None):
@@ -67,19 +63,18 @@ def solve(self, X, y, datafit, penalty, w_init=None, Xw_init=None):
6763
Xw = X @ w
6864
z = w + (t_old - 1.) / t_new * (w - w_old)
6965

70-
if n_iter % self.opt_freq == 0:
71-
opt = penalty.subdiff_distance(w, grad, all_features)
72-
stop_crit = np.max(opt)
66+
opt = penalty.subdiff_distance(w, grad, all_features)
67+
stop_crit = np.max(opt)
7368

74-
if self.verbose:
75-
p_obj = datafit.value(y, w, Xw) + penalty.value(w)
76-
print(
77-
f"Iteration {n_iter+1}: {p_obj:.10f}, "
78-
f"stopping crit: {stop_crit:.2e}"
79-
)
69+
if self.verbose:
70+
p_obj = datafit.value(y, w, Xw) + penalty.value(w)
71+
print(
72+
f"Iteration {n_iter+1}: {p_obj:.10f}, "
73+
f"stopping crit: {stop_crit:.2e}"
74+
)
8075

81-
if stop_crit < self.tol:
82-
if self.verbose:
83-
print(f"Stopping criterion max violation: {stop_crit:.2e}")
84-
break
76+
if stop_crit < self.tol:
77+
if self.verbose:
78+
print(f"Stopping criterion max violation: {stop_crit:.2e}")
79+
break
8580
return w

0 commit comments

Comments
 (0)