Variable conv1/weights already exists, disallowed. Did you mean to set reuse=True...tensorflow报错

在训练神经网络模型使用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()

你可能感兴趣的:(Tensorflow,python,tensorflow,深度学习)