liveBook · Manning

Backend

As explained in Deep Learning with Python, Third Edition

The underlying execution framework that a machine-learning library can target to run models.

A backend is the low-level execution framework beneath Keras. It supplies tensor operations, gradients, and hardware access while Keras provides the higher-level model and training APIs. section 3.6.1 section 3.2

Selecting a Keras backend

Choose the backend before importing Keras. For example, this selects JAX for the current Python process: import os os.environ["KERAS_BACKEND"] = "jax" import keras You can also edit ~/.keras/keras.json. Use "torch" for the PyTorch backend, not "pytorch". A fresh Keras environment uses TensorFlow by default. section 3.6.1

Use these practical rules when choosing or changing a backend:

  • Switch among JAX, TensorFlow, and PyTorch without locking Keras code to one ecosystem. section 3.6.1
  • Match the backend to the task: debugging, TPU training, or inference tooling can favor different ecosystems. section 3.6.1
  • Treat NumPy differently: it supports Keras predictions but cannot support training because it provides no gradient API. section 3.2
Figure 3.4 Keras and its backends. A backend is a low-level tensor-computing platform; Keras is a high-level deep learning API.
keras and backends

Use the diagram to distinguish Keras’s high-level API from the low-level tensor-computing platform supplied by its backend. section 3.6.1

How Deep Learning with Python, Third Edition covers it

How deep it goes
Explains backend selection, portability, tensor operations, and gradients, while stopping short of framework-specific implementation details.
Examples
Uses KERAS_BACKEND, ~/.keras/keras.json, JAX selection, and NumPy’s prediction-only limitation as concrete examples.
What it assumes
Assumes familiarity with Keras at a basic level while distinguishing its high-level APIs from backend-provided tensors and gradients.
What you can do after
Operate/configure Keras by selecting a backend before import and matching it to debugging, training, or inference needs.
How it connects
Connects Keras with TensorFlow, PyTorch, JAX, NumPy, tensors, gradients, hardware, and training loops.

Also explained in

Compare how 4 books explain backend →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with Python, Third Edition. The section links point to the parts of the book it draws on.