一、大部分代码只需要由 tf. 转换成 tf.compat.v1.
二、tf.contrib.rnn.LSTMCell( ) 不能直接用上述方式转换,因为contrib模块被弃用了,解决办法如下:
from tensorflow.python.ops import rnn, rnn_cell
rnn_cell.LSTMCell( )
三、tf.placeholder( ) 转换成 tf.compat.v1.placeholder( ) 后还会报错:
RuntimeError: tf.placeholder() is not compatible with eager execution
解决办法:tf.compat.v1.disable_eager_execution()