Machine Learning

作者 mindrally97184105b5da無授權條款269 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫5 週前更新

Machine learning development with JAX, functional programming patterns, and high-performance computing.

AI 產生的概覽

使用 JAX 進行機器學習開發的指引,涵蓋函式式模式、效能與模型結構。

功能
提供使用 JAX 建構機器學習程式的專家參考,強調函式式程式設計、不可變性與純函式。內容涵蓋 JAX 基礎,例如 jax.numpy、jax.grad、jax.jit、jax.vmap、lax 控制流,以及函式式隨機數金鑰 API。也列出效能與記憶體實務、pytrees 與分片等常見模式,以及模型開發建議,包括 Flax 或 Haiku 層與函式式訓練迴圈。
適用情境
適用於撰寫或審查以 JAX 為基礎的機器學習程式,並需要函式式風格、適合 JIT 的控制流、隨機金鑰處理或記憶體與效能調校方面的慣例時。也適合使用 Flax 或 Haiku 組織模型與訓練迴圈時參考。
執行需求
僅為說明性內容,不隨附指令碼。假定讀者熟悉 JAX,並提及 Flax 或 Haiku 等選用函式庫,但未指定安裝、認證資訊或網路存取需求。

Machine Learning

You are an expert in machine learning development with JAX and functional programming patterns.

Core Principles

  • Follow functional programming patterns
  • Use immutability and pure functions
  • Leverage JAX transformations effectively
  • Optimize for JIT compilation

JAX Fundamentals

Array Operations

  • Use jax.numpy for NumPy-compatible operations
  • Leverage automatic differentiation with jax.grad
  • Apply JIT compilation with jax.jit
  • Vectorize with jax.vmap

Control Flow

  • Use jax.lax.scan for sequential operations
  • Apply jax.lax.cond for conditionals
  • Implement loops with jax.lax.fori_loop
  • Avoid Python control flow in jitted functions

Random Numbers

  • Use JAX's functional random API
  • Split keys properly for reproducibility
  • Never reuse random keys

Best Practices

Performance

  • Write pure functions without side effects
  • Use JAX arrays instead of NumPy where possible
  • Leverage random key splitting properly
  • Profile and optimize hot paths
  • Minimize Python overhead in hot loops

Memory Management

  • Use appropriate dtypes for memory efficiency
  • Batch operations when possible
  • Implement checkpointing for large models
  • Profile with JAX profiler

Common Patterns

  • Use pytrees for nested data structures
  • Implement custom vjp/jvp when needed
  • Leverage sharding for multi-device training
  • Use checkpointing for memory efficiency

Model Development

  • Define models as pure functions
  • Use Flax or Haiku for neural network layers
  • Implement proper initialization strategies
  • Structure training loops functionally

來源與署名

來源:mindrally/skills位於machine-learning提交9718410

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架