使用训练神经网络模型tensorflow时,training模块训练多次报错,如:
1,Variable conv1/weights already exists, disallowed. Did you mean to set reuse=True in VarScope
2,Variable conv1/weights does not exist, or was not created with tf.get_variable
它们都属于自己定义的网络模型的参数问题,从前面开始conv1卷积层开始报告错误,因为这不是第一次训练模型,参数会发生冲突。此时,有必要告诉模型,它可以多次训练或理解为删除以前的一些参数
解决方案:这不是第一个训练模块training添加前(或每次训练后):
tf.reset_default_graph()
import tensorflow.compat.v1 as tf tf.disable_v2_behavior() import os import numpy as np import matplotlib.pyplot as plt tf.reset_default_graph()