ValueError:检查目标时出错:预期density_2具有3维,但数组的形状为(10000,1)

Ash*_*rud 4 python neural-network keras

我正在使用keras MLP网络对3-D字向量进行二进制分类input_shape=(None,24,73)。我已经使用了两个密集层dense_1dense_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
Run Code Online (Sandbox Code Playgroud)

ValueError:检查目标时出错:预期density_2具有3维,但数组的形状为(22,1)

ors*_*ady 5

由于您执行了binary_classification任务,因此最后一层应如下所示

model.add(Dense(1, activation='sigmoid'))
Run Code Online (Sandbox Code Playgroud)

现在,您的模型已经放出与目标形状(2D)不匹配的3D阵列