8000 fix lbfgs rename · amueller/scikit-learn@431e879 · GitHub
[go: up one dir, main page]

Skip to content

Commit 431e879

Browse files
committed
fix lbfgs rename
1 parent 5fcc7e5 commit 431e879

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

doc/modules/neural_networks_supervised.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ training samples::
8686
>>> from sklearn.neural_network import MLPClassifier
8787
>>> X = [[0., 0.], [1., 1.]]
8888
>>> y = [0, 1]
89-
>>> clf = MLPClassifier(solver='lbgfs', alpha=1e-5,
89+
>>> clf = MLPClassifier(solver='lbfgs', alpha=1e-5,
9090
... hidden_layer_sizes=(5, 2), random_state=1)
9191
...
9292
>>> clf.fit(X, y) # doctest: +NORMALIZE_WHITESPACE
@@ -95,7 +95,7 @@ training samples::
9595
epsilon=1e-08, hidden_layer_sizes=(5, 2), learning_rate='constant',
9696
learning_rate_init=0.001, max_iter=200, momentum=0.9,
9797
nesterovs_momentum=True, power_t=0.5, random_state=1, shuffle=True,
98-
solver='lbgfs', tol=0.0001, validation_fraction=0.1, verbose=False,
98+
solver='lbfgs', tol=0.0001, validation_fraction=0.1, verbose=False,
9999
warm_start=False)
100100

101101
After fitting (training), the model can predict labels for new samples::
@@ -134,7 +134,7 @@ indices where the value is `1` represents the assigned classes of that sample::
134134

135135
>>> X = [[0., 0.], [1., 1.]]
136136
>>> y = [[0, 1], [1, 1]]
137-
>>> clf = MLPClassifier(solver='lbgfs', alpha=1e-5,
137+
>>> clf = MLPClassifier(solver='lbfgs', alpha=1e-5,
138138
... hidden_layer_sizes=(15,), random_state=1)
139139
...
140140
>>> clf.fit(X, y) # doctest: +NORMALIZE_WHITESPACE
@@ -143,7 +143,7 @@ indices where the value is `1` represents the assigned classes of that sample::
143143
epsilon=1e-08, hidden_layer_sizes=(15,), learning_rate='constant',
144144
learning_rate_init=0.001, max_iter=200, momentum=0.9,
145145
nesterovs_momentum=True, power_t=0.5, random_state=1, shuffle=True,
146-
solver='lbgfs', tol=0.0001, validation_fraction=0.1, verbose=False,
146+
solver='lbfgs', tol=0.0001, validation_fraction=0.1, verbose=False,
147147
warm_start=False)
148148
>>> clf.predict([1., 2.])
149149
array([[1, 1]])

sklearn/neural_network/multilayer_perceptron.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def _loss_grad_lbfgs(self, packed_coef_inter, X, y, activations, deltas,
134134
with respect to the different parameters given in the initialization.
135135
136136
Returned gradients are packed in a single vector so it can be used
137-
in lbgfs
137+
in lbfgs
138138
139139
Parameters
140140
----------
@@ -345,8 +345,8 @@ def _fit(self, X, y, incremental=False):
345345
# First time training the model
346346
self._initialize(y, layer_units)
347347

348-
# lbgfs does not support mini-batches
349-
if self.solver == 'lbgfs':
348+
# lbfgs does not support mini-batches
349+
if self.solver == 'lbfgs':
350350
batch_size = n_samples
351351
elif self.batch_size == 'auto':
352352
batch_size = min(200, n_samples)
@@ -375,7 +375,7 @@ def _fit(self, X, y, incremental=False):
375375
intercept_grads, layer_units, incremental)
376376

377377
# Run the LBFGS solver
378-
elif self.solver == 'lbgfs':
378+
elif self.solver == 'lbfgs':
379379
self._fit_lbfgs(X, y, activations, deltas, coef_grads,
380380
intercept_grads, layer_units)
381381
return self
@@ -422,7 +422,7 @@ def _validate_hyperparameters(self):
422422
if self.learning_rate not in ["constant", "invscaling", "adaptive"]:
423423
raise ValueError("learning rate %s is not supported. " %
424424
self.learning_rate)
425-
supported_solvers = _STOCHASTIC_SOLVERS + ["lbgfs"]
425+
supported_solvers = _STOCHASTIC_SOLVERS + ["lbfgs"]
426426
if self.solver not in supported_solvers:
427427
raise ValueError("The solver %s is not supported. "
428428
" Expected one of: %s" %
@@ -704,10 +704,10 @@ class MLPClassifier(BaseMultilayerPerceptron, ClassifierMixin):
704704
- 'relu', the rectified linear unit function,
705705
returns f(x) = max(0, x)
706706
707-
solver : {'lbgfs', 'sgd', 'adam'}, default 'adam'
707+
solver : {'lbfgs', 'sgd', 'adam'}, default 'adam'
708708
The solver for weight optimization.
709709
710-
- 'lbgfs' is an optimizer in the family of quasi-Newton methods.
710+
- 'lbfgs' is an optimizer in the family of quasi-Newton methods.
711711
712712
- 'sgd' refers to stochastic gradient descent.
713713
@@ -717,15 +717,15 @@ class MLPClassifier(BaseMultilayerPerceptron, ClassifierMixin):
717717
Note: The default solver 'adam' works pretty well on relatively
718718
large datasets (with thousands of training samples or more) in terms of
719719
both training time and validation score.
720-
For small datasets, however, 'lbgfs' can converge faster and perform
720+
For small datasets, however, 'lbfgs' can converge faster and perform
721721
better.
722722
723723
alpha : float, optional, default 0.0001
724724
L2 penalty (regularization term) parameter.
725725
726726
batch_size : int, optional, default 'auto'
727727
Size of minibatches for stochastic optimizers.
728-
If the solver is 'lbgfs', the classifier will not use minibatch.
728+
If the solver is 'lbfgs', the classifier will not use minibatch.
729729
When set to "auto", `batch_size=min(200, n_samples)`
730730
731731
learning_rate : {'constant', 'invscaling', 'adaptive'}, default 'constant'
@@ -1046,10 +1046,10 @@ class MLPRegressor(BaseMultilayerPerceptron, RegressorMixin):
10461046
- 'relu', the rectified linear unit function,
10471047
returns f(x) = max(0, x)
10481048
1049-
solver : {'lbgfs', 'sgd', 'adam'}, default 'adam'
1049+
solver : {'lbfgs', 'sgd', 'adam'}, default 'adam'
10501050
The solver for weight optimization.
10511051
1052-
- 'lbgfs' is an optimizer in the family of quasi-Newton methods.
1052+
- 'lbfgs' is an optimizer in the family of quasi-Newton methods.
10531053
10541054
- 'sgd' refers to stochastic gradient descent.
10551055
@@ -1059,15 +1059,15 @@ class MLPRegressor(BaseMultilayerPerceptron, RegressorMixin):
10591059
Note: The default solver 'adam' works pretty well on relatively
10601060
large datasets (with thousands of training samples or more) in terms of
10611061
both training time and validation score.
1062-
For small datasets, however, 'lbgfs' can converge faster and perform
1062+
For small datasets, however, 'lbfgs' can converge faster and perform
10631063
better.
10641064
10651065
alpha : float, optional, default 0.0001
10661066
L2 penalty (regularization term) parameter.
10671067
10681068
batch_size : int, optional, default 'auto'
10691069
Size of minibatches for stochastic optimizers.
1070-
If the solver is 'lbgfs', the classifier will not use minibatch.
1070+
If the solver is 'lbfgs', the classifier will not use minibatch.
10711071
When set to "auto", `batch_size=min(200, n_samples)`
10721072
10731073
learning_rate : {'constant', 'invscaling', 'adaptive'}, default 'constant'

sklearn/neural_network/tests/test_mlp.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def test_gradient():
176176

177177
for activation in ACTIVATION_TYPES:
178178
mlp = MLPClassifier(activation=activation, hidden_layer_sizes=10,
179-
solver='lbgfs', alpha=1e-5,
179+
solver='lbfgs', alpha=1e-5,
180180
learning_rate_init=0.2, max_iter=1,
181181
random_state=1)
182182
mlp.fit(X, y)
@@ -235,7 +235,7 @@ def test_lbfgs_classification():
235235
expected_shape_dtype = (X_test.shape[0], y_train.dtype.kind)
236236

237237
for activation in ACTIVATION_TYPES:
238-
mlp = MLPClassifier(solver='lbgfs', hidden_layer_sizes=50,
238+
mlp = MLPClassifier(solver='lbfgs', hidden_layer_sizes=50,
239239
max_iter=150, shuffle=True, random_state=1,
240240
activation=activation)
241241
mlp.fit(X_train, y_train)
@@ -250,7 +250,7 @@ def test_lbfgs_regression():
250250
X = Xboston
251251
y = yboston
252252
for activation in ACTIVATION_TYPES:
253-
mlp = MLPRegressor(solver='lbgfs', hidden_layer_sizes=50,
253+
mlp = MLPRegressor(solver='lbfgs', hidden_layer_sizes=50,
254254
max_iter=150, shuffle=True, random_state=1,
255255
activation=activation)
256256
mlp.fit(X, y)
@@ -287,7 +287,7 @@ def test_multilabel_classification():
287287
# test fit method
288288
X, y = make_multilabel_classification(n_samples=50, random_state=0,
289289
return_indicator=True)
290-
mlp = MLPClassifier(solver='lbgfs', hidden_layer_sizes=50, alpha=1e-5,
290+
mlp = MLPClassifier(solver='lbfgs', hidden_layer_sizes=50, alpha=1e-5,
291291
max_iter=150, random_state=0, activation='logistic',
292292
learning_rate_init=0.2)
293293
mlp.fit(X, y)
@@ -305,7 +305,7 @@ def test_multilabel_classification():
305305
def test_multioutput_regression():
306306
# Test that multi-output regression works as expected
307307
X, y = make_regression(n_samples=200, n_targets=5)
308-
mlp = MLPRegressor(solver='lbgfs', hidden_layer_sizes=50, max_iter=200,
308+
mlp = MLPRegressor(solver='lbfgs', hidden_layer_sizes=50, max_iter=200,
309309
random_state=1)
310310
mlp.fit(X, y)
311311
assert_greater(mlp.score(X, y), 0.9)
@@ -388,8 +388,8 @@ def test_partial_fit_errors():
388388
assert_raises(ValueError,
389389
MLPClassifier(solver='sgd').partial_fit, X, y, classes=[2])
390390

391-
# lbgfs doesn't support partial_fit
392-
assert_false(hasattr(MLPClassifier(solver='lbgfs'), 'partial_fit'))
391+
# lbfgs doesn't support partial_fit
392+
assert_false(hasattr(MLPClassifier(solver='lbfgs'), 'partial_fit'))
393393

394394

395395
def test_params_errors():
@@ -471,7 +471,7 @@ def test_predict_proba_multilabel():
471471
return_indicator=True)
472472
n_samples, n_classes = Y.shape
473473

474-
clf = MLPClassifier(solver='lbgfs', hidden_layer_sizes=30,
474+
clf = MLPClassifier(solver='lbfgs', hidden_layer_sizes=30,
475475
random_state=0)
476476
clf.fit(X, Y)
477477
y_proba = clf.predict_proba(X)
@@ -493,7 +493,7 @@ def test_sparse_matrices():
493493
X = X_digits_binary[:50]
494494
y = y_digits_binary[:50]
495495
X_sparse = csr_matrix(X)
496-
mlp = MLPClassifier(solver='lbgfs', hidden_layer_sizes=15,
496+
mlp = MLPClassifier(solver='lbfgs', hidden_layer_sizes=15,
497497
random_state=1)
498498
mlp.fit(X, y)
499499
pred1 = mlp.predict(X)

0 commit comments

Comments
 (0)
0