Wasserstein GAN (WGAN) Implementation

repository·master·Indexed 25 days ago

https://github.com/martinarjovsky/wassersteingan

Official implementation of the Wasserstein GAN (WGAN) paper using PyTorch. This repository provides a command-line interface via main.py to train models on datasets such as cifar10, lsun, imagenet, and lfw, supporting both DCGAN and MLP architectures with Adam or RMSprop optimizers.

Tokens
744
Snippets
2
Records
8
Agent score
35%

What's inside wassersteingan

  1. Note on LSUN dataloader initialization

    master
    The first time you run the code on the LSUN dataset, creating the dataloader can take up to an hour. A small cache file containing a list of indices in the LSUN LMDB database will be created. Subsequent runs will use this cache and complete in seconds.
  2. Troubleshoot sudden drops in learning curves

    master

    If your learning curve experiences a sudden, large drop, it indicates the critic is failing to stay close to optimum, causing its error to stop being a reliable Wasserstein estimate.

    Common causes and solutions:

    • High learning rates: Try reducing the learning rate.
    • High momentum: Try reducing momentum.
    • General fix: Implement any adjustments that help the critic return to an optimal state.
  3. Train Wasserstein GAN via CLI

    master

    The main.py script provides a command-line interface to train a Wasserstein GAN. It supports multiple datasets including cifar10, lsun, imagenet, folder, and lfw. You can configure model architectures (DCGAN or MLP), optimization algorithms (Adam or RMSprop), and various hyperparameters for both the Generator and Critic (Discriminator).

    Supported Datasets

    • cifar10: Uses torchvision.datasets.CIFAR10.
    • lsun: Uses torchvision.datasets.LSUN (specifically bedroom_train).
    • imagenet, folder, lfw: Uses torchvision.datasets.ImageFolder.

    Key Configuration Options

    • --dataset: Required. The dataset type.
    • --dataroot: Required. Path to the dataset directory.
    • --experiment: Directory where samples and model checkpoints (.pth) will be stored. Defaults to samples.
    • --cuda: Enables CUDA training.
    • --adam: Use Adam optimizer instead of the default RMSprop.
    • --mlp_G / --mlp_D: Use MLP architectures for the Generator or Discriminator respectively.
    • --noBN: Disable Batch Normalization (only applicable for DCGAN).
    • --Diters: Number of Discriminator iterations per Generator iteration (default: 5).