suragnair/seqGAN
suragnair/seqGAN has 647 GitHub stars and 146 forks. GitHot measured 0 stars in 24 hours and 0 in 7 days. Last checked 2026-11-09 13:39 UTC. Last push 2018-09-27.
A simplified PyTorch implementation of "SeqGAN: Sequence Generative Adversarial Nets with Policy Gradient." (Yu, Lantao, et al.)
Measured star growth
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- Update delayed
- in 1 month
- Update delayed
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalseqGAN
A PyTorch implementation of "SeqGAN: Sequence Generative Adversarial Nets with Policy Gradient." (Yu, Lantao, et al.). The code is highly simplified, commented and (hopefully) straightforward to understand. The policy gradients implemented are also much simpler than in the original work (https://github.com/LantaoYu/SeqGAN/) and do not involve rollouts- a single reward is used for the entire sentence (inspired by the examples in http://karpathy.github.io/2016/05/31/rl/).
The architectures used are different than those in the orignal work. Specifically, a recurrent bidirectional GRU network is used as the discriminator.
The code performs the experiment on synthetic data as described in the paper.
You are encouraged to raise any doubts regarding the working of the code as Issues.
To run the code:
python main.py
main.py should be your entry point into the code.
Hacks and Observations
The following hacks (borrowed from https://github.com/soumith/ganhacks) seem to have worked in this case:
Training Discriminator a lot more than Generator (Generator is trained only for one batch of examples, and increasing the batch size hurts stability)
Using Adam for Generator and Adagrad for Discriminator
Tweaking learning rate for Generator in GAN phase
Using dropout in both training and testing phase
Stablity is extremely sensitive to almost every parameter :/
The GAN phase may not always lead to massive drops in NLL (sometimes very minimal) - I suspect this is due to the very crude nature of the policy gradients implemented (without rollouts).
Sample Learning Curve
Learning curve obtained after MLE training for 100 epochs followed by adversarial training. (Your results may vary!)

Explore related projects
tensorflow/tensorflow
An Open Source Machine Learning Framework for Everyone
201,427 starshuggingface/transformers
🤗 Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.
168,711 starsAUTOMATIC1111/stable-diffusion-webui
Stable Diffusion web UI
165,261 starsComfy-Org/ComfyUI
The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
145,835 stars