Jacob Garcia · Hugging Face Model Foundry

Pocket Wgan Lab

Interactive conditional adversarial digit generator. This showcase backs up the trained artifacts, measured evaluation, and complete runnable source.

Explore every file View the full foundry

Verified project card

# Pocket WGAN-GP

Pocket WGAN-GP is a compact class-conditional adversarial image generator for the
8x8 handwritten-digits benchmark. It combines a projection critic, Wasserstein
training with gradient penalty, and an auxiliary class objective. The interactive
Space exposes class, noise seed, and latent temperature.

## Why this experiment exists

GANs can report strong-looking averages while collapsing to one prototype. This
project therefore treats class fidelity, within-class variance, quantized sample
uniqueness, nearest-training-example distance, and exact-copy rate as first-class
evaluation outputs. A frozen 2,198-parameter classifier trained in Tiny Vision
Foundry supplies the label-fidelity measurement.

## Verified local result

The 31,712-parameter generator reached 97.0% class fidelity across 1,000 held-out
generations. Its mean within-class pixel variance was 98.24% of the real training
data baseline. Every quantized sample was unique, the exact training-copy rate was
zero, and mean nearest-training-image MSE was 0.03026. The critic contains 17,931
parameters and received 7,200 updates.

## Reproduce

```bash
uv run python projects/pocket-wgan/train.py
uv run pytest tests/test_pocket_wgan.py
```

The published bundle contains the generator and critic in SafeTensors format,
the complete evaluation report, a 100-sample contact sheet, and 1,000 generated
evaluation samples. Reported numbers are local measurements, not claims about a
currently deployed Hub Space.

Evaluation snapshot

{
  "model": "Pocket WGAN-GP",
  "method": "Projection-conditioned WGAN-GP with auxiliary class supervision",
  "generator_parameters": 31712,
  "critic_parameters": 17931,
  "training_examples": 1257,
  "generator_steps": 2400,
  "critic_updates": 7200,
  "best_generator_step": 2400,
  "generation": {
    "judge_accuracy": 0.9700000286102295,
    "judge_accuracy_by_class": {
      "0": 0.9900000095367432,
      "1": 0.949999988079071,
      "2": 0.9900000095367432,
      "3": 0.9700000286102295,
      "4": 0.9599999785423279,
      "5": 0.9700000286102295,
      "6": 0.9900000095367432,
      "7": 1.0,
      "8": 0.9599999785423279,
      "9": 0.9200000166893005
    },
    "mean_pixel_variance_by_class": {
      "0": 0.0305124931037426,
      "1": 0.04492313414812088,
      "2": 0.03864439204335213,
      "3": 0.04265550151467323,
      "4": 0.0401928536593914,
      "5": 0.04807004705071449,
      "6": 0.032149579375982285,
      "7": 0.04377623647451401,
      "8": 0.04335470125079155,
      "9": 0.04571780934929848
    },
    "real_mean_pixel_variance_by_class": {
      "0": 0.025008603930473328,
      "1": 0.05708667263388634,
      "2": 0.04482439160346985,
      "3": 0.03898561745882034,
      "4": 0.04554782807826996,
      "5": 0.04596441984176636,
      "6": 0.03248969465494156,
      "7": 0.046020835638046265,
      "8": 0.044565171003341675,
      "9": 0.044857367873191833
    },
    "diversity_ratio_by_class": {
      "0": 1.2200798248703002,
      "1": 0.7869285785182504,
      "2": 0.8621286460553024,
      "3": 1.0941343063176903,
      "4": 0.8824318382497515,
      "5": 1.0458099376908663,
      "6": 0.9895315950927983,
      "7": 0.9512264579203641,
      "8": 0.9728382114261526,
      "9": 1.0191817201254216
    },
    "mean_diversity_ratio": 0.9824291116266899,
    "samples": 1000,
    "collapse_and_memorization_checks": {
      "mean_nearest_training_mse": 0.030259807055350394,
      "median_nearest_training_mse": 0.02845568861812353,
      "exact_training_copy_fraction": 0.0,
      "quantized_unique_fraction_by_class": {
        "0": 1.0,
        "1": 1.0,
        "2": 1.0,
        "3": 1.0,
        "4": 1.0,
        "5": 1.0,
        "6": 1.0,
        "7": 1.0,
        "8": 1.0,
        "9": 1.0
      },
      "mean_quantized_unique_fraction": 1.0
    }
  },
  "judge": "Frozen Tiny Vision student, 98.52% real-image test accuracy",
  "training_history": [
    {
      "generator_step": 1,
      "generator_loss": 1.832496166229248,
      "critic_loss": 7.296276569366455,
      "gradient_penalty": 0.6319434642791748,
      "judge_fidelity": 0.08749999850988388,
      "mean_diversity_ratio": 0.09041444920003414,
      "selection_score": 0.101062165889889
    },
    {
      "generator_step": 200,
      "generator_loss": 2.1555261611938477,
      "critic_loss": -0.743652880191803,
      "gradient_penalty": 0.00692558940500021,
      "judge_fidelity": 0.24250000715255737,
      "mean_diversity_ratio": 0.03933937028050423,
      "selection_score": 0.24840091269463302
    },
    {
      "generator_step": 400,
      "generator_loss": 1.0727102756500244,
      "critic_loss": -0.5879160165786743,
      "gradient_penalty": 0.005078175105154514,
      "judge_fidelity": 1.0,
      "mean_diversity_ratio": 0.03597373897209764,
      "selection_score": 1.0053960608458146
    },
    {
      "generator_step": 600,
      "generator_loss": 1.01450514793396,
      "critic_loss": -0.5324597358703613,
      "gradient_penalty": 0.006901979446411133,
      "judge_fidelity": 0.9950000047683716,
      "mean_diversity_ratio": 0.10493496991693974,
      "selection_score": 1.0107402502559126
    },
    {
      "generator_step": 800,
      "generator_loss": 1.043497920036316,
      "critic_loss": -0.49861836433410645,
      "gradient_penalty": 0.008488744497299194,
      "judge_fidelity": 0.9775000214576721,
      "mean_diversity_ratio": 0.3373389258980751,
      "selection_score": 1.0281008603423833
    },
    {
      "generator_step": 1000,
      "generator_loss": 0.9358897805213928,
      "critic_loss": -0.4203786253929138,
      "gradient_penalty": 0.009127671830356121,
      "judge_fidelity": 0.9725000262260437,
      "mean_diversity_ratio": 0.43268701434135437,
      "selection_score": 1.0374030783772468
    },
    {
      "generator_step": 1200,
      "generator_loss": 1.0532721281051636,
      "critic_loss": -0.30880528688430786,
      "gradient_penalty": 0.006839464418590069,
      "judge_fidelity": 0.9725000262260437,
      "mean_diversity_ratio": 0.58423230946064,
      "selection_score": 1.0601348726451396
    },
    {
      "generator_step": 1400,
      "generator_loss": 1.1917768716812134,
      "critic_loss": -0.25530850887298584,
      "gradient_penalty": 0.0061252727173268795,
      "judge_fidelity": 0.9674999713897705,
      "mean_diversity_ratio": 0.6854087769985199,
      "selection_score": 1.0703112879395484
    },
    {
      "generator_step": 1600,
      "generator_loss": 1.0977249145507812,
      "critic_loss": -0.2501622140407562,
      "gradient_penalty": 0.0051786331459879875,
      "judge_fidelity": 0.9524999856948853,
      "mean_diversity_ratio": 0.7668859779834747,
      "selection_score": 1.0675328823924064
    },
    {
      "generator_step": 1800,
      "generator_loss": 1.106730580329895,
      "critic_loss": -0.24072407186031342,
      "gradient_penalty": 0.0037523529026657343,
      "judge_fidelity": 0.9649999737739563,
      "mean_diversity_ratio": 0.8528995037078857,
      "selection_score": 1.092934899330139
    },
    {
      "generator_step": 2000,
      "generator_loss": 1.3110945224761963,
      "critic_loss": -0.1876629739999771,
      "gradient_penalty": 0.004364368040114641,
      "judge_fidelity": 0.9549999833106995,
      "mean_diversity_ratio": 0.9044061362743377,
      "selection_score": 1.0906609037518502
    },
    {
      "generator_step": 2200,
      "generator_loss": 1.3018580675125122,
      "critic_loss": -0.1839527189731598,
      "gradient_penalty": 0.00520103657618165,
      "judge_fidelity": 0.9624999761581421,
      "mean_diversity_ratio": 0.899994432926178,
      "selection_score": 1.0974991410970687
    },
    {
      "generator_step": 2400,
      "generator_loss": 1.5436924695968628,
      "critic_loss": -0.16877740621566772,
      "gradient_penalty": 0.0042749010026454926,
      "judge_fidelity": 0.9599999785423279,
      "mean_diversity_ratio": 1.0144544422626496,
      "selection_score": 1.1099999785423278
    }
  ]
}

Backed-up artifact tree

  • README.md
  • __pycache__/app.cpython-311.pyc
  • __pycache__/model.cpython-311.pyc
  • app.py
  • artifacts/pocket-wgan/critic.safetensors
  • artifacts/pocket-wgan/evaluation.json
  • artifacts/pocket-wgan/generated_samples.npz
  • artifacts/pocket-wgan/generator.safetensors
  • artifacts/pocket-wgan/samples.png
  • data/evaluation_samples.parquet
  • model.py
  • requirements.txt
  • train.py