pytorch-patterns
PyTorch deep learning patterns and best practices for building robust, efficient, and reproducible training pipelines, model architectures, and data loading.
Skill by jpmsilva1
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/jpmsilva1-pytorch-patterns
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: data, ml
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions: not checked yet.
What's inside
- Skill name
pytorch-patterns- Description
- PyTorch deep learning patterns and best practices for building robust, efficient, and reproducible training pipelines, model architectures, and data loading.
- License
- MIT
- Metadata
- origin: community (adapted from ECC)
- Instructions
- 392 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# PyTorch Development Patterns
Idiomatic PyTorch patterns and best practices for building robust, efficient, and reproducible deep learning applications.
## When to Activate
- 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
## Core Principles
### 1. Device-Agnostic Code
Always write code that works on both CPU and GPU without hardcoding devices.
```python
# Good: Device-agnostic
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = MyModel().to(device)
data = data.to(device)
# Bad: Hardcoded device
model = MyModel().cuda() # Crashes if no GPU
data = data.cuda()
```
### 2. Reproducibility First
Set all random seeds for reproducible results.
```python
# Good: Full reproducibility setup
def set_seed(seed: int = 42) -> None:
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
np.random.seed(seed)
random.seed(seed)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
# Bad: No seed control
model = MyModel() # Different weights every run
```
### 3. Explicit Shape Management
Always document and verify tensor shapes.
```python
# Good: Shape-annotated forward pass
def forward(self, x: torch.Tensor) -> torch.Tensor:
# x: (batch_size, channels, height, width)
x = self.conv1(x) # -> (batch_size, 32, H, W)
x = self.pool(x) # -> (batch_size, 32, H//2, W//2)
x = x.view(x.size(0), -1) # -> (batch_size, 32*H//2*W//2)
return self.fc(x) # -> (batch_size, num_classes)
# Bad: No shape tracking
def forward(self, x):
x = self.conv1(x)
x = self.pool(x)
x = x.view(x.size(0), -1) # What size is this?
return self.fc(x) # Will this even work?
```
## Model Architecture Patterns
### Clean nn.Module Structure
```python
# Good: Well-organized module
class ImageClassifier(nn.Module):
def __init__(self, num_classes: int, dropout: float = 0.5) -> None:
super().__init__()
self.features = nn.Sequential(
nn.Conv2d(3, 64, kernel_size=3, padding=1),
nn.BatchNorm2d(64),
nn.ReLU(inplace=True),
nn.MaxPool2d(2),
)
self.classifier = nn.Sequential(
nn.Dropout(dropout),
nn.Linear(64 * 16 * 16, num_classes),
)
def forward(self, x: torch.Tensor) -> torch.Tensor:
x = self.features(x)
x = x.view(x.size(0), -1)
return self.classifier(x)
# Bad: Everything in forward
class ImageClassifier(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
x = F.conv2d(x, weight=self.make_weight()) # Creates weight each call!
return x
```
### Proper Weight Initialization
```python
# Good: Explicit initialization
def _init_weights(self, module: nn.Module) -> None:
if isinstance(module, nn.Linear):
nn.init.kaiming_normal_(module.weight, mode="fan_out", nonlinearity="relu")
if module.bias is not None:
nn.init.zeros_(module.bias)
elif isinstance(module, nn.Conv2d):
nn.init.kaiming_normal_(module.weight, mode="fan_out", nonlinearity="relu")
elif isinstance(module, nn.BatchNorm2d):
nn.init.ones_(module.weight)
nn.init.zeros_(module.bias)
model = MyModel()From jpmsilva1/ai-research-ecosystem, MIT.
More from jpmsilva1/ai-research-ecosystem
- 0.529score
academic-code-replicator
jpmsilva1
Full-lifecycle skill for replicating experiments from academic papers.
SkillBFreshness: BClaude Code +9 - 0.524score
research-orchestrator
jpmsilva1
Triggered when the user types /research or asks to start a research workflow.
SkillBFreshness: BClaude Code +9 - 0.524score
output-shaper
jpmsilva1
Dynamic token compression and verbosity controller.
SkillBFreshness: BClaude Code +9 - 0.524score
save-session
jpmsilva1
Triggered when the user types /save or asks to save the session.
SkillBFreshness: BClaude Code +9 - 0.524score
lint-vault
jpmsilva1
Triggered when the user types /lint or asks to health-check the Obsidian Vault.
SkillBFreshness: BClaude Code +9 - 0.521score
scientific-thinking-literature-review
jpmsilva1
Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis…
SkillBFreshness: BClaude Code +9 - 0.521score
scientific-thinking-scholar-evaluation
jpmsilva1
Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing…
SkillBFreshness: BClaude Code +9 - 0.521score
academic-rebuttal-simulator
jpmsilva1
Simulates 'Reviewer 2' for ML papers (NeurIPS, ICLR).
SkillBFreshness: BClaude Code +9 - 0.521score
distributed-gpu-engineer
jpmsilva1
Expert in scaling ML training across multiple GPUs and nodes.
SkillBFreshness: BClaude Code +9 - 0.521score
experiment-sweeper
jpmsilva1
Expert in ML hyperparameter orchestration.
SkillBFreshness: BClaude Code +9 - 0.521score
paper-code-finder
jpmsilva1
Find source code implementations and GitHub repositories for academic AI/ML research papers.
SkillBFreshness: BClaude Code +9 - 0.519score
resume-session
jpmsilva1
Triggered when the user types /resume or asks to resume.
SkillBFreshness: BClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Jul 31, 2026 (2 months ago)
- Last release
- Aug 14, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
More from jpmsilva1
- 0.529score
academic-code-replicator
jpmsilva1
Full-lifecycle skill for replicating experiments from academic papers.
SkillBFreshness: BClaude Code +9 - 0.524score
research-orchestrator
jpmsilva1
Triggered when the user types /research or asks to start a research workflow.
SkillBFreshness: BClaude Code +9 - 0.524score
output-shaper
jpmsilva1
Dynamic token compression and verbosity controller.
SkillBFreshness: BClaude Code +9 - 0.524score
save-session
jpmsilva1
Triggered when the user types /save or asks to save the session.
SkillBFreshness: BClaude Code +9 - 0.524score
lint-vault
jpmsilva1
Triggered when the user types /lint or asks to health-check the Obsidian Vault.
SkillBFreshness: BClaude Code +9 - 0.521score
scientific-thinking-literature-review
jpmsilva1
Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis…
SkillBFreshness: BClaude Code +9
Cite this page
pytorch-patterns skill. Agent Mart. https://agentmart.dev/skills/jpmsilva1-pytorch-patterns (last updated 2026-10-24)