Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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. 

I have some 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?

like image 574
AMGMNPLK Avatar asked Jun 12 '19 11:06

AMGMNPLK


People also ask

What is placeholder in TensorFlow?

A placeholder is simply a variable that we will assign data to at a later date. It allows us to create our operations and build our computation graph, without needing the data. In TensorFlow terminology, we then feed data into the graph through these placeholders.

When eager execution is enabled?

With eager execution enabled, TensorFlow functions execute operations immediately (as opposed to adding to a graph to be executed later in a tf. compat. v1. Session ) and return concrete values (as opposed to symbolic references to a node in a computational graph).

What is eager execution?

Eager execution is a powerful execution environment that evaluates operations immediately. It does not build graphs, and the operations return actual values instead of computational graphs to run later. With Eager execution, TensorFlow calculates the values of tensors as they occur in your code.

What is TF compat v1 Disable_eager_execution ()?

compat. v1. disable_eager_execution() This function can only be called before any Graphs, Ops, or Tensors have been created. It can be used at the beginning of the program for complex migration projects from TensorFlow 1.


1 Answers

I found an easy solution here: disable Tensorflow eager execution

Basicaly it is:

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.

like image 138
AMGMNPLK Avatar answered Sep 21 '22 17:09

AMGMNPLK