tensorflow訓練神經網絡出現錯誤(一)

訓練神經網絡時出現錯誤:

1.出現下面錯誤

  "reuse=tf.AUTO_REUSE in VarScope?" % name)

ValueError: Variable bn_1/moving_mean/biased does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=tf.AUTO_REUSE in VarScope?

只需要給主程序前面加兩行代碼:

import tensorflow as tf
tf.reset_default_graph()

2.出現錯誤ImportError: cannot import name 'Softmax'/'Subtract'

是keras版本不對,想要用Subtract,keras版本得2.1.3以後纔行,但是在改keras版本得同時得注意tensorflow的版本。以下是他們對應的版本。

#卸載keras並安裝指定版本
pip uninstall keras#先卸載原先版本
pip install keras==2.2.4#a安裝自己需要的版本,如果出現拒絕訪問的問題,在install後面加--user


#卸載tensorflow並安裝對應版本
pip uninstall tensorflow
pip install --user tensorflow==1.12.0#從上圖中可以找出對應的版本

#查看版本
#python進去
>>>import keras
>>>print(keras.__version__)
>>> print(keras.__version__)
2.2.4
>>> import tensorflow
>>> print(tensorflow.__version__)
1.12.0

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章