MNIST Conditional GAN (cGAN) Generator
Conditional GAN trained on MNIST to generate handwritten digits 0-9.
Architecture
- Type: Conditional DCGAN Generator
- Input: noise vector (100,) + integer label (0-9)
- Output: grayscale image (1, 28, 28), Tanh activation [-1, 1]
- Parameters: ~1.9M
- Conditioning: label embedding (10-dim) concatenated with noise
Training
- Dataset: MNIST (60,000 images)
- Epochs: 50
- Optimizer: Adam (lr=0.0002, betas=(0.5, 0.999))
- Loss: BCELoss with label smoothing (0.9)
- G steps per D step: 2
Usage
from cgan_model import Generator
import torch
G = Generator()
G.load_state_dict(torch.load("mnist_cgan_generator.pth", map_location="cpu"))
G.eval()
z = torch.randn(1, 100)
label = torch.tensor([7])
with torch.no_grad():
img = G(z, label) # (1, 1, 28, 28) in [-1, 1]
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support