引導式測驗 · 硬 等級

機器學習的 JAX 與 XLA 測驗

將 JAX 轉換連接到自動微分、向量化、編譯和並行執行,同時考慮追蹤行為。

相關引導路徑機器學習的 Jax 與 Xla
預覽每個問題8 問題

當您參加測驗時,就會出現答案和解釋。

  1. 哪一個 JAX 轉換計算可微函數的梯度?
    • jax.vmap
    • jax.jit
    • jax.grad
    • jax.device_put
  2. jax.vmap 提供什麼?
    • 即時編譯
    • 映射軸上的自動向量化
    • 自動微分
    • 顯式隨機密鑰分割
  3. jax.jit 扮演什麼角色?
    • 計算標量目標的梯度
    • 跨批次向量化函數
    • 將陣列放置在選定的設備上
    • Compiles a compatible function for efficient execution through XLA
  4. Why can a Python if statement fail inside a jitted function when its condition uses an array value?
    • Tracing cannot use a runtime array value as an ordinary Python boolean
    • Python evaluates every array-dependent if during tracing
    • An array value always converts to a Python bool inside jit
    • The compiled function specializes on runtime values automatically
  5. How does explicit random-key passing fit JAX's programming style?
    • It stores one hidden global generator
    • It removes random variation from training
    • It makes randomness an explicit input to computations
    • It fixes package versions
  6. Why may changing input shapes cause additional JAX compilation?
    • The model must retrain for each input
    • Compilation can specialize to shapes and static arguments
    • XLA discards the previous dataset
    • Gradients cannot use arrays
  7. What should be done when timing asynchronous device execution?
    • Measure only Python dispatch time
    • Skip warmup for compiled functions
    • Change the random seed during timing
    • Synchronize the result before stopping the timer
  8. Which statement about JAX versus PyTorch is sound?
    • Choose based on workload, ecosystem and team needs
    • JAX is always faster for every model
    • PyTorch cannot run on accelerators
    • The frameworks have identical APIs