Skip to main content

Crate ruxla_nn

Crate ruxla_nn 

Source
Expand description

Neural network layers, initializers, optimizers, and weight loading.

The layers follow flax.linen, so that a model trained in JAX can be written again in Rust, load its weights (Weights), and run natively or with XLA, with the same results and, when traced, the same IR as Flax.

Modules§

init
Initializers with the definitions of jax.nn.initializers, computed natively (initialization runs once, so it is not traced).
optim
Optimizers with the computations of Optax’s: gradient transformations that are chained, applied to the gradient, and whose result is added to the parameters.

Structs§

Conv
A convolution of channels-last inputs with an HWIO kernel, and a bias (flax.linen.Conv).
Dense
A fully connected layer, x @ kernel + bias (flax.linen.Dense).
ExportedModel
A JAX model written by ruxla.export_model(fn, params, *args, path=...): its parameters (Weights, for Rust layers written like the model) and the function exported with jax.export (ExternFn, called with the parameters and then the other arguments, with XLA).
LayerNorm
Layer normalization over the last dimension, with a learned scale and bias (flax.linen.LayerNorm).
Weights
Named weights, such as the parameters of a Flax model with names like params/Dense_0/kernel (the keys of the parameter tree joined by /).

Enums§

ModelError
An error from loading an ExportedModel.
WeightsError
An error from loading weights.

Functions§

avg_pool
The average over windows of the spatial dimensions of an input (*batch, spatial..., features) (flax.linen.avg_pool). With count_include_pad, padding counts as zeros; otherwise each window is divided by the number of elements it covers.
max_pool
The maximum over windows of the spatial dimensions of an input (*batch, spatial..., features) (flax.linen.max_pool; strides of 1 for None).
min_pool
The minimum over windows (flax.linen.min_pool); see max_pool.
relu
max(x, 0) (flax.linen.relu, jax.nn.relu).
tanh
Hyperbolic tangent.