ml-framework-implementation

Implements and debugs reproducible machine learning code in PyTorch, TensorFlow, JAX, and scikit-learn.

Updated Aug 28, 2026
One-click install
npx skills add https://github.com/miyake-san/sogo-agent-platform --skill ml-framework-implementation-miyake-san
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ml-framework-implementation
Source: https://github.com/miyake-san/sogo-agent-platform/tree/main/skills/experimental/ml-framework-implementation
Command: npx skills add https://github.com/miyake-san/sogo-agent-platform --skill ml-framework-implementation-miyake-san

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing ML code that actually runs is hard: shape mismatches, wrong loss/activation pairings, non-deterministic results, and outdated APIs cause most failures. This Skill turns ML ideas, math, and papers into complete, runnable, reproducible code using current idiomatic framework APIs. ## Core Features & Use Cases - Framework Implementation: Write models, training loops, data pipelines, and evaluation harnesses in PyTorch, TensorFlow/Keras, JAX/Flax, scikit-learn, Hugging Face, XGBoost, and LightGBM. - Paper-to-Code Translation: Convert a method or mathematical derivation into working code with annotated tensor shapes and a smoke test. - Debugging Guidance: Diagnose shape errors, NaN losses, CUDA OOM, non-reproducibility, and incorrect loss/activation pairings with a structured symptom table. - Use Case: Ask for a PyTorch training loop for image classification and receive a complete script with seed setting, device pinning, gradient clipping, correct CrossEntropyLoss usage on logits, and a validation pass. ## Quick Start Ask the agent to implement a training loop for your model in PyTorch with reproducibility settings and a smoke test on a small batch.

Frequently Asked Questions about ml-framework-implementation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a reproducible PyTorch training loop?

Set seeds for random, numpy, and torch, enable cudnn deterministic mode, and pin the device. Use AdamW, pass raw logits to CrossEntropyLoss, clip gradients, and separate train and eval phases with model.train() and torch.no_grad().

How to fine-tune a Hugging Face Transformer model?

Load a tokenizer and model with AutoTokenizer and AutoModelForSequenceClassification, tokenize with truncation and padding, then train with the Trainer API and TrainingArguments. Pin a model revision in production and pass a compute_metrics function for evaluation.

PyTorch vs JAX vs scikit-learn for model implementation?

PyTorch uses nn.Module with manual backward passes, JAX/Flax uses functional modules with jax.value_and_grad and optax optimizers, and scikit-learn fits estimators via Pipeline with .fit(X, y). Choose based on task: deep learning favors PyTorch or JAX, tabular baselines favor scikit-learn.

Why is my training loss NaN in PyTorch?

NaN losses usually come from a learning rate that is too high, log of zero, poor initialization, or missing gradient clipping. Lower the learning rate, add eps or clamping, clip gradient norms, and inspect the input data for invalid values.

Why does CrossEntropyLoss give a shape error?

CrossEntropyLoss expects raw logits of shape (B, C) and target class indices of shape (B,) with long dtype. Passing probabilities, one-hot targets, or mismatched batch dimensions causes the mismatch.

How do I fix CUDA out of memory during training?

Reduce the batch size, use gradient accumulation to simulate larger batches, enable automatic mixed precision with torch.amp, or apply gradient checkpointing. These trade compute or memory to fit the model on available GPU memory.