ValueError:检查目标时出错:预期density_2具有3维,但数组的形状为(10000,1) [英] ValueError: Error when checking target: expected dense_2 to have 3 dimensions, but got array with shape (10000, 1)

查看:71
本文介绍了ValueError:检查目标时出错:预期density_2具有3维,但数组的形状为(10000,1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用keras MLP网络对3-D字向量input_shape=(None,24,73)进行二进制分类.我使用了两个密集层dense_1dense_2.在dense_2处出现一个我无法解决的错误.

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.

这是我的模型摘要.

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:检查目标时出错:预期density_2具有3 尺寸,但数组的形状为(22,1)

ValueError: Error when checking target: expected dense_2 to have 3 dimensions, but got array with shape (22, 1)

推荐答案

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

Since you have a binary_classification task your last layer should look something like this

model.add(Dense(1, activation='sigmoid'))

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

Right now you model is out puting 3D array which don't match the shape of your target (2D)

这篇关于ValueError:检查目标时出错:预期density_2具有3维,但数组的形状为(10000,1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆