SeqGAN without the rollouts: a readable PyTorch port
A stripped-down reimplementation that trades the original's Monte Carlo rollouts for policy-gradient simplicity, then sweats the stability details so you don't have to.

What it does
This is a teaching-friendly PyTorch rewrite of the 2017 SeqGAN paper, which trains a generator to produce realistic sequences (here, synthetic text) via adversarial training with policy gradients. The discriminator is a bidirectional GRU instead of the paper’s original architecture. The code runs a single command (python main.py) and reproduces the paper’s synthetic data experiment.
The interesting bit
The author deliberately threw out the original’s Monte Carlo rollout mechanism—used to estimate rewards for partially generated sequences—and replaced it with a single reward for the entire sentence, borrowing from Karpathy’s RL examples. This makes the policy gradients “much simpler,” though the README admits this crudeness likely explains why the GAN phase sometimes barely moves the needle on negative log-likelihood.
Key highlights
- ~650 stars; explicitly pitched as “highly simplified, commented and (hopefully) straightforward to understand”
- Discriminator architecture swapped to recurrent bidirectional GRU (not in original paper)
- Borrowed practical tricks from Soumith Chintala’s ganhacks: discriminator trained far more than generator, Adam vs. Adagrad split, dropout in both train and test phases
- Single-file entry point (
main.py) with synthetic data experiment ready to run
Caveats
- Stability is “extremely sensitive to almost every parameter”
- GAN phase may produce “very minimal” NLL improvement; author suspects the crude policy gradients are the culprit
- Explicitly not a faithful reproduction: architectures differ, rollouts omitted
Verdict
Grab this if you’re trying to understand SeqGAN’s core loop without drowning in research-code complexity, or if you want a hackable baseline for sequence GANs. Skip it if you need the original paper’s exact numbers or a production-ready text generator.