首页 > 解决方案 > ValueError:检查输入时出错:预期dense_3_input的形状为(33,)但得到的数组形状为(34,)

问题描述

我正在参加课程——来自 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,)

完整代码。请帮我解释错误。提前致谢 :)

标签: pythontensorflowkerasdeep-learning

解决方案


在答案部分写下答案,即使它出现在评论部分是为了社区的利益。

数据集中有一个空特征。我没有放下它。在不删除它的情况下,input_shape 应该是 34,因为数据集中有 34 个特征。现在,通过删除空功能,一切正常。


推荐阅读