pytorchAvoid common PyTorch mistakes β train/eval mode, gradient leaks, device mismatches, and checkpoint gotchas.
Install via ClawdBot CLI:
clawdbot install ivangdavila/pytorchRequires:
model.train() enables dropout, BatchNorm updates β default after initmodel.eval() disables dropout, uses running stats β MUST call for inferencemodel.eval() doesn't disable gradients β still need torch.no_grad()torch.no_grad() for inference β reduces memory, speeds up computationloss.backward() accumulates gradients β call optimizer.zero_grad() before backwardzero_grad() placement matters β before forward pass, not after backward.detach() to stop gradient flow β prevents memory leak in loggingmodel.to(device) and tensor.to(device).cuda() vs .to('cuda') β both work, .to(device) more flexible.cpu().numpy() requiredtorch.device('cuda' if torch.cuda.is_available() else 'cpu') β portable codenum_workers > 0 uses multiprocessing β Windows needs if name == 'main':pin_memory=True with CUDA β faster transfer to GPUworker_init_fnnum_workers can cause memory issues β start with 2-4, increase if CPU-boundtorch.save(model.state_dict(), path) β recommended, saves only weightsmodel.load_state_dict(torch.load(path))map_location for cross-device β torch.load(path, map_location='cpu') if saved on GPU_ β tensor.add_(1) vs tensor.add(1)tensor.data bypasses autograd β legacy, prefer .detach() for safety.detach() logged metricstorch.cuda.empty_cache() releases cached memory β but doesn't fix leaksgc.collect() β before empty_cache if neededwith torch.no_grad(): prevents graph storage β crucial for validation loopbatch_size=1 fails in train mode β use eval mode or track_running_stats=Falsecross_entropy expects logits β not softmax output.item() to get Python scalar β .numpy() or [0] deprecated/errorAI Usage Analysis
Analysis is being generated⦠refresh in a few seconds.
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
Provides a 7-step debugging protocol plus language-specific commands to systematically identify, verify, and fix software bugs across multiple environments.
A comprehensive skill for using the Cursor CLI agent for various software engineering tasks (updated for 2026 features, includes tmux automation guide).
Write, run, and manage unit, integration, and E2E tests across TypeScript, Python, and Swift using recommended frameworks.
Control and operate Opencode via slash commands. Use this skill to manage sessions, select models, switch agents (plan/build), and coordinate coding through Opencode.
Coding style memory that adapts to your preferences, conventions, and patterns for consistent coding.