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
持续更新中。。。。