machine-learning

Implements machine learning models using JAX with functional programming patterns and JIT compilation.

Updated Aug 28, 2026
One-click install
npx skills add https://github.com/Yash-Awasthi/adapfit --skill machine-learning-yash-awasthi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: machine-learning
Source: https://github.com/Yash-Awasthi/adapfit/tree/main/.agents/skills/machine-learning
Command: npx skills add https://github.com/Yash-Awasthi/adapfit --skill machine-learning-yash-awasthi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing correct and performant JAX code requires discipline around functional purity, random key management, and JIT-compatible control flow, which developers often get wrong when coming from NumPy or imperative frameworks. ## Core Features & Use Cases - JAX Fundamentals Guidance: Covers jax.numpy operations, automatic differentiation with jax.grad, JIT compilation with jax.jit, and vectorization with jax.vmap. - Functional Control Flow: Enforces jax.lax.scan, jax.lax.cond, and jax.lax.fori_loop instead of Python control flow inside jitted functions. - Model Development Patterns: Guides pure-function model definitions using Flax or Haiku, proper random key splitting, pytrees, sharding, and gradient checkpointing. - Use Case: When building a training loop that runs slowly or produces wrong gradients, apply this Skill to refactor it into pure functions with proper key splitting and JIT-compiled scan loops. ## Quick Start Help me write a JIT-compiled JAX training loop for a neural network using Flax with proper random key splitting.

Frequently Asked Questions about machine-learning

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

FAQPage Schema
How do I write a JIT-compiled training loop in JAX?▼

Define the training step as a pure function and decorate it with jax.jit, replacing Python loops with jax.lax.scan or jax.lax.fori_loop. Avoid side effects and Python control flow inside jitted code, since they break tracing or silently produce wrong results.

How does random number generation work in JAX?▼

JAX uses a functional random API where you explicitly create and split PRNG keys instead of relying on global state. Split keys before each use and never reuse a key, otherwise random values become correlated or identical.

Should I use Flax or Haiku for neural networks in JAX?▼

Both Flax and Haiku provide neural network layers on top of JAX while keeping models as pure functions with explicit parameter pytrees. Choose based on your team's existing codebase, since both integrate with jax.jit, jax.vmap, and jax.grad.

Why does my jitted JAX function ignore Python if statements?▼

Python control flow is evaluated once at trace time, so data-dependent branches are frozen into the compiled graph. Replace conditionals with jax.lax.cond and loops with jax.lax.scan or jax.lax.fori_loop for correct dynamic behavior.

How do I reduce memory usage when training large JAX models?▼

Use gradient checkpointing to trade compute for memory, choose smaller dtypes where acceptable, and batch operations to improve utilization. Profile with the JAX profiler to find hot paths before optimizing.