Code Monkey home page Code Monkey logo

Comments (6)

RanaivosonHerimanitra avatar RanaivosonHerimanitra commented on July 18, 2024 6

Restart and run kernel using the following inplace of cell number 4 of the original notebook:

sess = tf.Session() 
batch_size = 50 
z_dimensions = 100 
x_placeholder = tf.placeholder("float", shape = [None,28,28,1], name='x_placeholder') 
Gz = generator(batch_size, z_dimensions) 
Dx = discriminator(x_placeholder) 
with tf.variable_scope(tf.get_variable_scope()) as scope:
    pass 
Dg = discriminator(Gz, reuse=True)
g_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(logits=Dg, labels=tf.ones_like(Dg))) 
d_loss_real = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(logits=Dx, labels=tf.fill([batch_size, 1], 0.9))) 
d_loss_fake = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(logits=Dg, labels=tf.zeros_like(Dg))) 
d_loss = d_loss_real + d_loss_fake 
tvars = tf.trainable_variables() 
d_vars = [var for var in tvars if  'd_' in var.name] 
g_vars = [var for var in tvars if not 'g_' in var.name] 

with tf.variable_scope(scope):    
    d_trainer_fake = tf.train.AdamOptimizer(0.0001).minimize(d_loss_fake, var_list=d_vars) 
    d_trainer_real = tf.train.AdamOptimizer(0.0001).minimize(d_loss_real, var_list=d_vars) 
    g_trainer = tf.train.AdamOptimizer(0.0001).minimize(g_loss, var_list=g_vars)
    

from generative_adversarial_networks_live.

fulkast avatar fulkast commented on July 18, 2024 3

I made some necessary namescope fixes to run the code on my machine where I use Tensorflow 1.2.
I've submitted a PR which is here: #3

from generative_adversarial_networks_live.

chuong98 avatar chuong98 commented on July 18, 2024 1

The fix from RanaivosonHerimanitra lets the code run, but does not yield correct result.
Change this line from his code should correct it (remove not ):

g_vars = [var for var in tvars if 'g_' in var.name]

If you also want the code run continuously, change the plt.plot part to:

            plt.imshow(im.reshape([28, 28]), cmap='Greys')
            plt.show(block=False)
            plt.pause(2)
            plt.close()

from generative_adversarial_networks_live.

 avatar commented on July 18, 2024

does anybody know how to solve this problem? unless this piece of code is useless

from generative_adversarial_networks_live.

pudepiedj avatar pudepiedj commented on July 18, 2024

The fix from RanaivosonHerimanitra solves the problem. Thank you.

from generative_adversarial_networks_live.

7LFB avatar 7LFB commented on July 18, 2024

with tf.variable_scope(scope,reuse=tf.AUTO_REUSE):
optimizer_step=tf.train.AdamOptimizer(0.0001).minimized(loss, var)

from generative_adversarial_networks_live.

Related Issues (10)

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.