【榆钱】# 错误实践

文章主要介绍了三个在使用TensorFlow时遇到的AttributeError问题,分别是Session、ConfigProto和set_random_seed。这些问题由TensorFlow版本升级引起。解决方案包括使用tf.compat.v1模块,调用disable_v2_behavior()来禁用TF2.x行为,或者回退到1.15以下版本进行安装。
摘要由CSDN通过智能技术生成

1.问题:AttributeError: module 'tensorflow' has no attribute 'Session'

   解决:将 tf.Session()

              改为 tf.compat.v1.Session()

2.问题:AttributeError: module 'tensorflow' has no attribute 'configProto'

   解决:将 tf.ConfigProto()

              改为 tf.compat.v1.ConfigProto()

3.问题:AttributeError: module 'tensorflow' has no attribute 'tf.set_random_seed'

   解决:将 tf.set_random_seed() 

              改为 tf.random.set_seed()

以上错误均由于版本问题,还可以在引TensorFlow包的时候

import tensorflow as tf

改为

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

最后,如果实在还不行,只能重装一下TensorFlow了,装1.15以下的版本 (悲泣)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值