Git Product home page Git Product logo

Error for running with TensorFlow: ValueError: Variable d_w1/Adam/ does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope? about generative-adversarial-networks HOT 5 CLOSED

jonbruner avatar jonbruner commented on June 10, 2024
Error for running with TensorFlow: ValueError: Variable d_w1/Adam/ does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope?

from generative-adversarial-networks.

Comments (5)

heathervica avatar heathervica commented on June 10, 2024 1

Its running perfectly :), thank you so much

from generative-adversarial-networks.

adeshpande3 avatar adeshpande3 commented on June 10, 2024

First, try restarting the kernel, and running the notebook again. A lot of times creating Tensorflow graphs in iPython notebooks can get a little messy.

If that doesn't fix it, this is most likely an issue with scope. I think that the new Tensorflow version deals with optimizers (other than GradientDescentOptimizer) a bit differently. I think adding this with tf.variable_scope(tf.get_variable_scope(), reuse=False): before the declaration of the Adam optimizer should fix the problem, but not completely sure if this is a long term solution. Have you come across this error @jonbruner

from generative-adversarial-networks.

jonbruner avatar jonbruner commented on June 10, 2024

Adit is correct; this is usually a scope issue. When the Adam optimizer is instantiated, it creates a bunch of additional TensorFlow operations, and if TF thinks it can only reuse existing operations it throws an error.

I did come across this error and added the with tf.variable_scope line, which seemed to fix it. I'll try running again shortly to see if I can reproduce the error.

from generative-adversarial-networks.

jonbruner avatar jonbruner commented on June 10, 2024

OK, I think I've fixed the problem in gan-script.py; TF v1.0 and v1.1 might handle variable scope in slightly different ways. The code previously worked in v1.0.1 but broke in v1.1.

In the revised script, variable scope is handled at a slightly higher level; reuse_variables() is false until after the optimizers are defined, at which point it's set to true for the rest of the script. The exception is the discriminator network, which is set up once with variable reuse off and a second time with variable reuse on.

@adeshpande3, would you mind running gan-script.py to make sure I didn't miss anything? I'll make the same changes to gan-script-fast.py now.

from generative-adversarial-networks.

jonbruner avatar jonbruner commented on June 10, 2024

I've now updated gan-script-fast.py along the same lines, and I've tested it and gan-script.py on both TF v1.0.1 and v1.1.0.

@heathervica, thanks for bringing this to our attention!

I'm going to go ahead and close this issue for now; @adeshpande3, let me know if you run into any problems when you run the files.

from generative-adversarial-networks.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.