为多个隐藏层设置sklearn MLPClassizer的激活参数

2024-07-08 11:23:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我设计了一个神经网络,它有两个具有不同激活函数的隐藏层。如何使用sklearn.neural_network.mlpclassizer库为每个层设置不同于其他层的激活函数

有类似的东西吗

from sklearn.neural_network import MLPClassifier
clf = MLPClassifier(alpha=1e-5 ,hidden_layer_sizes=(10,5),activation=['tanh','relu'])

错误是: 错误为:“raise VALUERROR”(“不支持激活“%s”)


Tags: 函数fromimportalphalayer错误神经网络network
1条回答
网友
1楼 · 发布于 2024-07-08 11:23:20

documentation开始,激活可以是:

activation{‘identity’, ‘logistic’, ‘tanh’, ‘relu’}, default=’relu’

    Activation function for the hidden layer.

        ‘identity’, no-op activation, useful to implement linear bottleneck, returns f(x) = x

        ‘logistic’, the logistic sigmoid function, returns f(x) = 1 / (1 + exp(-x)).

        ‘tanh’, the hyperbolic tan function, returns f(x) = tanh(x).

        ‘relu’, the rectified linear unit function, returns f(x) = max(0, x)

没有为不同层设置不同激活的选项。回想一下,MLP在概念上比成熟的神经网络更简单。如果您想要一个简单的体系结构,那么为什么不对两个层使用相同的激活呢?如果你想要更多的控制,那么就切换到真正的深度学习框架

相关问题 更多 >

    热门问题