Computes `model_params` updates from `update`. Args: updates: The updates to potentially transform and then apply. Returns: The updated model parameters. The learner state updates will be placed in the output collection's 'state_update' section.
(self, updates: Updates)
| 243 | cfg = self.config |
| 244 | return jax.tree.map( |
| 245 | lambda path: match_regex_rules( |
| 246 | path, rules=cfg.update_rules, default_value=UpdateType.ALL_UPDATES |
| 247 | ), |
| 248 | tree_paths(tree), |
| 249 | ) |
| 250 | |
| 251 | def should_update_with_optimizers(self, model_params: Nested[OptParam]) -> dict: |
| 252 | """Returns whether each parameter should be updated with the optimizers. |
| 253 | |
| 254 | Args: |
| 255 | model_params: A nested structure with OptParams as leaf nodes. |
| 256 | |
| 257 | Returns: |
| 258 | A nested dict with the same structure as `model_params` with boolean leaf values. |
| 259 | """ |
| 260 | return jax.tree.map(should_update_with_optimizers, self._update_types(model_params)) |
| 261 | |
| 262 | def handles_undefined_loss(self) -> bool: |
| 263 | return self.config.ignore_undefined_loss |
| 264 | |
| 265 | def update(self, updates: Updates) -> Nested[Tensor]: |
| 266 | """Computes `model_params` updates from `update`. |
| 267 |