ValueError :;检查输入时出错:期望flatten_input具有3维,但数组的形状为(940682,2)

时间:2020-08-09 11:20:55

标签: python tensorflow dotnetnuke

我正在用python训练DNN模型。 数据看起来像这样。 enter image description here

而且,我只是在训练像这样的模型;

model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10, activation='softmax')])

model.compile(optimizer='adam',
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])
model.fit(X_train, y_train, epochs=5)

但是错误会这样发生

检查输入时出错:预期flatten_input具有3维,但数组的形状为(940682,2)

我该如何解决这个问题?

这是X_train,y_train的形状。 enter image description here

0 个答案:

没有答案