贾克斯

人工智能 社区

技能解读

当前原文的自动摘译,尚未人工审校。

内容

概念与理论 不变性 4 种转换 Pytrees 代码示例

1. 开发新模型

将参数定义为 Pytree(字典/数据类)。定义您的前向传递函数(纯)。定义你的损失函数。使用 jax.value_and_grad 获取渐变。使用jax.jit加快更新步骤。

2. 调试形状/NaN

禁用 JIT:jax.config.update("jax_disable_jit", True) 以使用标准 python 工具进行调试。在 JITted 函数中使用 jax.debug.print。

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
人工智能
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
88 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@diegosouzapw · 未声明许可证
上下文用量评级
低消耗
接入复杂程度
即装即用
是否需要外部接口密钥
不需要
兼容的系统
未声明(默认跨平台)
运行环境要求
Python
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
网络行为
仅限本地
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) SKILL.md
# JAX Skill

JAX is Autograd and XLA, brought together for high-performance machine learning research.

## Contents

- [Concepts & Theory](reference.md)
  - Immutability
  - The 4 Transformations
  - Pytrees
- [Code Examples](examples.md)
  - `jit`, `grad`, `vmap`, `random` usage
  - Control Flow (`scan`, `cond`, `fori_loop`)
  - Parallelism (`sharding`)

## Common Workflows

### 1. Developing a new Model
1.  Define your parameters as a Pytree (dict/dataclass).
2.  Define your forward pass function (pure).
3.  Define your loss function.
4.  Use `jax.value_and_grad` to get gradients.
5.  Use `jax.jit` to speed up the update step.
6.  See [examples.md](examples.md) for snippets.

### 2. Debugging Shapes/NaNs
1.  Disable JIT: `jax.config.update("jax_disable_jit", True)` to debug with standard python tools.
2.  Use `jax.debug.print` inside JITted functions.

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。