close

目前Tensorflow版本已經更新到2.0.0,

但許多應用與原先Tensorflow v1的版本呼叫方式有所不同,

造成不同的Error發生,

這邊將記錄遇到各種AttributeError時的修改方式,

將不定期新增錯誤修正方式

 

錯誤1_(app) :

AttributeError: module 'tensorflow' has no attribute 'app'

新版已將舊版的app修改為compat.v1用法

舊版tensorflow用法:

ex_1: tf.app.flags.FLAGS

ex_2: tf.app.run()

修改為

ex_1: tf.compat.v1.flags.FLAGS

ex_2: tf.compat.v1.app.run()

 

錯誤2_(gfile):

AttributeError: module 'tensorflow' has no attribute 'gfile'

新版已將舊版的tf.gfile.*修改為tf.io.gfile.*用法

舊版tensorflow用法:

ex_1: tf.gfile.GFile()

修改為

ex_1: tf.io.gfile.GFile()

 

錯誤3_(logging):

AttributeError: module 'tensorflow' has no attribute 'logging'

新版已將舊版的tf.logging.*修改為tf.compat.v1.logging.*用法

舊版tensorflow用法:

ex_1: tf.logging.set_verbosity(tf.logging.INFO)

修改為:

ex_1: tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.INFO)

arrow
arrow

    楓綺 發表在 痞客邦 留言(0) 人氣()