Keras:ValueError:检查模型目标时出错:预期density_1具有形状(无,10),但数组的形状为(10,1) [英] Keras: ValueError: Error when checking model target: expected dense_1 to have shape (None, 10) but got array with shape (10, 1)

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

问题描述

我是keras的新手,我遇到此错误:ValueError:检查模型目标时出错:预期density_1具有形状(无,10),但数组的形状为(10,1).我输入的数组形状是(10,1010)

I'm new to keras and I'm facing this error: ValueError: Error when checking model target: expected dense_1 to have shape (None, 10) but got array with shape (10, 1). My input array shape is (10, 1010)

我的模型只有一层

model = Sequential()

model.add(Dense(10, batch_input_shape=(None, 1010),init='uniform', activation='relu'))

有什么办法解决这个问题吗?我尝试了很多组合,但对我却无济于事?

any ideas how can I fix this I tried many combinations nothing works for me?

推荐答案

一个提示是,该错误抱怨目标的尺寸.我怀疑目标是形状(10, 1),而(最终)层期望目标是(None, 10).模型需要目标与模型的最后一层具有相同的尺寸.毕竟,如果两者的维数不同,那么Keras还能如何进行各种比较,并最终给您一个准确性得分?

A clue is in the fact that the error is complaining about the dimension of the target. I suspect the target is shape (10, 1), whereas the (final) layer is expecting the target to be (None, 10). The model needs the target to be the same dimension as the last layer in the model. After all, if the two aren't the same dimension, how else would Keras be able to do any kinds of comparisons and ultimately give you an accuracy score?

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

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