DCGAN-Tensorflow | Tensorflow implementation of Deep Convolutional | Machine Learning library
kandi X-RAY | DCGAN-Tensorflow Summary
kandi X-RAY | DCGAN-Tensorflow Summary
A Tensorflow implementation of Deep Convolutional Generative Adversarial Networks trained on Fashion-MNIST, CIFAR-10, etc.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Build the graph
- A 2D convolution layer
- Lrelu
- 2d convolution layer
- Runs the evaluation
- Dump prediction results to a file
- Add a batch prediction
- Logs a step message
- Train the model
- Runs a single step
- Log a step message
- Download CIFAR10 10
- Prepare h5py data
- Create the default dataset
- Returns a list of all ids
- Download Fashion MNIST
- Download MNIST dataset
- Download SVHN
- Runs the test
DCGAN-Tensorflow Key Features
DCGAN-Tensorflow Examples and Code Snippets
Community Discussions
Trending Discussions on DCGAN-Tensorflow
QUESTION
I am reading people's implementation of DCGAN, especially this one in tensorflow.
In that implementation, the author draws the losses of the discriminator and of the generator, which is shown below (images come from https://github.com/carpedm20/DCGAN-tensorflow):
Both the losses of the discriminator and of the generator don't seem to follow any pattern. Unlike general neural networks, whose loss decreases along with the increase of training iteration. How to interpret the loss when training GANs?
...ANSWER
Answered 2017-Nov-09 at 12:37Unfortunately, like you've said for GANs the losses are very non-intuitive. Mostly it happens down to the fact that generator and discriminator are competing against each other, hence improvement on the one means the higher loss on the other, until this other learns better on the received loss, which screws up its competitor, etc.
Now one thing that should happen often enough (depending on your data and initialisation) is that both discriminator and generator losses are converging to some permanent numbers, like this: (it's ok for loss to bounce around a bit - it's just the evidence of the model trying to improve itself)
This loss convergence would normally signify that the GAN model found some optimum, where it can't improve more, which also should mean that it has learned well enough. (Also note, that the numbers themselves usually aren't very informative.)
Here are a few side notes, that I hope would be of help:
- if loss haven't converged very well, it doesn't necessarily mean that the model hasn't learned anything - check the generated examples, sometimes they come out good enough. Alternatively, can try changing learning rate and other parameters.
- if the model converged well, still check the generated examples - sometimes the generator finds one/few examples that discriminator can't distinguish from the genuine data. The trouble is it always gives out these few, not creating anything new, this is called mode collapse. Usually introducing some diversity to your data helps.
- as vanilla GANs are rather unstable, I'd suggest to use some version of the DCGAN models, as they contain some features like convolutional layers and batch normalisation, that are supposed to help with the stability of the convergence. (the picture above is a result of the DCGAN rather than vanilla GAN)
- This is some common sense but still: like with most neural net structures tweaking the model, i.e. changing its parameters or/and architecture to fit your certain needs/data can improve the model or screw it.
QUESTION
There is a lot of code when subset of a neural network layers is reused. I always used the following code, which can be found, for example, here:
...ANSWER
Answered 2019-May-10 at 22:10Answering myself. According to the answer they do share the same weights, but the tensors on the graph are separate:
QUESTION
I am trying to use this version of the DCGAN code (implemented in Tensorflow) with some of my data. I run into the problem of the discriminator becoming too strong way too quickly for generator to learn anything.
Now there are some tricks typically recommended for that problem with GANs:
batch normalisation (already there in DCGANs code)
giving a head start to generator.
I did some version of the latter by allowing 10 iterations of generator per 1 of discriminator (not just in the beginning, but throughout the entire training), and that's how it looks:
Adding more generator iterations in this case helps only by slowing down the inevitable - discriminator growing too strong and suppressing the generator learning.
Hence I would like to ask for an advice on whether there is another way that could help the problem of a too strong discriminator?
...ANSWER
Answered 2017-Jun-16 at 13:26To summarise this topic - the generic advice would be:
- try playing with model parameters (like learning rates, for instance)
- try adding more variety to the input data
- try adjusting the architecture of both generator and discriminator networks.
However, in my case the issue was the data scaling: I've changed the format of the input data from the initial .jpg to .npy and lost the rescaling on the way. Please note that this DCGAN-tensorflow code rescales the input data to [-1,1] range, and the model is tuned to work with this range.
QUESTION
I would like to add another term to the generator loss function in DCGAN-tensorflow model.py (code lines 127-133). Like this:
...ANSWER
Answered 2017-Sep-21 at 13:45It appears Tensorflow has most of the necessary operations that are available in numpy, so here is the tf version of my numpy code above:
QUESTION
I am trying to adjust this DCGAN code to be able to work with 2x80 data samples.
All generator layers are tf.nn.deconv2d
other than h0, which is ReLu. Generator filter sizes per level are currently:
ANSWER
Answered 2017-Jun-09 at 05:25In your ops.py file
your problem come from the striding size in your deconv filter, modify the header for conv2d
and deconv2d
to:
QUESTION
I am trying to augment DC-GANS code so that it works with my data. The original code has its data as JPEG, however I would really strongly prefer to have my data in .npy.
The problem is line 76: self.data = glob(os.path.join("./data", self.dataset_name, self.input_fname_pattern))
won't work with numpy data (it comes back blank, i.e. []
).
Hence I am wondering what's a good replacement for glob(os.path.join())
for numpy files? Or are there any parameters that would make glob compatible with the numpy data?
ANSWER
Answered 2017-May-28 at 19:12In DCGAN.__init__
, change input_fname_pattern='*.jpg'
to input_fname_pattern='*.npy'
:
QUESTION
Running the DCGANS-tensorflow tutorial, more precisely lines python download.py mnist celebA
and python main.py --dataset celebA --input_height=108 --train --crop
, I get the following error:
ANSWER
Answered 2017-May-22 at 16:00I realised what was the problem with this - just needed an updated version of the Tensorflow (had 0.9.0 versus required 0.12.1), and pip install tensorflow --upgrade
solved my problem.
QUESTION
I'm using open source Tensorflow implementations of research papers, for example DCGAN-tensorflow. Most of the libraries I'm using are configured to train the model locally, but I want to use Google Cloud ML to train the model since I don't have a GPU on my laptop. I'm finding it difficult to change the code to support GCS buckets. At the moment, I'm saving my logs and models to /tmp and then running a 'gsutil' command to copy the directory to gs://my-bucket at the end of training (example here). If I try saving the model directly to gs://my-bucket it never shows up.
As for training data, one of the tensorflow samples copies data from GCS to /tmp for training (example here), but this only works when the dataset is small. I want to use celebA, and it is too large to copy to /tmp every run. Is there any documentation or guides for how to go about updating code that trains locally to use Google Cloud ML?
The implementations are running various versions of Tensorflow, mainly .11 and .12
...ANSWER
Answered 2017-Mar-16 at 03:23There is currently no definitive guide. The basic idea would be to replace all occurrences of native Python file operations with equivalents in the file_io
module, most notably:
open()
->file_io.FileIO()
os.path.exists()
->file_io.file_exists()
glob.glob()
->file_io.get_matching_files()
These functions will work locally and on GCS (as well as any registered file system). Note, however, that there are some slight differences in file_io
and the standard file operations (e.g., a different set of 'modes' are supported).
Fortunately, checkpoint and summary writing do work out of the box, just be sure to pass a GCS path to tf.train.Saver.save
and tf.summary.FileWriter
.
In the sample you sent, that looks potentially painful. Consider monkey patching the Python functions to map to the TensorFlow equivalents when the program starts to only have to do it once (demonstrated here).
As a side note, all of the samples on this page show reading files from GCS.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install DCGAN-Tensorflow
You can use DCGAN-Tensorflow like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page