# Pytorch Training

Best practices for building robust PyTorch training loops.

- Repository: https://github.com/aiming-lab/AutoResearchClaw (14798 stars)
- Category: Data and ML
- License: MIT
- Last updated: 2026-08-19
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add aiming-lab/AutoResearchClaw --skill pytorch-training -g -a claude-code -y`
Codex: `npx skills add aiming-lab/AutoResearchClaw --skill pytorch-training -g -a codex -y`
Cursor: `npx skills add aiming-lab/AutoResearchClaw --skill pytorch-training -g -a cursor -y`
Gemini CLI: `npx skills add aiming-lab/AutoResearchClaw --skill pytorch-training -g -a gemini-cli -y`

## Description

Best practices for building robust PyTorch training loops. Use when generating or reviewing ML training code.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

## PyTorch Training Best Practice
1. Use torch.manual_seed() for reproducibility (set for torch, numpy, random)
2. Use DataLoader with num_workers>0 and pin_memory=True for GPU
3. Enable cudnn.benchmark=True for fixed input sizes
4. Use learning rate schedulers (CosineAnnealingLR or OneCycleLR)
5. Implement early stopping based on validation metric
6. Log metrics every epoch, save best model checkpoint
7. Use torch.no_grad() for evaluation
8. Clear gradients with optimizer.zero_grad(set_to_none=True) for efficiency

