Skip to content Skip to sidebar Skip to footer

Valueerror: Variable Conv/w Already Exists, Disallowed

I was using TensorFlow and encountered an error. I want to use 'conv_W[0]' to initialize 'conv/W', they have the same shape of [3,3,192,32]. My code is as follows: def convolution

Solution 1:

That's probably happening because you initalize the variable on every epoch, so in other words the error means: Do you want to share this variable or you want to redeclare it? Since the desired behavior is unclear (create new variables or reuse the existing ones?) TensorFlow will fail. If you do want to share the variable you can just change the line:

conv_w = tf.get_variable('conv/W', initializer=tf.constant_initializer(conv_W[0]),reuse=True)

Otherwise set reuse=False, and that will solve your problem.

For more information about how to share/unshare variables see the Tensorflow documentation:

Post a Comment for "Valueerror: Variable Conv/w Already Exists, Disallowed"