gpt4 book ai didi

python-3.x - 断言错误: Mismatch between dataset size and units in output layer

转载 作者:行者123 更新时间:2023-11-30 09:54:32 25 4
gpt4 key购买 nike

我想使用 scikit-neuralnetwork 进行 NN 分类,我有 5 个类,因此在输出层中,我的单位=5 但我收到此错误:数据集大小与输出层中的单位不匹配,我根据文档 reshape 了 y_train 并将“Sigmoid”函数应用于输出层: http://scikit-neuralnetwork.readthedocs.io/en/latest/guide_model.html#classification

If you want to do multi-label classification, simply fit using a y array of integers that has multiple dimensions, e.g. shape (N, 3) for three different classes. Then, make sure the last layer is Sigmoid instead.

y_train 形状为:(2115, 5)X_train 形状为:(2115, 343)这是代码:

import sknn.mlp as mlp
from sknn.mlp import Classifier
ip_layer = mlp.Layer('Sigmoid', units=1)
hidden_layer = mlp.Layer('Tanh', units=100)
op_layer = mlp.Layer('Sigmoid', units=5)

nn = Classifier(
[ip_layer, hidden_layer, op_layer],
n_iter=10000
)
nn.fit(X_train, y_train)

最佳答案

输入层有一个单元。

如果您设置ip_layer = mlp.Layer('Sigmoid',units=343)它应该可以工作。

关于python-3.x - 断言错误: Mismatch between dataset size and units in output layer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36966957/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com