liveBook · Manning

Search space

As explained in Deep Learning with R, Third Edition

A search space is the set of allowed values or choices for the hyperparameters being optimized.

A search space is the set of allowed values or choices for the hyperparameters being optimized. It replaces fixed settings, such as units = 32, with ranges or alternatives that a tuner can test. section 18.1.1

A small KerasTuner search space

A model can search for between 16 and 64 dense-layer units in steps of 16, while choosing either the rmsprop or adam optimizer. These choices form a two-part search space. section 18.1.1

Listing 18.1 KerasTuner model-building function
build_model <- function(hp, num_classes = 10) {
  units  <- hp$Int(  #1
    name = "units",  #1
    min_value = 16L,  #1
    max_value = 64L,  #1
    step = 16L)  #1
  model  <- keras_model_sequential() |> #1
    layer_dense(units, activation = "relu") |>
    layer_dense(num_classes, activation = "softmax")

  optimizer <- hp$Choice(name = "optimizer", #2
                         values = c("rmsprop", "adam")) 
  model |> compile(optimizer = optimizer,
                   loss = "sparse_categorical_crossentropy",
                   metrics = "accuracy")
  model  #3
}

See the complete R model-building function that declares the integer and categorical hyperparameters. section 18.1.1

A tuner uses the search space to:

How Deep Learning with R, Third Edition covers it

How deep it goes
Defines ranges and choices, then demonstrates their declaration in a model-building function; it stops short of formal search-space theory.
Examples
Uses dense-layer units ranging from 16 to 64 and an optimizer choice between rmsprop and adam.
What it assumes
Assumes familiarity with model hyperparameters and compiled Keras models while explaining search-space declaration directly.
What you can do after
Apply it via KerasTuner by declaring tunable integer and categorical hyperparameters in a model-building function.
How it connects
Connects hyperparameters with model-building functions, tuners, Bayesian optimization, and validation metrics.

Also explained in

Compare how 11 books explain search space →

Related concepts

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