【问题标题】:Type ERROR when upgrading to tensorflow 2.9升级到 tensorflow 2.9 时输入 ERROR
【发布时间】:2023-01-16 17:06:47
【问题描述】:

升级到 tensorflow 2.9 后,我收到以下错误消息 调用 model.fit() 时 使用 tf 2.8 没有错误。 无论如何都适合,但令人担忧。

2022-06-21 12:42:58.930086: W tensorflow/core/common_runtime/forward_type_inference.cc:231] Type inference failed. This indicates an invalid graph that escaped type checking. Error message: INVALID_ARGUMENT: expected compatible input types, but input 1:
type_id: TFT_OPTIONAL
args {
  type_id: TFT_PRODUCT
  args {
    type_id: TFT_TENSOR
    args {
      type_id: TFT_BOOL
    }
  }
}
 is neither a subtype nor a supertype of the combined inputs preceding it:
type_id: TFT_OPTIONAL
args {
  type_id: TFT_PRODUCT
  args {
    type_id: TFT_TENSOR
    args {
      type_id: TFT_LEGACY_VARIANT
    }
  }
}

    while inferring type of node 'calculate/cond/output/_10'

知道什么会导致这个或如何解决它吗?

【问题讨论】:

  • 你可以发布你的问题代码吗?只是错误消息本身有点含糊。
  • 请分享一些最小的可重现代码以了解此错误。
  • 不幸的是,我真的无法提供更多信息,因为我收到了以下代码的消息:self.train_model.fit(train_generator.get(), epochs=self.epochs, validation_data=val_generator.get(), callbacks=self.callbacks)对于不同的模型架构,我得到了相同的消息,因此很难减少搜索空间
  • 我想我已经将范围缩小到 tf.train、tf.io 或 tf.data...我可能不得不重新编写用于保存 TFRecords 并再次加载它们的代码。希望它会更好,因为使用当前代码(在 2.2 上开发,升级到 2.4,现在试图升级到 2.9)需要一百万年才能保存任何东西。
  • 有没有人找出这个错误的原因?

标签: tensorflow keras types upgrade


【解决方案1】:

这应该是评论而不是答案,但我没有足够的声誉。我在此处 https://www.tensorflow.org/guide/migrate/evaluator 和此处 https://www.tensorflow.org/guide/migrate/migrating_feature_columns 的张量流指南的输出类型中看到了相同类型的错误消息。在点击链接后搜索“type inference failed”,您可以轻松找到出错的行。

【讨论】:

【解决方案2】:

在撰写本文时,这似乎仍然是一个悬而未决的问题。对于那些将来可能会阅读本文的人,请关注TensorFlowKeras repos 上发布的相关问题。尽管目前对...is just a warning, you can safely ignore it. Given code executed without any error message.之类的声明有一些反对意见,但一个可能按照 Keras 团队的建议忽略此警告:

I think this should be reproducible without involving any Keras logic, at which point the TF folks will definitely look at it. But anyway, as said before, this is just a warning, not something critical. You can ignore it.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多