build_windows
chronax.models.tcn.tcn_training.build_windows
Rolling windows over y, right-padded with h zeros.
Padding keeps every window with at least one real target and lets the newest observations appear as training contexts; the padded tail is masked out of the loss (matters on trending series, where the most recent regime is the forecast-relevant one).
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] (windows [n, input_size+h], target_mask [n, h])
Raises: ValueError
build_exog_windows
chronax.models.tcn.tcn_training.build_exog_windows
Rolling windows of an exog array [T, F], right-padded with h zero rows to match build_windows (late windows see zeros in the padded tail of each exog channel).
build_exog_windows(arr, input_size, h, n_windows, span)
| Parameter | Type | Default | Description |
|---|---|---|---|
arr |
jnp.ndarray |
- | (undocumented) |
input_size |
int |
- | (undocumented) |
h |
int |
- | (undocumented) |
n_windows |
int |
- | (undocumented) |
span |
str |
- | span="input" -> [n, input_size, F] (encoder window); span="full" -> [n, input_size+h, F] (future-known spanning input + horizon). |
Returns: jnp.ndarray
forward_loss
chronax.models.tcn.tcn_training.forward_loss
Scale, forward, and reduce a point/quantile loss in scaled space.
forward_loss(net, y_windows, target_mask=None, *, h, input_size, scaler, loss_fn, futr_windows=None)
| Parameter | Type | Default | Description |
|---|---|---|---|
net |
- | - | (undocumented) |
y_windows |
- | - | (undocumented) |
target_mask |
- | None |
target_mask [B, h] marks real target positions (0 in the h-padded tail); the loss is the masked mean over valid elements. None means all-valid. |
h |
- | - | (undocumented) |
input_size |
- | - | (undocumented) |
scaler |
- | - | (undocumented) |
loss_fn |
- | - | (undocumented) |
futr_windows |
- | None |
(undocumented) |
train
chronax.models.tcn.tcn_training.train
Train net in place via one nnx.scan. Returns per-step losses.
Batch-index sampling splits on dataset size: with replacement when there are fewer windows than windows_batch_size, without replacement otherwise.
train(net, y, *, h, input_size, max_steps, windows_batch_size, lr, seed, loss_fn, scaler, futr_exog=None)
| Parameter | Type | Default | Description |
|---|---|---|---|
net |
- | - | (undocumented) |
y |
- | - | (undocumented) |
h |
- | - | (undocumented) |
input_size |
- | - | (undocumented) |
max_steps |
- | - | (undocumented) |
windows_batch_size |
- | - | (undocumented) |
lr |
- | - | (undocumented) |
seed |
- | - | (undocumented) |
loss_fn |
- | - | (undocumented) |
scaler |
- | - | (undocumented) |
futr_exog |
- | None |
(undocumented) |
Returns: jnp.ndarray (per-step losses)
predict_step
chronax.models.tcn.tcn_training.predict_step
Forecast next h steps from the final input_size of the series.
predict_step(net, y_context, *, h, input_size, scaler, futr_full=None)
| Parameter | Type | Default | Description |
|---|---|---|---|
net |
- | - | (undocumented) |
y_context |
- | - | (undocumented) |
h |
- | - | (undocumented) |
input_size |
- | - | (undocumented) |
scaler |
- | - | (undocumented) |
futr_full |
- | None |
futr_full is the [input_size+h, F] future-known window (history + horizon). |
Returns: jnp.ndarray ([h, multiplier] in the original scale.)