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

2024-04-28 00:24:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在学习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。请帮我解释一下错误。提前感谢:)


Tags: 代码cominputhave错误train课程keras
1条回答
网友
1楼 · 发布于 2024-04-28 00:24:42

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

There is an empty feature in the dataset. I didn't drop it. Without dropping it, input_shape should be 34 as there are 34 features in the dataset. Now, by dropping the empty feature, everything is working fine.

相关问题 更多 >