今天在升級tensorflow 後,運行相關腳本 ,有兩個報錯
一個是報如下
報AttributeError: module 'tensorflow' has no attribute 'decode_raw'
網上度娘沒查到, 用tf的升級工具試了下
tf_upgrade_v2 --infile Train.py --outfile Train-new.py
可以看到 tf.decode_raw 改爲 tf.io.decode_raw
另一個是
AttributeError: module 'tensorflow' has no attribute 'placeholder'
查看tf 2下 沒有 placeholder ,搜索框中先搜了下 placeholder
發現 如下內容 於是替換下即可,第一個問題其實也可以通過先在tf中搜索找到答案
tf.compat.v1.placeholder