[英]AttributeError: module 'tensorflow.compat.v2' has no attribute 'logging'
[英]AttributeError: module 'tensorflow.compat.v2' has no attribute 'depth_to_space'
我正在嘗試運行一個代碼,它是用 tensorflow 版本 1.4.0 編寫的我在 google colab 上運行我的代碼,它給出了 tensorflow 版本 2.x。
為了運行我的代碼,我使用了向后兼容性,例如:將import tensorflow as tf
替換為
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
它適用於某些事情,但在某種程度上它歸結為這個錯誤
AttributeError:模塊“tensorflow.compat.v2”沒有屬性“depth_to_space”
我無法理解的是這個方法 'depth_to_space' 在 tensorflow 1.x 和 2.x 的兩個版本中都有,那么為什么我的 tensorflow 版本沒有得到它? 這是 1.x 版方法的鏈接: https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/nn/depth_to_space
請幫助我了解此錯誤的原因。
謝謝,普拉奈
我試過Tensorflow 1.15 。它工作正常。 看起來你的 Tensorflow 版本有點舊,
下面的示例代碼使用 Tf 1.15 測試沒有任何錯誤。
import tensorflow as tf
print(tf.__version__)
x = [[[[1, 2, 3, 4]]]]
tf.nn.depth_to_space(x, 2, data_format='NHWC', name=None)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.