liveBook · Manning

Keras

As explained in Distributed Machine Learning Patterns

Keras is a high-level deep-learning API for defining, training, evaluating, and exporting neural-network models, commonly used through TensorFlow as tf.keras.

Keras is TensorFlow’s high-level API for defining, training, evaluating, and saving neural-network models. It turns a prepared dataset into an executable model workflow. section 8.1.1

A typical Keras workflow:

  • Load MNIST through tf.keras.datasets and inspect its NumPy arrays. section 8.1.1
  • Normalize pixel values from 0–255 to 0–1. section 8.1.1
  • Define a Sequential network with Flatten, Dense, and Dropout layers. section 8.1.1
  • Compile with an optimizer, loss function, and accuracy metric, then fit and evaluate it. section 8.1.1
  • Save the trained model and reload it for later use. section 8.1.1

MNIST classifier

A compact model flattens 28×28 images, applies a 128-unit ReLU layer and dropout, then predicts ten digit classes with softmax. Five epochs reach about 97.9% test accuracy. section 8.1.1

Listing 8.8 The sequential model definition
model = tf.keras.models.Sequential([
 tf.keras.layers.Flatten(input_shape=(28, 28)),
 tf.keras.layers.Dense(128, activation='relu'),
 tf.keras.layers.Dropout(0.2),
 tf.keras.layers.Dense(10, activation='softmax')
])

Inspect the concrete Sequential architecture used for the image classifier. section 8.1.1

How Distributed Machine Learning Patterns covers it

How deep it goes
Defines layers, compilation, fitting, evaluation, saving, and tuning, but does not descend into TensorFlow internals.
Examples
Demonstrates normalized MNIST images, a Sequential classifier, model persistence, and Keras Tuner Hyperband with early stopping.
What it assumes
Assumes a Python environment and NumPy familiarity while demonstrating dataset arrays and preprocessing directly.
What you can do after
Build it from scratch: create, train, evaluate, save, reload, and tune a TensorFlow neural-network model.
How it connects
Connects TensorFlow, NumPy arrays, MNIST, neural-network layers, model evaluation, and hyperparameter tuning.

Also explained in

Compare how 6 books explain Keras →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Distributed Machine Learning Patterns. The section links point to the parts of the book it draws on.