liveBook · Manning

KerasTuner

As explained in Distributed Machine Learning Patterns

Keras Tuner is a library for searching and selecting hyperparameter configurations for Keras models.

KerasTuner searches hyperparameter configurations for Keras models instead of training only one fixed configuration. A model-building function exposes tunable choices such as layer width and learning rate. section 8.1.1

A Hyperband tuner evaluates validation accuracy, allocates training resources adaptively, and can stop weak runs early. EarlyStopping further halts training when validation loss stops improving. section 8.1.1

MNIST model search

Define an integer search from 32 to 512 units and choose the Adam learning rate from 0.01, 0.001, or 0.0001. Search with Hyperband, select the best configuration, rebuild the model, train it, and evaluate it on test data. section 8.1.1

Listing 8.16 The Hyperband model tuner
tuner = kt.Hyperband(model_builder,
                    objective='val_accuracy',
                    max_epochs=10,
                    factor=3,
                    directory='my_dir',
                    project_name='intro_to_kt')

Shows the Hyperband tuner configured with an objective, epoch limit, reduction factor, and project storage directory. section 8.1.1

How Distributed Machine Learning Patterns covers it

How deep it goes
Explains installation, model construction, tuner configuration, search, selection, retraining, and evaluation without detailing tuner internals.
Examples
Demonstrates MNIST tuning with dense-layer width, Adam learning rate, Hyperband, validation splitting, and test-set evaluation.
What it assumes
Assumes familiarity with TensorFlow Keras models and training, while teaching hyperparameter tuning from a single fixed configuration.
What you can do after
Apply KerasTuner to define a search space, run Hyperband, retrieve the best hyperparameters, retrain, and evaluate a model.
How it connects
Connects hyperparameter search to TensorFlow, Keras model builders, Hyperband, validation accuracy, and early stopping.

Also explained in

Compare how 3 books explain KerasTuner →

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.