python - 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,)
完整代码。请帮我解释错误。提前致谢 :)
解决方案
在答案部分写下答案,即使它出现在评论部分是为了社区的利益。
数据集中有一个空特征。我没有放下它。在不删除它的情况下,input_shape 应该是 34,因为数据集中有 34 个特征。现在,通过删除空功能,一切正常。
推荐阅读
- python - 我收到 PermissionError: [Errno 13] Permission denied: when move a file using shutil.move 有没有办法忽略这个错误?
- android - 使用 android gradle 插件 3.6+ 执行 crashlyticsGenerateSymbols 任务时出错
- python - 我无法使用 Python 从 JSON 响应中正确访问字典列表
- blazor - 动态附加 Blazor 组件
- vue.js - ckeditor4-vue 与 Nuxt.js 如何访问 CKEDITOR
- python - 使用 Python 对 mongodb 进行日期查询返回空
- apache-kafka - 无法在 Mac 上运行 Kafka
- android-studio - AndroidStudio:如何复制视图和自动创建唯一 ID?
- shareandcharge - 公共测试环境的凭证握手错误
- excel - 在 VBA 中输入公式数组的问题