Skip to contents

Stop gradient propagation through an mlx array

Usage

mlx_stop_gradient(x)

Arguments

x

An mlx array, or an R array/matrix/vector that will be converted via as_mlx().

Value

A new mlx array with identical values but zero gradient.

Examples

x <- as_mlx(matrix(1:4, 2, 2))
mlx_stop_gradient(x)
#> mlx array [2 x 2]
#>   dtype: float32
#>   device: gpu
#>   values:
#>      [,1] [,2]
#> [1,]    1    3
#> [2,]    2    4