Assists with building, training, and deploying neural networks using PyTorch. Use when designing architectures for computer vision, NLP, or tabular data, optimizing training with mixed precision and distributed strategies, or exporting models for production inference. Trigger words: pytorch, torch, neural network, deep learning, training loop, cuda.
PyTorch is a deep learning framework for building and training neural networks with dynamic computation graphs and automatic differentiation. It provides tensor operations with GPU acceleration, nn.Module for defining architectures, DataLoader for efficient data loading, mixed precision training for performance, and export tools (TorchScript, ONNX) for production deployment.
nn.Module with __init__ for layers and forward for computation, using nn.Sequential for simple stacks and custom forward logic for complex architectures.loss.backward(), optimizer.step(), optimizer.zero_grad(), with gradient clipping via clip_grad_norm_ for stability.Dataset with __len__ and __getitem__, then use DataLoader with num_workers=4 and pin_memory=True for GPU training throughput.torch.compile(model) on PyTorch 2.0+ for 20-50% speedup, mixed precision with torch.amp.autocast() for halved memory and doubled throughput, and DistributedDataParallel for multi-GPU training.torchvision.models or Hugging Face, freeze the backbone, and replace the classifier head for your task.torch.export() or torch.jit.trace() for production, torch.onnx.export() for cross-framework compatibility, and torch.quantization for INT8 inference speedup.User request: "Fine-tune a pretrained ResNet for classifying product images"
Actions:
resnet50(weights=ResNet50_Weights.DEFAULT) and freeze all layers except the final classifiernn.Linear(2048, num_classes)Output: A fine-tuned image classifier with production-quality accuracy and efficient mixed-precision training.
User request: "Build a sentiment analysis model using a pretrained transformer"
Actions:
AutoModel.from_pretrained("bert-base-uncased") with a classification headAutoTokenizer and create a DataLoadertorch.export() for production servingOutput: A sentiment analysis model fine-tuned on custom data and exported for production inference.
torch.compile(model) on PyTorch 2.0+ for a free 20-50% speedup with one line.AdamW over Adam for correct weight decay implementation with modern architectures.torch.amp) for any GPU training to halve memory and double throughput.model.eval() and torch.no_grad() during inference to prevent unnecessary gradient computation.pin_memory=True in DataLoader when training on GPU to speed up CPU-to-GPU data transfer.model.state_dict() not the full model since state dicts are portable across code changes.npx skills add TerminalSkills/pytorch下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer