keras-coordconv icon indicating copy to clipboard operation
keras-coordconv copied to clipboard

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

Open rytisss opened this issue 4 years ago • 4 comments

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

rytisss avatar Jul 24 '20 09:07 rytisss

Same issue. Tensorflow version 1.15

LEChaney avatar Sep 03 '20 00:09 LEChaney

same issue

SerdarHelli avatar Apr 28 '21 09:04 SerdarHelli

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.

SergioLeonardoMendes avatar May 13 '21 21:05 SergioLeonardoMendes

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

PolarBean avatar Feb 23 '22 15:02 PolarBean