scatter_mul
¶
scatter_mul(values: array, index: array, out_size: int) -> array
Computes the product of the values grouped by index (along axis 0).
Groups without any value are set to 1, as in PyG. MLX has no gradient for multiplicative scatters, so this function provides its own: the gradient of a value is the product of the other values of its group, which is also correct for groups containing zeros.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
array
|
Input array of shape |
required |
index
|
array
|
Array of shape |
required |
out_size
|
int
|
Number of groups. |
required |
Returns:
| Type | Description |
|---|---|
array
|
An array of shape |
Source code in mlx_graphs/utils/scatter.py
from mlx_graphs.utils.scatter import scatter_mul · mlx_graphs/utils/scatter.py