tensorflow1.4 轉 tensorflow2.0 代碼轉換中遇到的問題

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

發佈了328 篇原創文章 · 獲贊 115 · 訪問量 33萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章