RuntimeError:tf.placeholder() 与急切执行不兼容

新手上路,请多包涵

我已经使用 tf_upgrade_v2 TF1 代码升级到 TF2。我是两者的菜鸟。我收到下一个错误:

 RuntimeError: tf.placeholder() is not compatible with eager execution.

我有一些 tf.compat.v1.placeholder()

 self.temperature = tf.compat.v1.placeholder_with_default(1., shape=())
self.edges_labels = tf.compat.v1.placeholder(dtype=tf.int64, shape=(None, vertexes, vertexes))
self.nodes_labels = tf.compat.v1.placeholder(dtype=tf.int64, shape=(None, vertexes))
self.embeddings = tf.compat.v1.placeholder(dtype=tf.float32, shape=(None, embedding_dim))

你能给我一些关于如何进行的建议吗?任何“快速”解决方案?还是我应该重新编码?

原文由 AMGMNPLK 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 798
1 个回答

我在这里找到了一个简单的解决方案: 禁用 Tensorflow eager execution

基本上是:

tf.compat.v1.disable_eager_execution()

这样一来,您就可以禁用默认的 activate eager execution,并且您不需要再接触代码了。

原文由 AMGMNPLK 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题