粢醍. 2023-04-04 19:42 采纳率: 0%
浏览 28

tf.compat.v1.variable_scope 报错,如何解决?

问题: tf.compat.v1.variable_scope 报错 module 'tensorflow' has no attribute 'variable_scope'

毕设卡住了qwq
源代码是tensorflow1的,但是Google cola只能用2,把源代码“tf.variable_scope”改成“tf.compat.v1.variable_scope”还是报错

img

  • 写回答

2条回答 默认 最新

  • 玉堃 2023-04-05 19:12
    关注

    import tensorflow.compat.v1 as tf
    tf.disable_v2_behavior()
    需要屏蔽掉v2版本方法,不知道你添加了没。

    引用自tensorflow2报错AttributeError: module ‘tensorflow‘ has no attribute ‘variable_scope‘

    评论

报告相同问题?

问题事件

  • 创建了问题 4月4日