我正在使用 keras MLP 网络对 3-D 词向量进行二进制分类 input_shape=(None,24,73)
。我使用了两个密集层 dense_1
和 dense_2
。在 dense_2
,我遇到了一个我无法解决的错误。
这是我的模型摘要。
Layer (type) Output Shape Param #
=================================================================
dense_1 (Dense) (None, 8, 90) 6660
_________________________________________________________________
dense_2 (Dense) (None, 8, 1) 91
=================================================================
Total params: 6,751
Trainable params: 6,751
Non-trainable params: 0
ValueError: Error when checking target: expected dense_2 to have 3 dimensions, but got array with shape (22, 1)
最佳答案
因为你有一个 binary_classification 任务,你的最后一层应该看起来像这样
model.add(Dense(1, activation='sigmoid'))
现在您的模型正在输出与形状不匹配的 3D 阵列 你的目标(2D)
关于python - ValueError : Error when checking target: expected dense_2 to have 3 dimensions, 但得到形状为 (10000, 1) 的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49623436/