Esc
Ask AIAnswers may be inaccurate; check the linked pages.Esc
Ask anything about these docs, like how to get started or what a function does.

chronax.gru_losses

Pluggable point-loss functions for the GRU forecaster.

Each loss has signature (pred, target) -> scalar and reduces by mean over all elements. Functions are module-level so they pickle cleanly when stored as the loss attribute of a fitted chronax.models.gru.GRU.

The LOSSES mapping is the canonical string-to-callable registry used by GRU(loss="mae" | "mse" | "huber"). Callers wanting a non-default Huber threshold (or any other loss) should pass a callable directly to GRU(loss=...) instead of a string.

mae

chronax.gru_losses.mae

Mean absolute error: mean(|pred - target|).

mae(pred, target)

Parameter Type Default Description
pred jnp.ndarray - (undocumented)
target jnp.ndarray - (undocumented)

Returns: jnp.ndarray

mse

chronax.gru_losses.mse

Mean squared error: mean((pred - target)**2).

mse(pred, target)

Parameter Type Default Description
pred jnp.ndarray - (undocumented)
target jnp.ndarray - (undocumented)

Returns: jnp.ndarray

huber

chronax.gru_losses.huber

Huber loss with delta = 1.0 (the conventional default).

Quadratic for residuals with |r| <= 1, linear outside. Smooth at the transition, so gradients are well-behaved everywhere.

huber(pred, target)

Parameter Type Default Description
pred jnp.ndarray - (undocumented)
target jnp.ndarray - (undocumented)

Returns: jnp.ndarray

LOSSES

chronax.gru_losses.LOSSES

The canonical string-to-callable registry used by GRU(loss="mae" | "mse" | "huber").

Type: Mapping[str, LossFn] Value: {'mae': mae, 'mse': mse, 'huber': huber}

resolve

chronax.gru_losses.resolve

Return a callable loss from either a registry string or a callable.

resolve(loss)

Parameter Type Default Description
loss str | LossFn - (undocumented)

Returns: LossFn Raises: ValueError for unknown strings, naming the registered options.