I am trying to run a code, which was written with tensorflow version 1.4.0 I am running my code on google colab which gives in tensorflow version 2.x with it.
To run my code, I am using backward compatibility like: replacing import tensorflow as tf
with
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
which works for certain things, but at a point it comes down to this error
AttributeError: module 'tensorflow.compat.v2' has no attribute 'depth_to_space'
What I am not able to understand is this method 'depth_to_space' is in both versions of tensorflow 1.x and 2.x, then why is my version of tensorflow not getting it? Here's the link to the method in version 1.x: https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/nn/depth_to_space
Please help me understand what's the cause of this error.
Thanks, Pranay
I tried with Tensorflow 1.15 .Its working fine. Looks like your Tensorflow version bit old,
Below sample code tested with Tf 1.15 without any error.
import tensorflow as tf
print(tf.__version__)
x = [[[[1, 2, 3, 4]]]]
tf.nn.depth_to_space(x, 2, data_format='NHWC', name=None)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.