Code Monkey home page Code Monkey logo

generative-adversarial-networks's Introduction

Introduction to generative adversarial networks

This repository contains code to accompany the O'Reilly tutorial on generative adversarial networks written by Jon Bruner and Adit Deshpande. See the original tutorial to run this code in a pre-built environment on O'Reilly's servers with cell-by-cell guidance, or run these files on your own machine.

There are three versions of our simple GAN model in this repository:

  • gan-notebook.ipynb is identical to the interactive tutorial, available here so that you can run it on your own machine.
  • gan-script.py is a straightforward Python script containing code drawn directly from the tutorial, to be run from the command line. Note that it doesn't print anything when it's executed, but it does send regular updates to TensorBoard so that you can track its progress.
  • gan-script-fast.py is a modest refactoring of gan-script.py that runs slightly faster because more of its computations are contained in the TensorFlow graph.

Requirements and installation

In order to run gan-script.py or gan-script-fast.py, you'll need TensorFlow version 1.0 or later and NumPy. In order to run gan-notebook.ipynb, you'll additionally need Jupyter and matplotlib.

If you've already got TensorFlow on your machine, then you've got NumPy and should be able to run the raw Python scripts.

Installing Anaconda Python and TensorFlow

The easiest way to install TensorFlow as well as NumPy, Jupyter, and matplotlib is to start with the Anaconda Python distribution.

  1. Follow the installation instructions for Anaconda Python. We recommend using Python 3.6.

  2. Follow the platform-specific TensorFlow installation instructions. Be sure to follow the "Installing with Anaconda" process, and create a Conda environment named tensorflow.

  3. If you aren't still inside your Conda TensorFlow environment, enter it by opening your terminal and typing

    source activate tensorflow
  4. Download and unzip this entire repository from GitHub, either interactively, or by entering

    git clone https://github.com/jonbruner/generative-adversarial-networks.git
  5. Use cd to navigate into the top directory of the repo on your machine

  6. Launch Jupyter by entering

    jupyter notebook

    and, using your browser, navigate to the URL shown in the terminal output (usually http://localhost:8888/)

generative-adversarial-networks's People

Contributors

jonbruner 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

generative-adversarial-networks's Issues

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?

Hello, please maybe could you help me? I had a running for running, I tried to figurate how to solve but I could not, I tried also with Python 2, 3.5, 3.6, And Tensorflow 1 and 1.1

The complete Error was:
heather@heather-ThinkPad-P50:~/Downloads/generative-adversarial-networks-master (2)$ python3 gan-script.py
Extracting MNIST_data/train-images-idx3-ubyte.gz
Extracting MNIST_data/train-labels-idx1-ubyte.gz
Extracting MNIST_data/t10k-images-idx3-ubyte.gz
Extracting MNIST_data/t10k-labels-idx1-ubyte.gz
Traceback (most recent call last):
File "gan-script.py", line 131, in
d_trainer_fake = tf.train.AdamOptimizer(0.0003).minimize(d_loss_fake, var_list=d_vars)
File "/home/heather/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/optimizer.py", line 325, in minimize
name=name)
File "/home/heather/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/optimizer.py", line 446, in apply_gradients
self._create_slots([_get_variable_for(v) for v in var_list])
File "/home/heather/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/adam.py", line 122, in _create_slots
self._zeros_slot(v, "m", self._name)
File "/home/heather/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/optimizer.py", line 766, in _zeros_slot
named_slots[_var_key(var)] = slot_creator.create_zeros_slot(var, op_name)
File "/home/heather/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/slot_creator.py", line 174, in create_zeros_slot
colocate_with_primary=colocate_with_primary)
File "/home/heather/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/slot_creator.py", line 146, in create_slot_with_initializer
dtype)
File "/home/heather/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/slot_creator.py", line 66, in _create_slot_var
validate_shape=validate_shape)
File "/home/heather/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 1049, in get_variable
use_resource=use_resource, custom_getter=custom_getter)
File "/home/heather/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 948, in get_variable
use_resource=use_resource, custom_getter=custom_getter)
File "/home/heather/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 356, in get_variable
validate_shape=validate_shape, use_resource=use_resource)
File "/home/heather/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 341, in _true_getter
use_resource=use_resource)
File "/home/heather/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 671, in _get_single_variable
"VarScope?" % name)
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?

Not able to load pre-trained model

Error Tensor name "g_b1/beta" not found in checkpoint files pretrained-model/pretrained_gan.ckpt when loading pre-trained model, can anyone help?

Python 3.5 TensorFlow 1.2 variable scope related error

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

at line 128: d_trainer_fake = tf.train.AdamOptimizer(0.0003).minimize(d_loss_fake, var_list=d_vars)

Variable d_w1/Adam_3/ does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=tf.AUTO_REUSE in VarScope?

error
ValueError: Variable d_w1/Adam_3/ does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=tf.AUTO_REUSE in VarScope?
trial 1

d_trainer_fake = tf.train.AdamOptimizer(0.0003).minimize(d_loss_fake, var_list=d_vars)
d_trainer_real = tf.train.AdamOptimizer(0.0003).minimize(d_loss_real, var_list=d_vars)

# Train the generator
g_trainer = tf.train.AdamOptimizer(0.0001).minimize(g_loss, var_list=g_vars)

trial 2

with tf.variable_scope(tf.get_variable_scope()):
    d_trainer_real = tf.train.AdamOptimizer(0.0003).minimize(d_loss_real, var_list=d_vars)

    d_trainer_fake = tf.train.AdamOptimizer(0.0003).minimize(d_loss_fake, var_list=d_vars)
    g_trainer = tf.train.AdamOptimizer(0.0001).minimize(g_loss, var_list=g_vars)

Python 3.5.2
tf.version = '1.11.0'

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.