Learner

Pytorch Modules for Training Models for sequential data
from tsfast.datasets.core import *
dls = create_dls_test(prediction=True)
model = SimpleRNN(1,1)

Create Learner Models

Create Learner with different kinds of models with fitting Parameters and regularizations.


source

get_inp_out_size

 get_inp_out_size (dls)

returns input and output size of a timeseries databunch

test_eq(get_inp_out_size(dls),(2,1))

RNN Learner

The Learners include model specific optimizations. Removing the first n_skip samples of the loss function of transient time, greatly improves training stability. In


source

RNNLearner

 RNNLearner (dls, loss_func=MSELoss(), metrics=[<function fun_rmse at
             0x7f38c72698a0>], n_skip=0, cbs=None, num_layers=1,
             hidden_size=100, linear_layers=0, return_state=False,
             hidden_p=0.0, input_p=0.0, weight_p=0.0, rnn_type='gru',
             ret_full_hidden=False, stateful=False, normalization='',
             **kwargs)
RNNLearner(dls,rnn_type='gru').fit(1,1e-4)
epoch train_loss valid_loss fun_rmse time
0 0.050820 0.054230 0.232794 00:01

TCN Learner

Performs better on multi input data. Higher beta values allow a way smoother prediction. Way faster then RNNs in prediction.


source

TCNLearner

 TCNLearner (dls, hl_depth=3, loss_func=MSELoss(), metrics=[<function
             fun_rmse at 0x7f38c72698a0>], n_skip=0, cbs=None,
             hl_width=10, act=<class 'torch.nn.modules.activation.Mish'>,
             bn=False, stateful=False, **kwargs)
TCNLearner(dls).fit(1)
/home/pheenix/miniconda3/envs/env_tsfast/lib/python3.11/site-packages/torch/nn/utils/weight_norm.py:28: UserWarning: torch.nn.utils.weight_norm is deprecated in favor of torch.nn.utils.parametrizations.weight_norm.
  warnings.warn("torch.nn.utils.weight_norm is deprecated in favor of torch.nn.utils.parametrizations.weight_norm.")
0.00% [0/1 00:00<?]
epoch train_loss valid_loss fun_rmse time

0.00% [0/12 00:00<?]

CRNN Learner


source

CRNNLearner

 CRNNLearner (dls, loss_func=MSELoss(), metrics=[<function fun_rmse at
              0x7f38c72698a0>], n_skip=0, cbs=None, num_ft=10,
              num_cnn_layers=4, num_rnn_layers=2, hs_cnn=10, hs_rnn=10,
              hidden_p=0, input_p=0, weight_p=0, rnn_type='gru',
              stateful=False, **kwargs)
CRNNLearner(dls,rnn_type='gru').fit(1,3e-2)
0.00% [0/1 00:00<?]
epoch train_loss valid_loss fun_rmse time

0.00% [0/12 00:00<?]

Autoregressive Learner


source

AR_TCNLearner

 AR_TCNLearner (dls, hl_depth=3, alpha=1, beta=1, early_stop=0,
                metrics=None, n_skip=None, hl_width=10, act=<class
                'torch.nn.modules.activation.Mish'>, bn=False,
                stateful=False, **kwargs)
AR_TCNLearner(dls).fit(1)
0.00% [0/1 00:00<?]
epoch train_loss valid_loss fun_rmse time

0.00% [0/12 00:00<?]

source

AR_RNNLearner

 AR_RNNLearner (dls, alpha=0, beta=0, early_stop=0, metrics=None,
                n_skip=0, fname='model', num_layers=1, hidden_size=100,
                linear_layers=0, return_state=False, hidden_p=0.0,
                input_p=0.0, weight_p=0.0, rnn_type='gru',
                ret_full_hidden=False, stateful=False, normalization='',
                **kwargs)
AR_RNNLearner(dls).fit(1)
epoch train_loss valid_loss fun_rmse time
0 0.058972 0.063309 0.251510 00:00