tfl.configs.apply_updates

View source on GitHub

Updates a model config with the given set of (key, values) updates.

Any value passed in the updates that matches a field of the config will be applied to the config. Nested configs can be updated as follows: to add/update a field FIELD in feature config for feature FEATURE, use feature__FEATURE__FIELD as the key. To add/update a field FIELD for regularizer with name REGULARIZER use regularizer__REGULARIZER__FIELD as the key. This naming scheme can be nested. When possible, string values will be converted to the corresponding value type in the model config.

Example:

model_config = ...
updates = [
    ('output_max', 1),
    ('regularizer__torsion__l1', 0.001),
    ('feature__some_feature_name__lattice_size', 4),
    ('feature__some_feature_name__regularizer__calib_hessian__l2', 0.001),
    ('unrelated_haparam_not_affecting_model_config', 42),
]
configs.apply_updates(model_config, updates)

model_config The model config object to apply the updates to.
updates A list of (key, value) pairs with potential config updates. Values that are not matched to a field in the model config will be ignored.

Number of updates that are applied to the model config.