如何确定sklearn中MLPClassifier的“损失函数”?

Ahm*_*mad 5 classification machine-learning neural-network scikit-learn

我想使用sklearn的MLPClassifier

mlp = MLPClassifier(hidden_layer_sizes=(50,), max_iter=10, alpha=1e-4,
                solver='sgd', verbose=10, tol=1e-4, random_state=1,
                learning_rate_init=.1)
Run Code Online (Sandbox Code Playgroud)

我没有找到损失函数的任何参数,我希望它是mean_squared_error。是否可以根据模型来确定?

che*_*ate 5

根据文档

该模型使用 LBFGS 或随机梯度下降来优化对数损失函数。

对数损失与交叉熵基本相同。

无法将另一个损失函数传递给MLPClassifier,因此不能使用 MSE。但MLPRegressor如果你真的想要的话,可以使用 MSE。

然而,一般建议是坚持使用交叉熵损失进行分类,据说它比 MSE 有一些优势。因此,您可能只想按MLPClassifier原样使用您的分类问题。