Repolode
google

google/flax

A neural network library for JAX focused on flexibility, offering the Flax NNX API for building, inspecting and debugging models.

Stars
7,366
Forks
849
Open issues
526
Last commit
22 hours ago

What is it?

Flax is a neural network library and ecosystem built on JAX. Its newer Flax NNX API lets developers define models with regular Python objects that support reference sharing and mutability, which makes networks easier to create, inspect, debug and analyze. The older Flax Linen API, released in 2020, is the predecessor from which NNX evolved.

The library provides common layers such as Linear, Conv, BatchNorm, LayerNorm, GroupNorm, multi-head attention, LSTM and GRU cells, and Dropout. It also includes utilities for replicated training, serialization and checkpointing, metrics, and prefetching data to devices. Examples cover MNIST and inference with the Gemma language model.

Flax is designed so that users modify the training loop directly, rather than relying on added framework features. Installation is available from PyPI, and Python 3.8 or later is required.

Key features

  • 01Flax NNX API that uses regular Python objects with reference sharing and mutability
  • 02Built-in layers including Linear, Conv, normalization layers, attention, recurrent cells and Dropout
  • 03Utilities for replicated training, checkpointing, metrics and device prefetching
  • 04Examples for MNIST and Gemma language model inference
  • 05Installable from PyPI on top of JAX

Use cases

  • Researching and prototyping new neural network architectures in JAX
  • Writing custom training loops for experiments without framework constraints
  • Training models on CPUs, GPUs or TPUs through JAX
  • Learning JAX-based deep learning with the MNIST and Gemma examples

Quick start

  1. 1

    Install JAX first using the official JAX installation instructions for your hardware

  2. 2

    Install Flax from PyPI

    pip install flax

Things to know

  • Flax depends on JAX, so you must also install and configure JAX for your hardware.

Topics

FAQ

What is flax?
A neural network library for JAX focused on flexibility, offering the Flax NNX API for building, inspecting and debugging models. Flax is a neural network library and ecosystem built on JAX. Its newer Flax NNX API lets developers define models with regular Python objects that support reference sharing and mutability, which makes networks easier to create, inspect, debug and analyze. The older Flax Linen API, released in 2020, is the predecessor from which NNX evolved.
Is flax free to use? What license does it have?
flax is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is flax still maintained?
Actively maintained. The last commit to flax was on Nov 7, 2026.
What can I use flax for?
Researching and prototyping new neural network architectures in JAX Writing custom training loops for experiments without framework constraints Training models on CPUs, GPUs or TPUs through JAX Learning JAX-based deep learning with the MNIST and Gemma examples
How do I install flax?
Install JAX first using the official JAX installation instructions for your hardware Install Flax from PyPI: pip install flax
Where can I get flax?
The source code and installation instructions are on GitHub: https://github.com/google/flax

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects