MCPcopy Create free account
hub / github.com/apple/axlearn / update

Method update

axlearn/common/learner.py:245–264  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 15

forward_and_backwardMethod · 0.95
test_wrap_functionMethod · 0.45
mainFunction · 0.45
_build_spm_configFunction · 0.45
named_trainer_configsFunction · 0.45
get_trainer_kwargsFunction · 0.45
named_trainer_configsFunction · 0.45
get_trainer_kwargsFunction · 0.45
get_trainer_kwargsFunction · 0.45
_update_block_argsMethod · 0.45
named_model_configsFunction · 0.45
_expected_data_shapeMethod · 0.45

Calls 3

replaceMethod · 0.80