agentleFS
congmnguyencongmnguyen/claude-code-wsl2-setup/skills/pytorch-training/SKILL.md

pytorch-training

Skill50 starsChanged 3 months agoMITView on GitHub

PyTorch model-building conventions and a neural-net training debug checklist. Use this skill whenever writing or reviewing PyTorch code that defines a model (nn.Linear, nn.Conv2d, BatchNorm) or trains one (training loop, optimizer, LR schedule), and ESPECIALLY when debugging training problems — loss not converging, loss stuck or flat, suspiciously slow learning, "hockey stick" loss curves, or a model that seems to ignore its inputs. Also consult it before starting any from-scratch training run, even if the user doesn't mention debugging.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run through these before and during any training run — each one catches a class of silent bug that wastes full training runs:

    line 14
  2. Very specific:

    Overfit a single batch first: Before full training, verify the model can drive loss to ~0 on one small batch — if it can't, there's a bug …

    line 16
  3. Very specific:

    Verify loss @ init: Check the starting loss equals the theoretical value — softmax over n classes should give -log(1/n) (e.g.

    line 17

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

PyTorch Training

Model-building conventions

  • Set bias=False on any nn.Linear/nn.Conv2d immediately followed by BatchNorm — BN's mean-subtraction + learnable beta cancels the bias, making it dead params. Keep bias=True (default) on the output/classifier head, which has no BN after it.

Neural net training checklist (common mistakes if skipped)

Run through these before and during any training run — each one catches a class of silent bug that wastes full training runs:

  1. Overfit a single batch first. Before full training, verify the model can drive loss to ~0 on one small batch — if it can't, there's a bug in the model/loss/data pipeline; no point training on the full set.
  2. Verify loss @ init. Check the starting loss equals the theoretical value — softmax over n classes should give -log(1/n) (e.g. ~2.30 for 10 classes). A mismatch means a bad head init or mislabeled targets.
  3. Input-independent baseline. Train once with inputs zeroed out; the model must do worse than with real inputs. If they match, the data pipeline isn't actually feeding the model (it's only learning the prior).
  4. Init the output-layer bias to data statistics. Regression with mean 50 → init bias 50; class imbalance 1:10 → set logit bias so p≈0.1 at init. Kills the "hockey stick" loss curve where early steps just learn the bias.
  5. Visualize the exact tensor right before y_hat = model(x). Decode what actually enters the net — the only source of truth for catching preprocessing/augmentation bugs (e.g. forgetting to flip labels when flipping images).
  6. Don't trust LR-decay defaults; use a constant LR and tune it last. Borrowed code often decays by epoch number (e.g. ImageNet decays at epoch 30) — on a smaller dataset this silently drives the LR to ~0 before the model converges.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.