在TensorFlow 2.0中获取变量作用域

3

我正在使用新版本的tensorflow (2.0.0 alpha),但我不知道为什么它不允许我运行:

tf.get_variable_scope().reuse_variables()

我遇到了以下错误:

AttributeError: module 'tensorflow' has no attribute 'get_variable_scope'

我猜可能有一个不同名称的新属性?谢谢!


1
不,variable_scopeget_variable已经从TensorFlow 2.x中删除(尽管您仍然可以在tf.compat.v1下找到它们)。请参阅RFC Variables in TensorFlow 2.0 - jdehesa
1个回答

1

来自评论

不,variable_scopeget_variable已经从TensorFlow 2.x中删除(尽管你仍然可以在tf.compat.v1中找到它们)。在TF 2.x中返回当前变量作用域,您可以使用tf.compat.v1.get_variable_scope代替get_variable_scope。有关更多详细信息,请参见从TF1迁移到TF2。(由jdehesa改写)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接