8news

Tech • AI • Robotics

VIDEO
ENFR
TodayShortsTop StoriesYour topicFor youTopicsAll videosYT channelsArchivesSearchFavorites

Introducing Keras Recommenders: state-of-the-art recommendation techniques at your fingertips

8/10
GoogleGoogle for DevelopersApril 28, 2026 at 11:00 PM6:35
Audio player
0:00 / 0:00

TL;DR

The recent integration of Keras with the modular Flax and NNX system opens new possibilities, combining Keras’s simplicity with the power and flexibility of JAX for advanced variable management and custom training.

KEY POINTS

Interoperability between Keras, Flax, and NNX

The new linkage makes keras.Variable an instance of nnx.Variable, enabling seamless coexistence of state between Keras and NNX. This compatibility makes it easy to mix components from both ecosystems without breaking variable management.

Activation via environment variables

To use this integration, two environment variables must be set before importing Keras: define the backend as JAX and explicitly enable NNX mode. This ensures Keras leverages the advanced capabilities of NNX and Flax.

Explicit variable management and tracking

The system allows verification that Keras variables are properly recognized and tracked by NNX: they appear in the managed variable list, have a trace state for just-in-time compilation, and can be accessed directly via NNX, improving control during training.

Modularity and simplified model definition

NNX provides a modular approach using standard Python classes, bringing native modularity into Keras through integration. For example, an NNX module can include linear layers, custom Keras variables, and manage their interaction within the model’s call method.

Two flexible training modes

The first mode follows the classic Keras approach: model.compile and model.fit work as usual, with NNX and JAX operating behind the scenes to optimize performance, without requiring code changes.

Custom training for greater control

The second mode enables custom training loops by treating a Keras model as an nnx.Module. This gives access to the broader JAX ecosystem, including Optax for optimizers, and nnx.jit and nnx.grad for efficient acceleration and differentiation.

Just-in-time compilation and acceleration

Using the nnx.jit decorator improves performance by compiling training functions on the fly, providing noticeable speed gains even for Keras models integrated with NNX.

Unifying rapid prototyping and advanced research

This synergy allows users to start easily with familiar Keras APIs while progressively accessing advanced research and optimization features from JAX, creating a unified framework for all skill levels.

Access to JAX libraries and extensibility

Integrated Keras models can fully leverage JAX tools like Optax, along with a wide range of statistical and differential functions, greatly extending possibilities beyond the traditional Keras framework.

Official resources available

A comprehensive guide and code examples are available on the keras.io website, offering a clear starting point to learn and experiment with this integration.

CONCLUSION

The integration of Keras with Flax and NNX transforms state management and training possibilities, combining ease of use with powerful customization in the JAX ecosystem. This bridge enables more flexible and high-performance machine learning development.

Explain this
Full transcript

More from Google