Tensorflow Error筆記1
願天堂沒有Tensorflow! 阿門。
ValueError: Variable conv1/weights already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at:
將一個模型訓練好,並且儲存了checkpoint後,我嘗試呼叫儲存的模型:
![3352522-bc8c134ec4ed9584.png](https://i.iter01.com/images/7ece549880b2bb92cbaf7b9cd343d3c1dc58c14519ebc2274ced716392d4dbdc.png)
**儲存的模型檔案**
with tf.Session() as sess:
print("Reading checkpoints...")
ckpt = tf.train.get_checkpoint_state(logs_train_dir)
if ckpt and ckpt.model_checkpoint_path:
global_step = ckpt.model_checkpoint_path.split('/')[-1].split('-')[-1]
saver.restore(sess, ckpt.model_checkpoint_path)
print('Loading success, global_step is %s' % global_step)
else:
print('No checkpoint file found')
這是Tensorflow官網給出的模型呼叫方法,可是卻出現了下面的錯誤:
ValueError: Variable conv1/weights already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at:
原因是我們在一次測試過程中,測試了多張圖片,導致我們模型的引數需要重複使用,所以我們需要告訴TF‘允許複用引數’,所以只要在上面的程式碼加上
tf.get_variable_scope().reuse_variables()
Error就會消失。
with tf.Session() as sess:
tf.get_variable_scope().reuse_variables()
print("Reading checkpoints...")
ckpt = tf.train.get_checkpoint_state(logs_train_dir)
if ckpt and ckpt.model_checkpoint_path:
global_step = ckpt.model_checkpoint_path.split('/')[-1].split('-')[-1]
saver.restore(sess, ckpt.model_checkpoint_path)
print('Loading success, global_step is %s' % global_step)
else:
print('No checkpoint file found')
![3352522-d720aca39e1e667f.png](https://i.iter01.com/images/6e505dd1f5e0b7bf6d4b0f35124ec5d3eafcfa58fdb0d68b22f978ef53dfb906.png)
**Error消失**
相關文章
- TensorFlow筆記(1)——TensorFlow中的相關基本概念筆記
- TensorFlow 學習筆記筆記
- tensorflow學習筆記1——mac開發環境配置筆記Mac開發環境
- TensorFlow學習筆記(二)筆記
- tensorflow學習筆記3筆記
- tensorflow學習筆記——DenseNet筆記SENet
- TensorFlow Java API 學習筆記JavaAPI筆記
- Tensorflow學習筆記No.7筆記
- Tensorflow學習筆記No.8筆記
- Tensorflow學習筆記No.10筆記
- Tensorflow學習筆記No.11筆記
- TensorFlow筆記-01-開篇概述筆記
- tensorflow學習筆記--embedding_lookup()用法筆記
- 5.3 使用tensorflow搭建GoogLeNet網路 筆記Go筆記
- 筆記1筆記
- 《Golang學習筆記》error最佳實踐Golang筆記Error
- jvm筆記1JVM筆記
- Java筆記1Java筆記
- Day 1 筆記筆記
- tensorflow教程1
- Tensorflow學習筆記: 變數及共享變數筆記變數
- 學習筆記1筆記
- 陣列筆記1陣列筆記
- 閱讀筆記1筆記
- 學習筆記-1筆記
- TensorFlow筆記-02-Windows下搭建TensorFlow環境(win版非虛擬機器)筆記Windows虛擬機
- 《Spelling Error Correction with Soft-Masked BERT》閱讀筆記Error筆記
- TensorFlow筆記-03-張量,計算圖,會話筆記會話
- AI學習筆記——Tensorflow中的Optimizer(優化器)AI筆記優化
- TensorFlow筆記(2) 常量與變數【僅供自學】筆記變數
- 人工智慧實踐:Tensorflow2.0 新手筆記(2)人工智慧筆記
- python學習筆記(1Python筆記
- Vue學習筆記1Vue筆記
- noip刷題筆記1筆記
- HTTP快取筆記(1)HTTP快取筆記
- swift學習筆記《1》Swift筆記
- django專案筆記1Django筆記
- HTML學習筆記1HTML筆記
- python基礎筆記1Python筆記