tensorflow版本更新的问题归纳

tensorflow在前段时间更新了2.0.0版本,本人兴高采烈的更新了最新的版本,不料这一下子像是炸开了的河堤,不忍直视,然后本人就开始了新的探索(踩坑)之旅,简直爽到不要,言归正传:

1.module ‘tensorflow’ has no attribute ‘placeholder’

这一类问题就是由于tensorflow版本更新引发的,在此前版本的代码中,习惯tf.placeholder()的写法,在更新了tensorflow2.0后,由于版本的原因导致报错诸如此类报错科采用如下方案:

tf.placeholder()
报错---->module 'tensorflow' has no attribute 'placeholder'
修改===>tf.compat.v1.placeholder()

2.module ‘tensorflow’ has no attribute ‘ensorflow.examples.tutorials’

import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
报错--->module 'tensorflow' has no attribute 'ensorflow.examples.tutorials'
修改===>import tensorflow.compat.v1 as tf
	from tensorflow.examples.tutorials.mnist import input_data
    tf.disable_v2_behavior()

3.AttributeError: ‘module’ object has no attribute ‘pack’

报错--->AttributeError: 'module' object has no attribute 'pack'
修改===>pack替换为stack

4.AttributeError: ‘module’ object has no attribute ‘rnn_cell’

报错--->AttributeError: 'module' object has no attribute 'rnn_cell'
修改===>tf.nn.rnn_cell替换为tf.contrib.rnn

持续更新中。。。。

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值