界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
数据与研究 · SKILL.md

training-workflows

training-workflows

【数据与研究】Compose timm API-level training loops with optimizer and scheduler factories, loss selection, task wrappers, EMA, AMP scaling, metrics, checkpoint state, and safe CPU smoke checks. Use when writing or debugging custom training code rather than cataloging train.py CLI flags or building data loaders.

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: training-workflows description: "Compose timm API-level training loops with optimizer and scheduler factories, loss selection, task wrappers, EMA, AMP scaling, metrics, checkpoint state, and safe CPU smoke checks. Use when writing or debugging custom training code rather than cataloging train.py CLI flags or building data loaders." disable-model-invocation: true metadata: disco-role: operating license: Apache 2.0

Training Workflows

Use this sub-skill when an agent needs to assemble or debug timm training components in Python code: create_optimizer_v2, optimizer_kwargs, create_scheduler_v2, loss modules, task wrappers, EMA, AMP scaling, metrics, and checkpoint-saving concepts.

Route by Need

  • Optimizer or parameter groups: Start with references/optimizer-scheduler-guide.md for create_optimizer_v2, weight-decay filtering, layer decay, hybrid fallback groups, and optimizer_kwargs config translation.
  • LR schedule behavior: Use references/optimizer-scheduler-guide.md for create_scheduler_v2, epoch-vs-update stepping, warmup, cycles, plateau metrics, and returned adjusted epoch counts.
  • Losses and task wrappers: Use references/training-api.md for LabelSmoothingCrossEntropy, SoftTargetCrossEntropy, BinaryCrossEntropy, JsdCrossEntropy, ClassificationTask, and distillation task routing.
  • EMA, AMP, metrics, checkpoints: Use references/training-api.md for ModelEma variants, NativeScaler, accuracy, AverageMeter, task checkpoint state, and CheckpointSaver concepts.
  • Failure diagnosis: Use references/troubleshooting.md for unsupported optimizer names, layer-decay grouping, scheduler step confusion, mixup/BCE target shape, distillation shape mismatches, EMA resume, and AMP/device mismatch.
  • Smoke construction: Run or adapt scripts/training_api_smoke.py to verify a model, optimizer, scheduler, loss, optional task wrapper, metrics, EMA, and one CPU backward pass.

Boundaries

  • This sub-skill covers API-level composition. Leave train script flag catalogs and launch recipes to cli-workflows.
  • This sub-skill assumes tensors already come from a valid pipeline. Leave dataset, loader, transforms, mixup/cutmix construction, and collation details to data-pipelines.
  • Do not make generated examples depend on repository-local files; keep examples importable from installed timm and standard PyTorch.

Safe Defaults

For a minimal custom loop, prefer create_model(..., pretrained=False), create_optimizer_v2(model, opt='adamw', lr=...), create_scheduler_v2(optimizer, sched='cosine', num_epochs=..., warmup_epochs=...), a target-compatible loss, accuracy/AverageMeter for logging, and optional ModelEmaV3 after model/device placement.

Run the smoke script before recommending a larger recipe:

python scripts/training_api_smoke.py --model resnet18 --opt adamw --sched cosine
我的收藏