MCPcopy Create free account
hub / github.com/ml-explore/mlx / update

Method update

python/mlx/optimizers/optimizers.py:20–29  ·  view source on GitHub ↗

Apply the gradients to the parameters of the model and update the model with the new parameters. Args: model (mlx.nn.Module): An mlx module to be updated. gradients (dict): A Python tree of gradients, most likely computed via :fu

(self, model: Module, gradients: dict)

Source from the content-addressed store, hash-verified

18 self._schedulers = {k: v for k, v in (schedulers or {}).items()}
19
20 def update(self, model: Module, gradients: dict):
21 """Apply the gradients to the parameters of the model and update the
22 model with the new parameters.
23
24 Args:
25 model (mlx.nn.Module): An mlx module to be updated.
26 gradients (dict): A Python tree of gradients, most likely computed
27 via :func:`mlx.nn.value_and_grad`.
28 """
29 model.update(self.apply_gradients(gradients, model))
30
31 def init(self, parameters: dict):
32 """Initialize the optimizer's state

Callers

nothing calls this directly

Calls 1

apply_gradientsMethod · 0.95

Tested by

no test coverage detected