我正在移植一些代码使用
tf.contrib.framework
到Tensorflow 2.0。特别地,
tf_upgrade_v2
报道
错误:使用成员tf.contrib.框架。获取已弃用模块中的\u name_作用域tf.contrib公司. tf.contrib.框架.get_name_作用域无法自动转换。tf.contrib公司将不会与TensorFlow 2.0一起分发,请考虑在non-contrib TensorFlow(一个社区维护的存储库,如TensorFlow/addons)中选择一个替代方案,或者派生所需的代码。
很公平,看看
Sunsetting tf.contrib
说
所以在寻找
get_name_scope
在文档中找不到TF2.0版本,但我找到了一个
in
tensorflow/python/framework/ops.py
评论中的这个例子:
with tf.name_scope('scope1'):
with tf.name_scope('scope2'):
print(tf.get_name_scope())
tf.get_name_scope()
给了我
AttributeError: module 'tensorflow' has no attribute 'get_name_scope'
我可以在其他模块下访问它吗?我试过了
tf.framework.ops
使用的另一个成员是
tf.contrib.framework.model_variable()