ValueError:检查输入时出错:期望dense_6_input有3个维度,但得到的形状为

时间:2017-08-14 19:48:36

标签: python keras

我从Keras收到此错误:

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

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

这是我的代码:

    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的形状为(55,72)

我如何解决这个问题以及什么是dense_6_input?

1 个答案:

答案 0 :(得分:0)

问题在于:

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

不要将input_shape设置为输入值数组的形状,因为input_shape不包含样本维度。你想要的应该是:

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

然后你应该可以毫无问题地打电话给你。