Downloads · 30 days
0
RGarrido03/mnist-conditional-gan
mnist-conditional-gan is a machine learning model from RGarrido03. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Class-conditional synthesis of 28×28 grayscale MNIST-style digits. The generator maps noise z and digit label y to an image; the discriminator uses a projection discriminator (Miyato & Koyama, ICLR 2018) with spectral…
Downloads · 30 days
0
Access
Public
Updated Mar 25, 2026
Repo size
42.5 MB
Likes
0
Public
Click a slice to open those files.
.pth42.5 MB · 100%
From the Hugging Face model README
Class-conditional synthesis of 28×28 grayscale MNIST-style digits. The generator maps noise z and digit label y to an image; the discriminator uses a projection discriminator (Miyato & Koyama, ICLR 2018) with spectral normalization.
| File | Description |
|---|---|
mnist_cgan_generator.pth | Generator state_dict for inference (matches submission_digit_cgan.py). |
training_<source>.pt | Original checkpoint file (full training state when applicable). |
cgan_architecture.py | Copy of digit_cgan/model.py (Generator + Discriminator definitions). |
generator_config.json | Inferred constructor kwargs and metadata. |
Checkpoint: generator-only export (epoch not in file).
Inferred architecture (from tensors):
latent_dim=100, embed_dim=100,
base_channels=384, num_classes=10(B, 1, 28, 28), values in [-1, 1] (tanh).Source file: mnist_cgan_generator.pth.
import torch
from huggingface_hub import hf_hub_download
import sys
sys.path.insert(0, "/path/to/week-06")
from digit_cgan.model import Generator
repo_id = "<YOUR_REPO_ID>"
weights = hf_hub_download(repo_id, "mnist_cgan_generator.pth")
G = Generator(
latent_dim=100,
embed_dim=100,
base_channels=384,
num_classes=10,
)
G.load_state_dict(torch.load(weights, map_location="cpu", weights_only=True))
G.eval()
with torch.no_grad():
z = torch.randn(4, 100)
y = torch.tensor([0, 1, 2, 3])
fake = G(z, y)
cgan_architecture.py)See T. Miyato & M. Koyama, cGANs with Projection Discriminator, ICLR 2018.
python -m digit_cgan.train — hinge loss, Adam, optional EMA on the
generator for sampling; best FID checkpoints use the EMA weights in
best_generator.pth.
CLI defaults in train.py include latent_dim=100, embed_dim=100;
base_channels_g / base_channels_d / feature_dim may differ per run —
always use generator_config.json or infer from weights as above.
MNIST is a simple benchmark; generalization to out-of-distribution digit styles is not guaranteed.