ValueError:检查输入时出错:预期density_3_input具有形状(33,)但具有形状(34,)的数组

时间:2020-10-25 14:42:35

标签: python tensorflow keras deep-learning

我正在上这门课程-来自Kaggle.com的深度学习入门。当我运行代码

early_stopping = keras.callbacks.EarlyStopping(
patience=10,
min_delta=0.001,
restore_best_weights=True,
)

history = model.fit(
    X_train, y_train,
    validation_data=(X_valid, y_valid),
    batch_size=512,
    epochs=1000,
    callbacks=[early_stopping],
    verbose=0, # hide the output because we have so many epochs
)

我收到此错误。

Error when checking input: expected dense_3_input to have shape (33,) but got array with shape (34,)

full code。请帮助我解释该错误。在此先感谢:)

1 个答案:

答案 0 :(得分:0)

即使在评论部分中出现了答案,也要在答案部分中写出答案,以使社区受益。

数据集中有一个空白特征。我没丢不删除它,input_shape应该为34,因为数据集中有34个要素。现在,通过删除空白功能,一切正常。