titu1994 / keras-coordconv

Keras implementation of CoordConv for all Convolution layers
MIT License
148 stars 33 forks source link

Tensorflow 2.2 gives error: TypeError: An op outside of the function building code is being passed a "Graph" tensor. #18

Open rytisss opened 3 years ago

rytisss commented 3 years ago

Hi, I added CoordConv layers to UNet model and it gives following error right before model training: TypeError: An op outside of the function building code is being passed a "Graph" tensor. It is possible to have Graph tensors leak out of the function building context by including a tf.init_scope in your function building code. For example, the following function will fail: @tf.function def has_init_scope(): my_constant = tf.constant(1.) with tf.init_scope(): added = my_constant * 2 The graph tensor has name: model/coordinate_channel2d/stack:0

LEChaney commented 3 years ago

Same issue. Tensorflow version 1.15

SerdarHelli commented 3 years ago

same issue

SergioLeonardoMendes commented 3 years ago

I had the same issue in Tensorflow 2.4. I solved by replacing the calls to function "K.ones" for "tf.ones" in the source code. It was also necessary to add a line to import tensorflow: "import tensorflow as tf". I hope this can help.

PolarBean commented 2 years ago

switching to tf.ones did not solve the issue for me on Tensorflow 2.4.1 however downgrading to 2.2 solved it.