Skip to contents

When retrieving an optimizer, the map first attempts an exact key match. If no exact match is found, it treats every key as a regular-expression pattern and performs a full match against the variable path. For example, "encoder" matches only the layer with that exact path; use "encoder/.*" to match its sublayers. Exact matches take precedence. If more than one regular expression matches, lookup raises an error. Variables not matched by the map use default_optimizer.

Usage

optimizer_map(default_optimizer, optimizer_map = NULL)

Arguments

default_optimizer

Keras optimizer used for unmatched variables.

optimizer_map

Optional named list mapping exact variable paths or regular expressions to optimizer instances.

Value

An OptimizerMap instance.

Examples

optimizers <- optimizer_map(
  default_optimizer = optimizer_sgd(),
  optimizer_map = list("encoder/.*" = optimizer_adam())
)