Git Product home page Git Product logo

dcgan-keras's Introduction

DCGAN-Keras

The CORRECT and PERFORMANT way to implement GAN in Keras.

This is the Tensorflow version, here's another guy who wrote the theano version: https://github.com/bstriner/keras-adversarial

In short

  1. create your D and G network as usual in Keras

  2. call gan_feed = gan(G,D)

  3. feed your data manually:

    # sample from cifar
    j = i % int(length/batch_size)
    minibatch = shuffled_cifar[j*batch_size:(j+1)*batch_size]
    z_input = np.random.normal(loc=0.,scale=1.,size=(batch_size,zed))
    
    # train for one step
    losses = gan_feed(sess,minibatch,z_input)

How this happened

DCGAN have been implemented in a lot of frameworks. However, existing Keras and Tensorflow implementations are SLOW due to duplicated computation.

Basically we want to do two things in one forward-backward pass:

  1. update Wd w.r.t. D_loss
  2. update Wg w.r.t. G_loss

This kind of update(different parameters w.r.t. different loss) however is not possible in Keras.

but possible in Torch - check soumith/dcgan.

So the dumb solution was to create two model, one updates Wd after its forward-backward pass, another updates Wg after its forward-backward pass. All those DCGAN on GitHub are almost all implemented this way.

I wrote a detailed description to the problem: https://ctmakro.github.io/site/on_learning/fast_gan_in_keras.html

It works

License

someone suggest I put a license here.

PUBLIC DOMAIN

USE THIS CODE HOWEVER WHATEVER WHEREVER WHENEVER.

dcgan-keras's People

Contributors

ctmakro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dcgan-keras's Issues

How to use with 64x64 images?

I'm using this with another dataset, and I want to run on a larger (64x64) resolution, but it's hard to figure out what I have to change in the code, can you give me a hint of what to change? Thanks.

Missing license

Thanks for posting this code. Any chance you could also post a license?

Images seem to be dimmed with grey

Is it some dcgan problem or just an architectural mistake? Net seems to return images not in [-1; 1], lower bound is lifted up in -0.6, -0.5 or so. So normalization like in this code makes greyed images. I tried to calculate min value and use it, but this makes images look a bit weird and have unrealistic colors sometimes. Any ideas?

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.