jax.lax.scatter_apply#
- jax.lax.scatter_apply(operand, scatter_indices, func, dimension_numbers, *, update_shape=(), indices_are_sorted=False, unique_indices=False, mode=None)[源代码][源代码]#
分散-应用操作符。
封装了 XLA 的 Scatter 操作符,其中
operand的值被func(operand)替换,具有重复索引的值会导致func的多次应用。scatter 的语义很复杂,其 API 可能在将来发生变化。对于大多数用例,您应该首选 JAX 数组上的
jax.numpy.ndarray.at属性,它使用熟悉的 NumPy 索引语法。请注意,在当前的实现中,
scatter_apply与自动微分不兼容。- 参数:
operand (Array) – 一个应应用散点的数组
scatter_indices (Array) – 一个数组,给出 operand 中每个 updates 应应用的索引。
dimension_numbers (ScatterDimensionNumbers) – 一个 lax.ScatterDimensionNumbers 对象,描述了 operand、start_indices、updates 和输出维度之间的关系。
update_shape (Shape) – 在给定索引处的更新形状。
indices_are_sorted (bool) – scatter_indices 是否已知为排序。如果是,可能会在某些后端提高性能。
unique_indices (bool) –
operand中要更新的元素是否保证不相互重叠。如果为真,可能会在某些后端提高性能。JAX 不会检查这一承诺:如果unique_indices为True时更新的元素重叠,行为是未定义的。mode (str | GatherScatterMode | None) – 如何处理越界索引:当设置为 ‘clip’ 时,索引会被限制在边界内,使得切片在边界内;当设置为 ‘fill’ 或 ‘drop’ 时,越界的更新会被丢弃。当设置为 ‘promise_in_bounds’ 时,越界索引的行为是实现定义的。
- 返回:
包含将 func 应用于给定索引处的 operand 的结果的数组。
- 返回类型: