当前的tensorflow版本是
tf.__version__
Out[4]: '2.0.0-dev20190526'
运行之前可以运行的tensorflow代码,出现的问题
'module' object has no attribute
In [1]: import tensorflow as tf
In [2]: tf.reset_default_graph()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-c193d79f7d5a> in <module>()
----> 1 tf.reset_default_graph()
AttributeError: 'module' object has no attribute 'reset_default_graph'
In [3]: Y = tf.placeholder(tf.float32, [None, 6])
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-7051f9cffff8> in <module>()
----> 1 Y = tf.placeholder(tf.float32, [None, 6])
AttributeError: 'module' object has no attribute 'placeholder'
可以看下官方文档
https://www.tensorflow.org/beta/guide/migration_guide
Convert Your Existing Code to TensorFlow 2.0
这里先使用最简单的方法解决上面的问题
It is still possible to run 1.X code, unmodified (except for contrib), in TensorFlow 2.0:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
'module' object has no attribute 'contrib'
tf.contrib.rnn.MultiRNNCell(lstm_layers)
应该怎样调用到MultiRNNCell
cd到目录/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops
grep -nr BasicLSTMCell ./
/rnn_cell_impl.py:634:@tf_export(v1=["nn.rnn_cell.BasicLSTMCell"])
tf.nn.rnn_cell.BasicLSTMCell(N_HIDDEN_UNITS, forget_bias=1.0)
Out[130]: <tensorflow.python.ops.rnn_cell_impl.BasicLSTMCell at 0x7f5cf19a4f10>