【问题标题】:ValueError: Error when checking input: expected dense_3_input to have shape (33,) but got array with shape (34,)ValueError:检查输入时出错:预期dense_3_input的形状为(33,)但得到的数组形状为(34,)
【发布时间】:2021-02-07 23:51:02
【问题描述】:

我正在学习课程——来自 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。请帮我解释错误。在此先感谢:)

【问题讨论】:

  • 请附上型号的代码。
  • 你的 X_train、y_train、X_valid 和 y_valid 的大小是多少?
  • 我看了你提到的链接。看起来数据集确实有 34 个特征,并且输出是二进制的。所以也许他们犯了一个错误,input_shape 应该等于34
  • 现在可以使用了。数据集中有一个空特征。我没有放下它。在不删除它的情况下,input_shape 应该是 34,因为数据集中有 34 个特征。现在,通过删除空功能,一切正常。谢谢。

标签: python tensorflow keras deep-learning


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2020-04-01
    • 2020-09-04
    • 2020-04-11
    • 2020-05-17
    • 2020-11-22
    • 1970-01-01
    • 1970-01-01
    • 2020-05-29
    • 1970-01-01
    相关资源
    最近更新 更多