一、大部分代碼只需要由 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()