BigGAN-PyTorch training
Use this sub-skill as the training router for the BigGAN-PyTorch repository. It
covers the executable training path (train.py and train_fns.py), the model
and numerical building blocks (BigGAN.py, BigGANdeep.py, layers.py,
losses.py, and sync_batchnorm/), and the bookkeeping/data helpers in
utils.py.
Route by intent
- Start a run or choose a recipe: read
references/workflows.md.
- Choose flags, understand tensor/optimizer contracts, or modify a model:
read
references/api-reference.md.
- Diagnose a failed help command, data path, OOM, resume, precision, or
multi-GPU run: read
references/troubleshooting.md.
Do not launch a production-scale run until the CUDA, dataset, output-root, and
experiment-name gates in workflows.md pass. The code is designed for CUDA;
train.py assigns device = 'cuda', and the sampling/standing-stat utilities
also create tensors on CUDA. A CPU-only run is not a supported fallback.
Non-negotiable facts
- The historical README targets PyTorch 1.0.1 plus
tqdm, numpy, scipy,
and h5py; this is an old research codebase, so validate the installed
PyTorch/torchvision pair before a long run.
- Supported dataset keys are
I32, I64, I128, I256, their _hdf5
ImageNet forms, C10, and C100. The key determines resolution, class
count, and the child name appended below data_root; do not substitute an
arbitrary directory name without updating the metadata dictionaries.
--parallel uses torch.nn.DataParallel around the combined G_D module,
not distributed training. Select visible GPUs with CUDA_VISIBLE_DEVICES.
- The default loss is hinge loss. The training closure averages each
accumulation loss before
backward(), then takes one optimizer step for the
corresponding network.
--ema creates a non-optimizing generator copy. --use_ema affects
sampling/metrics only when EMA is enabled; it does not change which weights
are optimized. Standing-stat accumulation is a separate option.
--G_fp16/--D_fp16 cast the corresponding modules (and the relevant data)
to half. The *_mixed_precision switches select the repository's naive
Adam16; they are not a modern AMP/Tensor-Core implementation. The README
reports early collapse risk and no Tensor-Core activation for this path.
- Checkpoints are a family of files under
<weights_root>/<experiment_name>/: G, D, both optimizer states,
state_dict, and optionally G_ema. Resume with the same configuration-derived
or explicitly supplied experiment name; use --load_weights for suffixes
such as best0 or copy0.
- On Python 3.11,
python train.py --help can crash before showing help with
ValueError: unsupported format character '#'. The literal %#.#f/%#.#e
text in the --logstyle help string is interpreted by argparse's %
formatter. Escape the literal percent signs in that help string as
%%#.#f/%%#.#e (or replace the text with words); keep the runtime
--logstyle value such as %3.3e unchanged. The same failure is observable
on newer Python versions. This is a parser-help bug, not a CUDA diagnosis.
For a short, bounded verification run, use the temporary ImageFolder smoke
harness in workflows.md; it bypasses the repository's unconditional Inception
startup, avoids metric evaluation and checkpoint sample sheets, uses one tiny
batch, and keeps all artifacts outside the repository.
1---2name: training-73description: "Train, resume, smoke-test, or troubleshoot BigGAN-PyTorch GAN4 runs, including BigGAN and BigGANdeep architectures, CUDA parallelism,5 gradient accumulation, EMA, spectral normalization, orthogonal regularization,6 precision modes, checkpoints, datasets, and the checked-in launch recipes."7disable-model-invocation: true8metadata:9 source: https://skillmd.com/skills/vectorspacelab/training-710 disco-role: operating11license: MIT12---1314# BigGAN-PyTorch training1516Use this sub-skill as the training router for the BigGAN-PyTorch repository. It17covers the executable training path (`train.py` and `train_fns.py`), the model18and numerical building blocks (`BigGAN.py`, `BigGANdeep.py`, `layers.py`,19`losses.py`, and `sync_batchnorm/`), and the bookkeeping/data helpers in20`utils.py`.2122## Route by intent2324- **Start a run or choose a recipe:** read `references/workflows.md`.25- **Choose flags, understand tensor/optimizer contracts, or modify a model:**26 read `references/api-reference.md`.27- **Diagnose a failed help command, data path, OOM, resume, precision, or28 multi-GPU run:** read `references/troubleshooting.md`.2930Do not launch a production-scale run until the CUDA, dataset, output-root, and31experiment-name gates in `workflows.md` pass. The code is designed for CUDA;32`train.py` assigns `device = 'cuda'`, and the sampling/standing-stat utilities33also create tensors on CUDA. A CPU-only run is not a supported fallback.3435## Non-negotiable facts36371. The historical README targets PyTorch 1.0.1 plus `tqdm`, `numpy`, `scipy`,38 and `h5py`; this is an old research codebase, so validate the installed39 PyTorch/torchvision pair before a long run.402. Supported dataset keys are `I32`, `I64`, `I128`, `I256`, their `_hdf5`41 ImageNet forms, `C10`, and `C100`. The key determines resolution, class42 count, and the child name appended below `data_root`; do not substitute an43 arbitrary directory name without updating the metadata dictionaries.443. `--parallel` uses `torch.nn.DataParallel` around the combined `G_D` module,45 not distributed training. Select visible GPUs with `CUDA_VISIBLE_DEVICES`.464. The default loss is hinge loss. The training closure averages each47 accumulation loss before `backward()`, then takes one optimizer step for the48 corresponding network.495. `--ema` creates a non-optimizing generator copy. `--use_ema` affects50 sampling/metrics only when EMA is enabled; it does not change which weights51 are optimized. Standing-stat accumulation is a separate option.526. `--G_fp16`/`--D_fp16` cast the corresponding modules (and the relevant data)53 to half. The `*_mixed_precision` switches select the repository's naive54 `Adam16`; they are not a modern AMP/Tensor-Core implementation. The README55 reports early collapse risk and no Tensor-Core activation for this path.567. Checkpoints are a family of files under57 `<weights_root>/<experiment_name>/`: G, D, both optimizer states,58 `state_dict`, and optionally `G_ema`. Resume with the same configuration-derived59 or explicitly supplied experiment name; use `--load_weights` for suffixes60 such as `best0` or `copy0`.618. On Python 3.11, `python train.py --help` can crash before showing help with62 `ValueError: unsupported format character '#'`. The literal `%#.#f/%#.#e`63 text in the `--logstyle` help string is interpreted by argparse's `%`64 formatter. Escape the literal percent signs in that *help string* as65 `%%#.#f/%%#.#e` (or replace the text with words); keep the runtime66 `--logstyle` value such as `%3.3e` unchanged. The same failure is observable67 on newer Python versions. This is a parser-help bug, not a CUDA diagnosis.6869For a short, bounded verification run, use the temporary ImageFolder smoke70harness in `workflows.md`; it bypasses the repository's unconditional Inception71startup, avoids metric evaluation and checkpoint sample sheets, uses one tiny72batch, and keeps all artifacts outside the repository.