简体   繁体   English

ValueError:检查输入时出错:预期density_6_input具有3维,但数组的形状

[英]ValueError: Error when checking input: expected dense_6_input to have 3 dimensions, but got array with shape

I'm receiving this error from Keras: 我从Keras收到此错误:

ValueError: Error when checking input: expected dense_6_input to have 3 dimensions,      but got array with shape (55, 72)

on

model.fit(X.values, Y.values, nb_epoch=1000, batch_size=16,verbose=0)

This is my code: 这是我的代码:

    from keras.models import Sequential
    from keras.layers import Dense, Activation

model = Sequential([
    Dense(32, input_shape=X.values.shape),
    Activation('relu'),
    Dense(10),
    Activation('softmax'),
])
model.compile(loss='mse', optimizer='rmsprop')
model.fit(X.values, Y.values, nb_epoch=1000, batch_size=16,verbose=0)

X has a shape of (55, 72) X的形状为(55,72)

How can I fix this and what is dense_6_input? 我该如何解决?什么是density_6_input?

The problem is here: 问题在这里:

Dense(32, input_shape=X.values.shape)

Don't set the input_shape to just the shape of the input values array, as the input_shape does not contain the samples dimension. 不要将input_shape设置为仅输入值数组的形状,因为input_shape不包含样本尺寸。 What you want should be: 您想要的应该是:

Dense(32, input_shape=(72,)),

Then you should be able to call fit without issues. 然后,您应该可以毫无问题地进行健身。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ValueError:检查输入时出错:预期density_11_input具有3维,但数组的形状为(0,1) - ValueError: Error when checking input: expected dense_11_input to have 3 dimensions, but got array with shape (0, 1) ValueError:检查输入时出错:预期dense_input有2维,但得到形状为(1,1,2)的数组 - ValueError: Error when checking input: expected dense_input to have 2 dimensions, but got array with shape (1, 1, 2) ValueError:检查输入时出错:预期density_151_input具有3维,但数组的形状为(2,2100) - ValueError: Error when checking input: expected dense_151_input to have 3 dimensions, but got array with shape (2, 2100) ValueError:检查输入时出错:预期的dense_input有2维,但得到的数组形状为(1、1、15) - ValueError: Error when checking input: expected dense_input to have 2 dimensions, but got array with shape (1, 1, 15) ValueError:检查时出错:预期density_1_input具有2维,但数组的形状为(1,16,16,512) - ValueError: Error when checking : expected dense_1_input to have 2 dimensions, but got array with shape (1, 16, 16, 512) 我不断收到此错误“ValueError:检查输入时出错:预期的dense_8_input有2维,但得到的数组形状为(705,66,1)” - I keep getting this error “ValueError: Error when checking input: expected dense_8_input to have 2 dimensions, but got array with shape (705, 66, 1)” ValueError:检查输入时出错:预期density_16_input具有2维,但数组的形状为(60000,28,28) - ValueError: Error when checking input: expected dense_16_input to have 2 dimensions, but got array with shape (60000, 28, 28) ValueError:检查输入时出错:预期density_1_input具有2维,但数组的形状为(60000,28,28) - ValueError: Error when checking input: expected dense_1_input to have 2 dimensions, but got array with shape (60000, 28, 28) ValueError:检查输入时出错:预期dense_10_input有2维,但得到的数组形状为(60000、28、28) - ValueError: Error when checking input: expected dense_10_input to have 2 dimensions, but got array with shape (60000, 28, 28) ValueError:检查输入时出错:预期dense_1_input具有形状(180,)但得到形状为(1,)的数组 - ValueError: Error when checking input: expected dense_1_input to have shape (180,) but got array with shape (1,)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM