studiogan_contragan
A conditional GAN whose discriminator also pulls same-class image embeddings together with a contrastive loss.
Diffusion and generative · 211 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
At a glance
- Parameters
- 9.4M
- Operations
- 211
- Framework
- PyTorch
- Recurrent
- No
- Published
- NeurIPS 2020
- Cited by
- 114 (as of 17 October 2026)
- Authors
- Minguk Kang, Jaesik Park
- License
- MIT
- Checked
- Passed: the trace was replayed operation by operation and matched the model's own output for this input.
Files
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
Details
- Stable ID
- m10289
- Graph hash
- 58d6b6f93ed7fe567e50e7f066c3ffda5515b4b7bde4bedc7c2606f618c98fc9
- Skeleton hash
- a85e85c13fe2039dc67bcebe83b3e09938d51583f2ad94354bc37bcdcbf05885
- Architecture hash
- 7ee4528ce538956c992fdb406b081a8285e912f57d7bd72839226821a6a29db1
- Diagram SHA-256
- bf0ca458d75632726848234e081135d7a4f36473fd1449a4a4fc2790c9033250
- TorchLens version
- 2.36.0
- Renderer
- graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
- Check
- Forward pass replayed in PyTorch
What it is
ContraGAN is a conditional GAN, a model that generates diverse images using class label information, with a different idea of what the class label should do. Earlier conditional GANs consider pairwise relations between the embedding of an image and the embedding of the corresponding label, the data-to-class relations, as the conditioning losses. ContraGAN considers relations between multiple image embeddings in the same batch, the data-to-data relations, as well as the data-to-class relations, by using a conditional contrastive loss, which the paper calls the 2C loss.
In practice the discriminator does two jobs at once. It discriminates the authenticity of given samples and minimizes a contrastive objective to learn the relations between training images, pulling the multiple image embeddings closer to each other when the class labels are the same, but pushing them far away otherwise. Simultaneously, the generator tries to generate realistic images that deceive the authenticity and have a low contrastive loss. The authors present this as extending ACGAN and ProjGAN with the 2C loss, and they show experimentally that contrastive learning helps to relieve the overfitting of the discriminator.
The captured rows come from the authors' PyTorch-StudioGAN library, where ContraGAN is listed with a BigGAN backbone, conditional batch normalization in the generator, the 2C conditioning and the hinge loss; one row is the discriminator alone. The paper reports that ContraGAN outperforms state-of-the-art models by 7.3% and 7.7% on Tiny ImageNet and ImageNet in terms of Frechet Inception Distance, and that it reduces FID significantly without hard negative and positive mining.
Key idea. The conditional contrastive (2C) loss lets a GAN discriminator learn data-to-data relations between images in a batch alongside data-to-class relations, improving conditional generation and relieving discriminator overfitting.
- contragan
- contrastive gan
- contrastive learning for conditional image generation
- conditional contrastive loss
- 2c loss
- conditional image generation
- studiogan
- gan
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@misc{kang2021contragancontrastivelearningconditional,
title={ContraGAN: Contrastive Learning for Conditional Image Generation},
author={Minguk Kang and Jaesik Park},
year={2021},
eprint={2006.12681},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2006.12681},
}