Skip to content
Back to skills

Pytorch

ASecurity

PyTorch for deep learning research and production

  • 47 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added September 12, 2026
databackend

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add skeletorflet/opencode-supreme-setup --skill pytorch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Pytorch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Pytorch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/skeletorflet-pytorch/badge)](https://www.skillsdirectory.com/skills/skeletorflet-pytorch)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: pytorch
description: PyTorch for deep learning research and production
---

### Core Concepts
- **Tensors**: Multi-dimensional arrays on CPU/GPU with autograd tracking
- **Autograd**: Automatic differentiation via `requires_grad` and `backward()`
- **nn.Module**: Base class for neural network layers with `forward()` method
- **Optimizers**: `torch.optim.SGD`, `Adam`, `AdamW` with `zero_grad()`/`step()` loop
- **DataLoader**: Batched, shuffled, parallel data loading with `Dataset` subclass
- **Distributed Training**: `DistributedDataParallel` for multi-GPU with NCCL backend

### Common Patterns
- `nn.Sequential(nn.Linear(d_in, d_hid), nn.ReLU(), nn.Linear(d_hid, d_out))` for simple nets
- Training loop: `for x, y in dataloader: pred = model(x); loss = loss_fn(pred, y); loss.backward(); optimizer.step(); optimizer.zero_grad()`
- `torch.utils.data.Dataset` with `__len__` and `__getitem__` for custom data
- Transfer learning: freeze `requires_grad=False` on backbone, train new head
- `torch.compile(model)` for graph optimization with `mode="reduce-overhead"`
- `model.to("cuda")` and `x.to("cuda")` for GPU execution

### Best Practices
- Use `with torch.no_grad():` for inference to disable gradient computation
- Set `torch.manual_seed(42)` and `torch.cuda.manual_seed_all(42)` for reproducibility
- Profile with `torch.profiler` before optimizing GPU utilization
- Use `pin_memory=True` in DataLoader for faster CPU-to-GPU transfer
- Enable `grad_scaler` for mixed precision training with `torch.cuda.amp`

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.