AttributeError:模块“tensorflow”没有属性“assign”
环境配置:
python3.7
tensorflow2.0
window 10
初始代码:
update_value = tf.assign(value, new_value)
执行错误:
与tf.assignTF 1.X 不同,tf.Variable.assing_sub它将急切地执行分配。
解决方法:
update_value =tf.compat.v1.assign(value, new_value)
使用介绍:
data= tf.Variable(20)
tf.compat.v1.assign(data,100)
意思是将100赋给data。