@@ -346,7 +346,7 @@ def _fit(self, X, y, incremental=False):
346
346
self ._initialize (y , layer_units )
347
347
348
348
# l-bfgs does not support mini-batches
349
- if self .algorithm == 'l-bfgs' :
349
+ if self .batch_size == 'auto' or self . algorithm == 'l-bfgs' :
350
350
batch_size = n_samples
351
351
else :
352
352
if self .batch_size < 1 or self .batch_size > n_samples :
@@ -493,7 +493,11 @@ def _fit_stochastic(self, X, y, activations, deltas, coef_grads,
493
493
y_val = None
494
494
495
495
n_samples = X .shape [0 ]
496
- batch_size = np .clip (self .batch_size , 1 , n_samples )
496
+
497
+ if self .batch_size == 'auto' :
498
+ batch_size = n_samples
499
+ else :
500
+ batch_size = np .clip (self .batch_size , 1 , n_samples )
497
501
498
502
try :
499
503
for it in range (self .max_iter ):
@@ -714,7 +718,7 @@ class MLPClassifier(BaseMultilayerPerceptron, ClassifierMixin):
714
718
alpha : float, optional, default 0.0001
715
719
L2 penalty (regularization term) parameter.
716
720
717
- batch_size : int, optional, default 200
721
+ batch_size : int, optional, default 'auto'
718
722
Size of minibatches for stochastic optimizers.
719
723
If the algorithm is 'l-bfgs', the classifier will not use minibatch.
720
724
@@ -864,7 +868,7 @@ class MLPClassifier(BaseMultilayerPerceptron, ClassifierMixin):
864
868
"""
865
869
def __init__ (self , hidden_layer_sizes = (100 ,), activation = "relu" ,
866
870
algorithm = 'adam' , alpha = 0.0001 ,
867
- batch_size = 200 , learning_rate = "constant" ,
871
+ batch_size = 'auto' , learning_rate = "constant" ,
868
872
learning_rate_init = 0.001 , power_t = 0.5 , max_iter = 200 ,
869
873
shuffle = True , random_state = None , tol = 1e-4 ,
870
874
verbose = False , warm_start = False , momentum = 0.9 ,
@@ -1067,7 +1071,7 @@ class MLPRegressor(BaseMultilayerPerceptron, RegressorMixin):
1067
1071
alpha : float, optional, default 0.0001
1068
1072
L2 penalty (regularization term) parameter.
1069
1073
1070
- batch_size : int, optional, default 200
1074
+ batch_size : int, optional, default 'auto'
1071
1075
Size of minibatches for stochastic optimizers.
1072
1076
If the algorithm is 'l-bfgs', the classifier will not use minibatch.
1073
1077
@@ -1211,7 +1215,7 @@ class MLPRegressor(BaseMultilayerPerceptron, RegressorMixin):
1211
1215
"""
1212
1216
def __init__ (self , hidden_layer_sizes = (100 ,), activation = "relu" ,
1213
1217
algorithm = 'adam' , alpha = 0.0001 ,
1214
- batch_size = 200 , learning_rate = "constant" ,
1218
+ batch_size = 'auto' , learning_rate = "constant" ,
1215
1219
learning_rate_init = 0.001 ,
1216
1220
power_t = 0.5 , max_iter = 200 , shuffle = True ,
1217
1221
random_state = None , tol = 1e-4 ,
0 commit comments