Description: Multi-backend recommender systems with Keras 3
View keras-team/keras-rs on GitHub ↗
Keras-rs is a Rust implementation of the Keras high-level neural networks API. It aims to provide a native Rust experience for building and training deep learning models, leveraging the performance and safety benefits of the Rust language while maintaining a familiar Keras-like interface. Unlike simply wrapping a Python Keras installation, keras-rs is a complete re-implementation, offering direct access to backends like TensorFlow, PyTorch, and potentially others in the future, without the Python dependency. This makes it suitable for deployment in environments where Python is undesirable or unavailable, such as embedded systems, WebAssembly, or performance-critical applications.
The core philosophy of keras-rs is to be *functional* and *composable*. Model building is done through a functional API, similar to Keras' functional API in Python, allowing for complex model architectures to be defined as pure functions. Layers are represented as Rust structs, and models are constructed by connecting these layers. This approach promotes code clarity, testability, and easier debugging. The project emphasizes a strong type system, catching potential errors at compile time rather than runtime, a key advantage of Rust. It also focuses on providing a consistent and intuitive API for users familiar with Keras in Python, minimizing the learning curve.
Currently, keras-rs supports a growing number of common Keras layers, including Dense, Conv2D, MaxPooling2D, Flatten, Activation, and more. It also includes support for common optimizers like Adam and SGD, and loss functions such as categorical cross-entropy and mean squared error. The backend integration with TensorFlow is relatively mature, allowing keras-rs models to be trained and evaluated using TensorFlow's computational graph and hardware acceleration (CPU, GPU, TPU). PyTorch backend support is also available, though still under active development and may have some limitations compared to the TensorFlow backend. The project is actively working on expanding backend support to include other deep learning frameworks.
A significant feature is the ability to export models to ONNX (Open Neural Network Exchange) format. This allows keras-rs models to be deployed and run using a variety of inference engines and hardware platforms, further enhancing its portability. The repository includes examples demonstrating model building, training, evaluation, and ONNX export. These examples cover common tasks like image classification (using MNIST and CIFAR-10 datasets) and text classification. The documentation, while still evolving, provides a good starting point for understanding the API and getting started with keras-rs.
The project is still under active development, and the API is subject to change. However, it represents a promising effort to bring the power and flexibility of Keras to the Rust ecosystem. Contributions are welcome, and the developers are actively seeking feedback from the community. Keras-rs is a good choice for developers who want to build and deploy deep learning models in Rust, benefiting from its performance, safety, and portability, while leveraging a familiar Keras-like API. The roadmap includes expanding layer support, improving backend integration, and enhancing documentation and tooling.
Fetching additional details & charts...