← Open Source
shayneobrien

generative-models

Annotated, understandable, and visually interpretable PyTorch implementations of: VAE, BIRVAE, NSGAN, MMGAN, WGAN, WGANGP, LSGAN, DRAGAN, BEGAN, RaGAN, InfoGAN, fGAN, FisherGAN.

TutorialsML/AI fundamentalsJupyter Notebook
Open on GitHub
Momentum
+0stars in 24 hours0.0%
504
Stars
72
Forks
+1
This week
2
Contributors
Created 2018-04-17 · Updated 2026-10-11 · #18244 today
Top developers
shayneobrienmattgroh

shayneobrien/generative-models is ranked 18,244 with 504 stars.

Same-category comparison

shayneobrien/generative-models is ranked 18,244 among these 8 peers; wellflat/imageprocessing-labs is ranked 18,247.

Same-category comparison
NameRankMetrics
gau-nernst/learn-cuda18,207
Language:
Cuda
Stars:
505
Forks:
67
Description:
Learn CUDA with PyTorch.
SmartFlowAI/Llama3-Tutorial18,226
Language:
Python
Stars:
504
Forks:
53
Description:
Llama3-Tutorial(XTuner、LMDeploy、OpenCompass).
hemingkx/ChineseNMT18,236
Language:
Python
Stars:
504
Forks:
90
Description:
ChineseNMT: Translate English to Chinese with PyTorch Implementation of Transformer.
jiahe7ay/MINI_LLM18,239
Language:
Python
Stars:
504
Forks:
73
Description:
This is a repository used by individuals to experiment and reproduce the pre-training process of LLM.
wellflat/imageprocessing-labs18,247
Language:
JavaScript
Stars:
504
Forks:
87
Description:
computer vision, image processing and machine learning on the web browser or node.
BBuf/how-to-learn-deep-learning-framework18,249
Stars:
503
Forks:
30
Description:
how to learn PyTorch and OneFlow.
JdeRobot/RoboticsAcademy18,251
Language:
Python
Stars:
503
Forks:
372
Description:
Learn Robotics with JdeRobot.
googlecodelabs/tensorflow-for-poets-218,259
Language:
Python
Stars:
503
Forks:
449
Key parameters and specifications
Key parameters and specifications
ParameterValue
LanguageJupyter Notebook
CategoryTutorials
SubcategoryML/AI fundamentals
KeywordsDiffusion
Stars504
Forks72
Contributors2
Created date2018-04-17
Updated date2026-10-11
Stars in 1 day0
Stars in 7 days1
Rank18,244
Previous rank17,995
Rank change-249
7-day stars rank11,609
Previous 7-day stars rank11,657
7-day stars rank change48
Total stars rank19,261
Previous total stars rank19,233
Total stars rank change-28
CountryUSA
README summary

5 Annotated implementations with comparative introductions for minimax, non-saturating, wasserstein, wasserstein gradient penalty, least squares, deep regret analytic, bounded equilibrium, relativistic, f-divergence, Fisher, and information generative adversarial networks (GANs), and standard, variational, and bounded information rate variational autoencoders (VAEs). Paper links are supplied at the beginning of each file with a short summary of the paper. See src folder for files to run via terminal, or notebooks folder for Jupyter notebook visualizations via your local browser. The main

file changes can be see in the , , and of the Trainer class, although changes are not completely limited to only these two areas (e. Wasserstein GAN clamps weight in the train function, BEGAN gives multiple outputs from train_D, fGAN has a slight modification in viz_loss function to indicate method used in title). All code in this repository operates in a generative, unsupervised manner on binary (black and white) MNIST. The architectures are compatible with a variety of datatypes

(1D, 2D, square 3D images). Plotting functions work with binary/RGB images. If a GPU is detected, the models use it. VAE Trainer classes contain methods to visualize latent space representations (see function). Usage To initialize an environment: For playing around in Jupyer notebooks: To run from Terminal: New Models One of the primary purposes of this repository is to make implementing deep generative model (i. , GAN/VAE) variants as easy as possible. This is possible because, typically but not

always (e. BIRVAE), the proposed modifications only apply to the way loss is computed for backpropagation. Thus, the core training class is structured in such a way that most new implementations should only require edits to the and functions of GAN Trainer classes, and the function of VAE Trainer classes. Suppose we have a non-saturating GAN and we wanted to implement a least-squares GAN. To do this, all we have to do is change two lines: Original (NSGAN

) New (LSGAN) Model Architecture The architecture chosen in these implementations for both the generator (G) and discriminator (D) consists of a simple, two-layer feedforward network. While this will give sensible output for MNIST, in practice it is recommended to use deep convolutional architectures (i. This can be done by editing the Generator and Discriminator classes for GANs, or the Encoder and Decoder classes for VAEs. Visualization All models were trained for 25 epochs with hidden dimension 400, latent dimension

20. Other implementation specifics are as close to the respective original paper (linked) as possible.

Frequently asked questions

How many stars and forks are recorded?

shayneobrien/generative-models has 504 stars and 72 forks.

What is the repository rank?

shayneobrien/generative-models is ranked 18,244.

What language and category are recorded?

shayneobrien/generative-models has 504 stars, uses Jupyter Notebook and belongs to Tutorials.

Which repository is closest in rank?

shayneobrien/generative-models is compared with wellflat/imageprocessing-labs, ranked 18,247 with 504 stars.

README

Overview

PyTorch 0.4.1 | Python 3.6.5

Annotated implementations with comparative introductions for minimax, non-saturating, wasserstein, wasserstein gradient penalty, least squares, deep regret analytic, bounded equilibrium, relativistic, f-divergence, Fisher, and information generative adversarial networks (GANs), and standard, variational, and bounded information rate variational autoencoders (VAEs).

Paper links are supplied at the beginning of each file with a short summary of the paper. See src folder for files to run via terminal, or notebooks folder for Jupyter notebook visualizations via your local browser. The main file changes can be see in the train, train_D, and train_G of the Trainer class, although changes are not completely limited to only these two areas (e.g. Wasserstein GAN clamps weight in the train function, BEGAN gives multiple outputs from train_D, fGAN has a slight modification in viz_loss function to indicate method used in title).

All code in this repository operates in a generative, unsupervised manner on binary (black and white) MNIST. The architectures are compatible with a variety of datatypes (1D, 2D, square 3D images). Plotting functions work with binary/RGB images. If a GPU is detected, the models use it. Otherwise, they default to CPU. VAE Trainer classes contain methods to visualize latent space representations (see make_all function).

Usage

To initialize an environment:

python -m venv env  
. env/bin/activate  
pip install -r requirements.txt  

For playing around in Jupyer notebooks:

jupyter notebook

To run from Terminal:

cd src
python bir_vae.py

New Models

One of the primary purposes of this repository is to make implementing deep generative model (i.e., GAN/VAE) variants as easy as possible. This is possible because, typically but not always (e.g. BIRVAE), the proposed modifications only apply to the way loss is computed for backpropagation. Thus, the core training class is structured in such a way that most new implementations should only require edits to the train_D and train_G functions of GAN Trainer classes, and the compute_batch function of VAE Trainer classes.

Suppose we have a non-saturating GAN and we wanted to implement a least-squares GAN. To do this, all we have to do is change two lines:

Original (NSGAN)

def train_D(self, images):
  ...
  D_loss = -torch.mean(torch.log(DX_score + 1e-8) + torch.log(1 - DG_score + 1e-8))

  return D_loss
def train_G(self, images):
  ...
  G_loss = -torch.mean(torch.log(DG_score + 1e-8))

  return G_loss

New (LSGAN)

def train_D(self, images):
  ...
  D_loss = (0.50 * torch.mean((DX_score - 1.)**2)) + (0.50 * torch.mean((DG_score - 0.)**2))

  return D_loss
def train_G(self, images):
  ...
  G_loss = 0.50 * torch.mean((DG_score - 1.)**2)

  return G_loss

Model Architecture

The architecture chosen in these implementations for both the generator (G) and discriminator (D) consists of a simple, two-layer feedforward network. While this will give sensible output for MNIST, in practice it is recommended to use deep convolutional architectures (i.e. DCGANs) to get nicer outputs. This can be done by editing the Generator and Discriminator classes for GANs, or the Encoder and Decoder classes for VAEs.

Visualization

All models were trained for 25 epochs with hidden dimension 400, latent dimension 20. Other implementation specifics are as close to the respective original paper (linked) as possible.

Model Epoch 1 Epoch 25 Progress Loss
MMGAN
NSGAN
WGAN
WGPGAN
DRAGAN
BEGAN
LSGAN
RaNSGAN
FisherGAN
InfoGAN
f-TVGAN
f-PearsonGAN
f-JSGAN
f-ForwGAN
f-RevGAN
f-HellingerGAN
VAE
BIRVAE

To Do

Models: CVAE, denoising VAE, adversarial autoencoder | Bayesian GAN, Self-attention GAN, Primal-Dual Wasserstein GAN
Architectures: Add DCGAN option
Datasets: Beyond MNIST

Nearby in the ranking
Similar items