Apply PyTorch best practices for robust, efficient, reproducible deep learning pipelines.
Overall this appears to be an open-source, highly adopted prompt/documentation-only PyTorch skill with no secrets, no remote endpoints, and no clear signs of local execution or data egress, so risk is low. The main caveats are the undeclared license and unknown maintenance status, which slightly weaken supply-chain confidence.
No keys, tokens, or environment variables are required; there is no sign of credential collection, forwarding, or abuse in the materials.
System checks show no remote hosts, and the README only describes local development patterns and best practices, with no data egress behavior indicated.
This is prompt/documentation-only and does not indicate spawning processes or executing system commands; however, as a skill it may still indirectly guide local code generation and execution, which is a normal caution.
The materials focus on PyTorch training, data loading, and code review, so it may touch user-provided local code or data samples, but no overbroad read/write access is shown.
The source is a GitHub open-source repository with very high community adoption (210k+ stars), which supports auditability; however, the license is undeclared and maintenance status is unknown, leaving some supply-chain opacity.
Copy the install command and let the AI configure it · recommended for beginners
Please install the "pytorch-patterns" skill from askskill: 1. Download https://raw.githubusercontent.com/affaan-m/ECC/main/skills/pytorch-patterns/SKILL.md 2. Save it as ~/.claude/skills/pytorch-patterns/SKILL.md 3. Reload skills and tell me it's ready
Give me a set of PyTorch training pipeline best practices, including project structure, config management, random seed setup, training and validation loops, checkpointing, logging, and reproducibility tips.
A structured training pipeline plan covering core modules and reproducible implementation guidance.
I am training an image model with PyTorch. Summarize best practices for Dataset, DataLoader, augmentation, multi-process loading, pin_memory, and prefetching, and explain common performance bottlenecks and debugging methods.
A set of data loading optimization recommendations with tuning tips, common pitfalls, and a troubleshooting checklist.
Based on PyTorch best practices, explain how to design maintainable model architecture code, including module decomposition, forward conventions, initialization strategies, device management, mixed precision training, and experiment tracking.
A model engineering guideline that improves maintainability, training stability, and experiment management.
Idiomatic PyTorch patterns and best practices for building robust, efficient, and reproducible deep learning applications.
Always write code that works on both CPU and GPU without hardcoding devices.
# 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()
Set all random seeds for reproducible results.
# 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
Always document and verify tensor shapes.
# 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?
# 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
# 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()
model.apply(model._init_weights)
# Good: Complete training loop with best practices
def train_one_epoch(
model: nn.Module,
dataloader: DataLoader,
optimizer: torch.optim.Optimizer,
criterion: nn.Module,
device: torch.device,
scaler: torch.amp.GradScaler | None = None,
) -> float:
model.train() # Always set train mode
total_loss = 0.0
for batch_idx, (data, target) in enumerate(dataloader):
data, target = data.to(device), target.to(device)
…
Handle returns, refunds, fraud checks, and warranty claim decisions efficiently.
Use Bun for runtime, bundling, testing, packages, and Node migration decisions.
Use the correct Ethereum Keccak-256 hashing in Node.js and TypeScript.
Apply Nuxt 4 patterns for SSR safety, performance, and data fetching.
Generate images, videos, and audio with one unified AI media workflow.
Design Quarkus 3 backend patterns for messaging, APIs, data, and async workflows.
Learn Django architecture, DRF API design, and production-ready development practices.
Search local PyTorch docs for answers, symbols, examples, and troubleshooting help.
Apply idiomatic Kotlin patterns to build robust, efficient, maintainable applications.
Learn Pythonic patterns, type hints, and best practices for maintainable code.
Learn idiomatic Go patterns and best practices for robust, maintainable applications.
Learn idiomatic Rust patterns, ownership, concurrency, and robust error handling practices.