Skip to content

Autoregressive Prediction

Autoregressive progressive prediction model.

ARProg

ARProg(n_u: int, n_x: int, n_y: int, init_sz: int, init_sz_range: tuple[int, int] | None = None, **kwargs)

Bases: Module

RNN model with teacher-forced initialization and autoregressive prediction.

Uses an initial segment with teacher forcing to warm up hidden state, then switches to autoregressive mode for the remaining sequence.

Parameters:

Name Type Description Default
n_u int

number of input signals.

required
n_x int

number of external state signals.

required
n_y int

number of output signals.

required
init_sz int

number of time steps for teacher-forced initialization.

required
init_sz_range tuple[int, int] | None

if set, randomize init_sz within (min, max) during training.

None
Source code in tsfast/prediction/ar.py
def __init__(
    self, n_u: int, n_x: int, n_y: int, init_sz: int, init_sz_range: tuple[int, int] | None = None, **kwargs
):
    super().__init__()
    self.n_u = n_u
    self.n_x = n_x
    self.n_y = n_y
    self.init_sz = init_sz
    self.init_sz_range = init_sz_range

    self.rnn_model = AR_Model(
        SimpleRNN(input_size=n_u + n_x + n_y, output_size=n_x + n_y, return_state=True, **kwargs),
        model_has_state=True,
        return_state=True,
        ar=True,
        out_sz=n_x + n_y,
    )