build_windows
xlinear_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.
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | (undocumented) |
input_size |
int |
- | (undocumented) |
h |
int |
- | (undocumented) |
Returns: tuple[jnp.ndarray, jnp.ndarray]
scaled_forward_loss
xlinear_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.
| Parameter | Type | Default | Description |
|---|---|---|---|
model |
XLinearNet |
- | (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
xlinear_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).
| Parameter | Type | Default | Description |
|---|---|---|---|
model |
XLinearNet |
- | (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
xlinear_training.predict_step
Forecast next h steps from the final input_size of y, inverse-scaled. Returns (h,).
| Parameter | Type | Default | Description |
|---|---|---|---|
model |
XLinearNet |
- | (undocumented) |
y |
jnp.ndarray |
- | (undocumented) |
h |
int |
- | (undocumented) |
input_size |
int |
- | (undocumented) |
scaler |
Scaler |
- | (undocumented) |
Returns: jnp.ndarray