本文介绍了运行时错误:tf.placeholder() 与急切执行不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已将 tf_upgrade_v2 TF1 代码升级到 TF2.我对两者都是菜鸟.我收到下一个错误:
I have upgraded with tf_upgrade_v2 TF1 code to TF2. I'm a noob with both. I got the next error:
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))
你能给我一些关于如何进行的建议吗?任何快速"解决方案?还是我应该重新编码?
Could you give me any advice about how to proceed? Any "fast" solutions? or should I to recode this?
推荐答案
我在这里找到了一个简单的解决方案:禁用 Tensorflow 急切执行
I found an easy solution here: disable Tensorflow eager execution
基本上是:
tf.compat.v1.disable_eager_execution()
使用此功能,您可以禁用默认的激活急切执行,并且您无需更多地接触代码.
With this, you disable the default activate eager execution and you don't need to touch the code much more.
这篇关于运行时错误:tf.placeholder() 与急切执行不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!