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
HWIOkernel, and a bias (flax.linen.Conv). - Dense
- A fully connected layer,
x @ kernel + bias(flax.linen.Dense). - Exported
Model - 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 withjax.export(ExternFn, called with the parameters and then the other arguments, with XLA). - Layer
Norm - 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§
- Model
Error - An error from loading an
ExportedModel. - Weights
Error - 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). Withcount_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 forNone). - min_
pool - The minimum over windows (
flax.linen.min_pool); seemax_pool. - relu
max(x, 0)(flax.linen.relu,jax.nn.relu).- tanh
- Hyperbolic tangent.