module tensorflow has no attribute Session

AttributeError: module ‘tensorflow’ has no attribute ‘Session’ AttributeError: module ‘tensorflow’ has no attribute ‘InteractiveSession’
AttributeError: module ‘tensorflow’ has no attribute 'assign’

我下载的是tensorflow2.0,但在网上找到的学习资源都是2.0以下的
所以总会碰见tensorflow里没有对应的模块等错误

领悟到一点就是去兼容低版本
解决办法如下:

sess = tf.compat.v1.Session()
update = tf.compat.v1.assign(state, new_value)
init_op = tf.compat.v1.initialize_all_variables()

就相应地加上**.compat.v1.**

如果有其他的解决办法,也请大家告知。
或者有其他学习资源的也请告知。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值