tidy3d.plugins.autograd.optimizers.Adam

tidy3d.plugins.autograd.optimizers.Adam#

class Adam[source]#

Bases: Tidy3dBaseModel

Adam optimizer (optax-compatible interface).

Parameters:
  • learning_rate (float) – Step size for the parameter updates.

  • beta1 (float = 0.9) – Exponential decay rate for the first moment estimate.

  • beta2 (float = 0.999) – Exponential decay rate for the second moment estimate.

  • eps (float = 1e-8) – Small constant for numerical stability.

  • mapping (Supports parameters as a single np.ndarray or a dict)

  • arrays/scalars. (string keys to)

  • learning_rate – Step size for the parameter updates.

  • beta1 – Exponential decay rate for the first moment estimate.

  • beta2 – Exponential decay rate for the second moment estimate.

  • eps – Small constant for numerical stability.

Example

>>> opt = adam(learning_rate=0.01)  
>>> state = opt.init(params)  
>>> for step in range(100):  
...     val, grad = value_and_grad(obj_fn)(params)
...     updates, state = opt.update(grad, state, params)
...     params = apply_updates(params, updates)

Attributes

Methods

init(params)

Create the initial optimizer state.

update(grads, state[, params])

Compute parameter updates from gradients (optax-compatible).

learning_rate#
beta1#
beta2#
eps#
init(params)[source]#

Create the initial optimizer state.

Parameters:

params (np.ndarray or dict) – Initial parameters (array or dict of arrays), used to determine the shape of moment estimates.

Returns:

Initial optimizer state with keys "m", "v", and "t".

Return type:

dict

update(grads, state, params=None)[source]#

Compute parameter updates from gradients (optax-compatible).

Parameters:
  • grads (np.ndarray or dict) – Gradient of the objective with respect to parameters.

  • state (dict) – Current optimizer state.

  • params (np.ndarray or dict, optional) – Current parameters (unused by Adam, accepted for API compatibility).

Returns:

(updates, new_state) where updates is the additive delta to apply via apply_updates().

Return type:

tuple