ValueError:检查目标时出错:预期dense_2具有3维,但得到形状为(10000, 1)的数组 [英] ValueError: Error when checking target: expected dense_2 to have 3 dimensions, but got array with shape (10000, 1)
问题描述
我正在使用 keras MLP 网络对 3-D 词向量进行二元分类 input_shape=(None,24,73)
.我使用了两个密集层 dense_1
和 dense_2
.在 dense_2
处,我收到一个我无法解决的错误.
这是我的模型摘要.
层(类型)输出形状参数#==================================================================密集_1(密集)(无、8、90)6660_________________________________________________________________密集_2(密集)(无,8,1)91==================================================================总参数:6,751可训练参数:6,751不可训练的参数:0
<块引用>
ValueError: 检查目标时出错:预期密集_2 有 3维度,但得到了形状为 (22, 1) 的数组
既然你有一个 binary_classification 任务,你的最后一层应该看起来像这样
model.add(Dense(1, activation='sigmoid'))
现在您的模型正在放置与形状不匹配的 3D 阵列你的目标(二维)
I am using keras MLP network for binary classification of 3-D word vector input_shape=(None,24,73)
. I have used two dense layers dense_1
and dense_2
. At dense_2
I'm getting an error which I've not been able to solve.
This is my model summary.
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)
Since you have a binary_classification task your last layer should look something like this
model.add(Dense(1, activation='sigmoid'))
Right now you model is out puting 3D array which don't match the shape of your target (2D)
这篇关于ValueError:检查目标时出错:预期dense_2具有3维,但得到形状为(10000, 1)的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!