0 XP
Lv 1 — Layer Novice

Track 1: Why Keras Exists and Why It Matters

Understand Keras's origin, philosophy, and the multi-backend revolution that makes Keras 3 unique.

The Origin Story

François Chollet created Keras in March 2015 while working at Google. His vision was radical for the time: deep learning should be accessible to everyone, not just PhD researchers with years of framework experience.

Before Keras, building a neural network required extensive boilerplate code — configuring computation graphs, manually managing sessions, and wrestling with low-level tensor operations. Chollet saw this as an unnecessary barrier and set out to create an API that was "designed for human beings, not machines."

His guiding principle: "Being able to go from idea to result with the least possible delay is key to doing good research." This idea — that developer experience is a research accelerator, not a luxury — became the foundation of Keras's design philosophy.

Keras Philosophy

Keras is built on four core principles that have guided its development for a decade:

  • User-friendliness — Designed for humans, not machines. The API minimizes the number of user actions required for common use cases and provides clear error messages. As Chollet puts it: "Keras follows best practices for reducing cognitive load."
  • Modularity — A model is a sequence or graph of standalone, fully configurable modules. Layers, optimizers, loss functions, and regularizers are all independent building blocks that can be combined with as few restrictions as possible.
  • Extensibility — New modules are easy to add (as new classes and functions), and existing modules provide ample examples. The ability to easily create new components makes Keras suitable for advanced research.
  • Minimalism — Just enough to get the job done, no more. Each module is kept small and simple. Source code is readable. No unnecessary complexity lurking beneath the surface.

These principles explain why Keras consistently ranks as one of the most-loved ML frameworks in developer surveys. The API is predictable: once you learn the patterns, everything else follows logically.

The Journey

Keras has gone through three major eras:

Era 1: Standalone Library (2015–2017) — Keras started as an independent library that could run on top of Theano, TensorFlow, or CNTK. This multi-backend design was Keras's original superpower, letting researchers switch engines without changing code.

Era 2: TensorFlow Integration (2017–2023) — Keras was integrated into TensorFlow as tf.keras, becoming TF's official high-level API. This brought massive adoption but created tight coupling. Keras became synonymous with TensorFlow in many developers' minds, and running Keras on PyTorch or JAX wasn't possible.

Era 3: Keras 3 Multi-Backend Rewrite (2023–present) — Chollet and the team performed a complete rewrite, restoring the original multi-backend vision but at a much deeper level. Keras 3 runs on TensorFlow, PyTorch, JAX, and OpenVINO. The split back to standalone was necessary because TensorFlow coupling limited Keras's reach — researchers using PyTorch or JAX were locked out.

# Keras 3 — works on any backend
import keras
from keras import layers

# Same code runs on TF, PyTorch, or JAX
model = keras.Sequential([
    layers.Dense(128, activation="relu"),
    layers.Dense(10, activation="softmax"),
])

Keras 3's Breakthrough

One API, three backends: TensorFlow, PyTorch, and JAX (plus OpenVINO for inference-only). The latest stable version is Keras 3.11.3.

The breakthrough is the keras.ops namespace — a universal operation layer that implements the full NumPy API plus neural network-specific functions. When you write keras.ops.matmul(x, w), Keras dispatches the call to jax.numpy.matmul, tf.matmul, or torch.matmul depending on the active backend, producing numerically identical results.

"Backend-agnostic" in practice means:

  • Write your model once, train it on any framework
  • Save a model trained on JAX, load it in TensorFlow for deployment
  • Use PyTorch's ecosystem for research, then export for TF Serving in production
  • Every built-in Keras layer, metric, loss, and optimizer uses keras.ops internally — they're all portable
# keras.ops — the universal operation layer
import keras

# These work identically on TF, PyTorch, or JAX:
x = keras.ops.matmul(a, b)
y = keras.ops.nn.softmax(logits)
z = keras.ops.image.resize(img, size=(224, 224))
⚙️ Backend Note
Keras 3.8 added OpenVINO as an inference-only backend, meaning you can run model.predict() using Intel's optimized inference engine.

When to Choose Keras

Choose Keras when you need:

  • Rapid prototyping — Keras provides the fastest path from idea to working model. Build a CNN in 10 lines, not 100.
  • Education — The cleanest API for learning deep learning concepts. The code reads almost like pseudocode.
  • Production — Battle-tested at Google scale. Export to TF Serving, TFLite, ONNX, or OpenVINO.
  • Research flexibility — Multi-backend means you can train on JAX for speed, prototype on PyTorch for debugging, and deploy on TF for serving.

When NOT to choose Keras:

  • Extremely custom training loops that need raw framework-specific features (e.g., JAX's jax.pmap for fine-grained parallelism)
  • Tight integration with framework-specific tooling that doesn't have Keras equivalents
  • Projects already deeply embedded in a single framework's ecosystem

That said, Keras 3's subclassing API and custom training steps cover most "advanced" needs. You'll rarely hit Keras's ceiling before reaching production-grade results.

The Ecosystem

Keras is more than a single library — it's a full ecosystem of tools:

  • KerasCV — Computer vision: pretrained backbones, object detection (YOLOv8), segmentation, advanced augmentation (CutMix, MixUp, RandAugment)
  • KerasNLP → KerasHub — NLP and beyond. Renamed to KerasHub in September 2024 as a unified model hub. Access BERT, GPT-2, Gemma, Llama, Mistral with from_preset()
  • KerasTuner — Hyperparameter search with RandomSearch, BayesianOptimization, and Hyperband strategies
  • keras.io — Official site with hundreds of code examples, guides, and API documentation

Real-world users:

OrganizationUse Case
GoogleGemma model family, internal ML infrastructure
CERNLarge Hadron Collider particle physics research
NASAHeliophysics and space weather prediction
WaymoSelf-driving car perception models
YouTubeRecommendation systems

Installation & Setup

Getting started with Keras 3 is straightforward:

# Install Keras
pip install keras

# Install your preferred backend
pip install tensorflow    # TensorFlow backend
pip install jax jaxlib    # JAX backend
pip install torch         # PyTorch backend

Set your backend before importing Keras:

import os
os.environ["KERAS_BACKEND"] = "jax"  # Must be set BEFORE import keras
import keras

# Or check/set programmatically (Keras 3.5+):
keras.config.set_backend("torch")
print(keras.backend.backend())  # → "torch"
⚙️ Backend Note
The KERAS_BACKEND environment variable takes highest priority. You can also set it in your ~/.keras/keras.json config file. The default backend is TensorFlow.

🧠 Track 1 Quiz

Q1: What year was Keras first released?
A2013
B2015
C2017
D2019
François Chollet created Keras in March 2015 while at Google.
Q2: Which of these is NOT a Keras 3 backend?
ATensorFlow
BPyTorch
CJAX
DMXNet
Keras 3 supports TensorFlow, PyTorch, JAX, and OpenVINO (inference-only). MXNet is not supported.
Q3: What is keras.ops?
AA model optimization tool
BThe universal operation namespace for backend-agnostic code
CA deployment tool
DA data loading library
keras.ops implements the full NumPy API plus neural network functions, dispatched to whichever backend is active.
Q4: Who created Keras?
AYann LeCun
BAndrew Ng
CFrançois Chollet
DGeoffrey Hinton
François Chollet created Keras in 2015 while working at Google.
Q5: What's the recommended way to set the Keras backend?
AKERAS_BACKEND environment variable
BEditing source code
CUsing pip flags
DIt's automatic
Set KERAS_BACKEND before importing Keras. It takes the highest priority over config files.
Type to search across all tracks...