【发布时间】:2019-01-30 19:48:24
【问题描述】:
我已经有一个经过训练的神经网络,
clf = neural_network.MLPClassifier(
activation='relu',
hidden_layer_sizes=(40,40,40,40),
learning_rate='adaptive',
learning_rate_init=0.01,
solver='sgd',
alpha=1e-6,
max_iter=20000,
warm_start=True,
)
我已经训练过了,
clf.fit(X,Y)
这个分类器有两个类[0,1]。
现在,当我一次使用数据集中的一个数据进一步训练它时。 clf.fit([features_1],[1]) 错误弹出
Traceback (most recent call last):
File "<pyshell#20>", line 1, in <module>
fav_clf.fit(X_, Y)
File "D:\Python3.5\lib\site-packages\sklearn\neural_network\multilayer_perceptron.py", line 973, in fit
hasattr(self, "classes_")))
File "D:\Python3.5\lib\site-packages\sklearn\neural_network\multilayer_perceptron.py", line 331, in _fit
X, y = self._validate_input(X, y, incremental)
File "D:\Python3.5\lib\site-packages\sklearn\neural_network\multilayer_perceptron.py", line 924, in _validate_input
(self.classes_, classes))
ValueError: warm_start can only be used where `y` has the same classes as in the previous call to fit. Previously got [0 1], `y` has [1]
【问题讨论】:
-
你不能只用一个样本来调用
fit()。请改用partial_fit()。
标签: python python-3.x scikit-learn neural-network python-3.5