pytorch-patterns
PyTorch 深度学习模式与最佳实践,用于构建稳健、高效且可复现的训练流水线、模型架构和数据加载。在编写或审查 PyTorch 训练循环、模型架构或数据加载时使用,或在某次运行无法复现时使用。
机器翻译查看英文原文
PyTorch deep learning patterns and best practices for building robust, efficient, and reproducible training pipelines, model architectures, and data loading. Use when writing or reviewing PyTorch training loops, model architectures, or data loading, or when a run will not reproduce.
适用对象:对象待分类。自动收录 · 待核查。
原作者说明节选
从固定版本的 SKILL.md 提取,保留原文语言。以下内容属于作者说明,本站尚未验证安装、兼容或运行结果。
查看英文原文
原文涵盖的主题
- PyTorch Development Patterns
- When to Activate
- Core Principles
- 1. Device-Agnostic Code
- 2. Reproducibility First
- 3. Explicit Shape Management
- Model Architecture Patterns
- Clean nn.Module Structure
Idiomatic PyTorch patterns and best practices for building robust, efficient, and reproducible deep learning applications. Writing new PyTorch models or training scripts Reviewing deep learning code Debugging training loops or data pipelines Optimizing GPU memory usage or training speed Setting up reproducible experiments Always write code that works on both CPU and GPU without hardcoding devices. Set all random seeds for reproducible results. Always document and verify tensor shapes. | Idiom | Description | |-------|-------------| | model.train() / model.eval() | Always set mode before train/eval | | torch.nograd() | Disable gradients for inference | | optimizer.zerograd(settonone=True) | More efficient gradient clearing | | .to(device) | Device-agnostic tensor/model placement | | torch.amp.autocast | Mixed precision for 2x speed | | pinmemory=True | Faster CPU→GPU data transfer | | torch.compile | JIT compilation for speed (2.0+) | | weightsonly=True | Secure model loading | | torch.manualseed | Reproducible experiments | | gradientcheckpointing | Trade compute for memory | Remember: PyTorch code should be device-agnostic, reproducible, and memory-conscious. When in doubt, profil
这里只展示节选,请以完整原文和当前要求为准。
- 来源仓库
- affaan-m/ECC
- 源文件
- pi/core/skills/pytorch-patterns/SKILL.md
- 固定版本
- d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
来源与内容状态
本条为自动发现的元数据,尚未完成人工文档核查;适用性与运行结果待核查。
原作者:affaan-m/ECC · 原作者仓库元数据。文档核查:未核查。最近来源检查:2026-11-09T15:01:43.204Z。
分类由名称、说明与路径规则生成,分类不代表已核实适配。
许可与权利归属
MIT。第三方内容及版权归原作者,使用条件以原文为准。
许可原文 ↗本站没有因同步、复制或用户自报成功而将资源标为运行验证通过。
限制与注意事项
- 元数据收录不代表本站已经安装、适配、实测或进行安全审查。