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.

build_windows

chronax.models.dlinear.dlinear_training.build_windows

Rolling training windows with neuralforecast-style right-padding.

Right-pads y with h zeros before unfolding (NF padder_train = ConstantPad1d((0, h))), yielding len(y) - input_size windows of length input_size + h — including ~h partial-horizon windows whose context reaches the end of the series. Returns (windows, mask) where mask is 1 on real points and 0 on the padded tail, so the loss can drop padded horizon steps. The insample (first input_size) of every window is fully real. Returns shape [n_windows, input_size+h] each.

build_windows(y, input_size, h)

Parameter Type Default Description
y jnp.ndarray - (undocumented)
input_size int - (undocumented)
h int - (undocumented)

Returns: tuple[jnp.ndarray, jnp.ndarray] Raises: ValueError

scaled_forward_loss

chronax.models.dlinear.dlinear_training.scaled_forward_loss

Forward + masked point loss in SCALED space. windows/mask: [B, input_size+h] -> scalar.

The insample is always real (padding is target-side only), so the scaler sees real values. Padded horizon steps are excluded via the outsample mask.

scaled_forward_loss(model, windows, mask, *, h, input_size, scaler, loss_fn=mae)

Parameter Type Default Description
model DLinearNet - (undocumented)
windows jnp.ndarray - (undocumented)
mask jnp.ndarray - (undocumented)
h int - (undocumented)
input_size int - (undocumented)
scaler Scaler - (undocumented)
loss_fn LossFn mae (undocumented)

Returns: jnp.ndarray

train

chronax.models.dlinear.dlinear_training.train

Train model in place via a single nnx.scan. Returns per-step losses.

Single nnx.scan (carry = (model, optimizer)) keeps train() vmap-traceable for BaseForecaster.conformity_scores. Window sampling replicates neuralforecast's regime-dependent scheme (with-replacement when n_windows < windows_batch_size, else a permutation). The scan iterates an int32 index tensor and gathers windows in-step (avoids materializing a large float32 batch tensor).

train(model, y, *, h, input_size, max_steps, windows_batch_size, lr, seed, scaler, loss_fn=mae)

Parameter Type Default Description
model DLinearNet - (undocumented)
y jnp.ndarray - (undocumented)
h int - (undocumented)
input_size int - (undocumented)
max_steps int - (undocumented)
windows_batch_size int - (undocumented)
lr optax.ScalarOrSchedule - (undocumented)
seed int - (undocumented)
scaler Scaler - (undocumented)
loss_fn LossFn mae (undocumented)

Returns: jnp.ndarray (per-step losses.) Raises: RuntimeError

predict_step

chronax.models.dlinear.dlinear_training.predict_step

Forecast next h steps from the final input_size of y, inverse-scaled. Returns (h,).

predict_step(model, y, *, h, input_size, scaler)

Parameter Type Default Description
model DLinearNet - (undocumented)
y jnp.ndarray - (undocumented)
h int - (undocumented)
input_size int - (undocumented)
scaler Scaler - (undocumented)

Returns: jnp.ndarray