I got a error when running a github project in tensorflow

992 views Asked by At

DCGAN

when I run the project , i got the error.

ValueError: Variable d_h0_conv/w/Adam/ does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope?

the part of code is below.

the optimizer:

d_optim = tf.train.AdamOptimizer(config.learning_rate, beta1=config.beta1) \
            .minimize(self.d_loss, var_list= self.d_vars)
        g_optim = tf.train.AdamOptimizer(config.learning_rate, beta1=config.beta1) \
            .minimize(self.g_loss, var_list= self.g_vars)

the variables:

self.d_vars = [var for var in t_vars if 'd_' in var.name]
        self.g_vars = [var for var in t_vars if 'g_' in var.name]

the operation:

def conv2d(input_, output_dim,
           k_h=5, k_w=5, d_h=2, d_w=2, stddev=0.02,
           name="conv2d"):
    with tf.variable_scope(name):
        w = tf.get_variable('w', [k_h, k_w, input_.get_shape()[-1], output_dim],
                            initializer=tf.truncated_normal_initializer(stddev=stddev))
        conv = tf.nn.conv2d(input_, w, strides=[1, d_h, d_w, 1], padding='SAME')

        biases = tf.get_variable('biases', [output_dim], initializer=tf.constant_initializer(0.0))
        conv = tf.reshape(tf.nn.bias_add(conv, biases), conv.get_shape())

        return conv

Environment:

ubuntu14.04 , python2.7 tensorflow 0.12

Thank you for help. I need help.

1

There are 1 answers

9
Rick Lentz On

I assume you were were running the command to train the network after pulling the data.

I was able to clone the project, pull the image data sets, and run the training command using Python 3.5 on Ubuntu w/Tensorflow 0.12. The commands are only slightly different

(e.g. python3 main.py --dataset mnist --is_train True vs python...)

I know this project support python 2.7 but you able to run the project using python3?