Skip to content

AdamConfig

from cascaqit import AdamConfig

AdamConfig

AdamConfig(
    learning_rate: float = 0.05,
    beta1: float = 0.9,
    beta2: float = 0.999,
    epsilon: float = 1e-08,
    stopping: AdamStoppingConfig | None = None,
    schema_version: str = ADAM_SCHEMA_VERSION,
)

Set the native Adam learning rate and momentum factors. learning_rate and epsilon must be finite and positive; beta1 and beta2 must lie strictly within (0, 1). Defaults are 0.05, 1e-8, 0.9 and 0.999 respectively. Updates use first/second moments with bias correction and are projected into bounds when bounds are configured.

stopping optionally supplies AdamStoppingConfig. This configuration does not select a gradient method: OptimizerConfig still requires method="ADAM" and GradientConfig. A small learning rate can produce small updates without establishing gradient or energy convergence.

from cascaqit import AdamConfig, OptimizerConfig
from cascaqit.algorithms import GradientConfig

adam = AdamConfig(learning_rate=0.03)
optimizer = OptimizerConfig(method="ADAM", max_iterations=4,
                            gradient=GradientConfig(), adam=adam, seed=7)
assert optimizer.adam.learning_rate == 0.03
assert AdamConfig.from_json(adam.to_json()) == adam
assert "stopping" not in adam.to_dict()

from_dict

from_dict(data: Mapping[str, Any]) -> AdamConfig

Restore AdamConfig from a dictionary. Omitted fields use defaults; nested configurations are restored and validated. Missing required fields or invalid values can raise KeyError, TypeError or ValueError.

from_json

from_json(text: str) -> AdamConfig

Parse a JSON object and call from_dict(), returning AdamConfig. Invalid JSON raises a parsing error; a non-object root raises TypeError.

to_dict

to_dict() -> dict[str, Any]

The stopping field is omitted when None. Return a JSON-compatible dictionary, serializing nested objects and converting tuples to arrays. This stores the declaration, not an execution result.

to_json

to_json(*, indent: int | None = None) -> str

Return a JSON string without writing a file. indent=None uses compact formatting; supply an indentation width for readable output.

stable_hash

stable_hash() -> str

Return the SHA-256 hex digest of canonical JSON. Fields, identifiers and metadata can affect it. Use it to compare saved content, not to decide physical equivalence.