Create a learnable linear transformation
Usage
mlx_linear(
in_features,
out_features,
bias = TRUE,
device = mlx_default_device()
)Arguments
- in_features
Number of input features.
- out_features
Number of output features.
- bias
Should a bias term be included?
- device
Execution target: supply
"gpu","cpu", or anmlx_streamcreated viamlx_new_stream(). Defaults to the currentmlx_default_device()unless noted otherwise (helpers that act on an existing array typically reuse that array's device or stream).
Examples
set.seed(1)
layer <- mlx_linear(3, 2)
x <- mlx_matrix(1:6, 2, 3)
mlx_forward(layer, x)
#> mlx array [2 x 2]
#> dtype: float32
#> device: gpu
#> values:
#> [,1] [,2]
#> [1,] -3.473105 -1.2398810
#> [2,] -4.516946 -0.3382074