Skip to content

Commit f721d7e

Browse files
committed
dual_steps ---> dual_step
1 parent fba2d04 commit f721d7e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

skglm/experimental/pdcd_ws.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def _solve(self, X, y, datafit, penalty, w_init=None, Xw_init=None):
101101
# init steps
102102
# choose steps to verify condition: Assumption 2.1 e)
103103
scale = np.sqrt(2 * n_features)
104-
dual_steps = 1 / (norm(X, ord=2) * scale)
104+
dual_step = 1 / (norm(X, ord=2) * scale)
105105
primal_steps = 1 / (norm(X, axis=0, ord=2) * scale)
106106

107107
# NOTE: primal and dual steps verify condition on steps when multiplied/divided
@@ -110,10 +110,10 @@ def _solve(self, X, y, datafit, penalty, w_init=None, Xw_init=None):
110110
# in the space with highest number of variable
111111
ratio = n_samples / n_features
112112
if n_samples > n_features:
113-
dual_steps *= ratio
113+
dual_step *= ratio
114114
primal_steps /= ratio
115115
else:
116-
dual_steps /= ratio
116+
dual_step /= ratio
117117
primal_steps *= ratio
118118

119119
# primal vars
@@ -136,7 +136,7 @@ def _solve(self, X, y, datafit, penalty, w_init=None, Xw_init=None):
136136

137137
# check convergence using fixed-point criteria on both dual and primal
138138
opts_primal = _scores_primal(X, w, z, penalty, primal_steps, all_features)
139-
opt_dual = _score_dual(y, z, Xw, datafit, dual_steps)
139+
opt_dual = _score_dual(y, z, Xw, datafit, dual_step)
140140

141141
stop_crit = max(max(opts_primal), opt_dual)
142142

@@ -161,7 +161,7 @@ def _solve(self, X, y, datafit, penalty, w_init=None, Xw_init=None):
161161
# inplace update of w, Xw, z, z_bar
162162
PDCD_WS._solve_subproblem(
163163
y, X, w, Xw, z, z_bar, datafit, penalty,
164-
primal_steps, dual_steps, ws, self.max_epochs, tol_in=0.3*stop_crit, verbose=self.verbose-1)
164+
primal_steps, dual_step, ws, self.max_epochs, tol_in=0.3*stop_crit, verbose=self.verbose-1)
165165

166166
current_p_obj = datafit.value(y, w, Xw) + penalty.value(w)
167167
p_objs.append(current_p_obj)
@@ -179,7 +179,7 @@ def _solve(self, X, y, datafit, penalty, w_init=None, Xw_init=None):
179179
@njit
180180
def _solve_subproblem(
181181
y, X, w, Xw, z, z_bar, datafit, penalty, primal_steps,
182-
dual_steps, ws, max_epochs, tol_in, verbose):
182+
dual_step, ws, max_epochs, tol_in, verbose):
183183
n_features = X.shape[1]
184184

185185
for epoch in range(max_epochs):
@@ -198,14 +198,14 @@ def _solve_subproblem(
198198
Xw += delta_w_j * X[:, j]
199199

200200
# update dual
201-
z_bar[:] = datafit.prox_conjugate(z + dual_steps * Xw,
202-
dual_steps, y)
201+
z_bar[:] = datafit.prox_conjugate(z + dual_step * Xw,
202+
dual_step, y)
203203
z += (z_bar - z) / n_features
204204

205205
# check convergence using fixed-point criteria on both dual and primal
206206
if epoch % 1 == 0:
207207
opts_primal_in = _scores_primal(X, w, z, penalty, primal_steps, ws)
208-
opt_dual_in = _score_dual(y, z, Xw, datafit, dual_steps)
208+
opt_dual_in = _score_dual(y, z, Xw, datafit, dual_step)
209209

210210
stop_crit_in = max(max(opts_primal_in), opt_dual_in)
211211
# if verbose:
@@ -241,7 +241,7 @@ def _scores_primal(X, w, z, penalty, primal_steps, ws):
241241

242242

243243
@njit
244-
def _score_dual(y, z, Xw, datafit, dual_steps):
245-
next_z = datafit.prox_conjugate(z + dual_steps * Xw,
246-
dual_steps, y)
244+
def _score_dual(y, z, Xw, datafit, dual_step):
245+
next_z = datafit.prox_conjugate(z + dual_step * Xw,
246+
dual_step, y)
247247
return norm(z - next_z, ord=np.inf)

0 commit comments

Comments
 (0)