from tsfast.datasets.core import *
Learner
Pytorch Modules for Training Models for sequential data
= create_dls_test(prediction=True)
dls = SimpleRNN(1,1) model
Create Learner Models
Create Learner with different kinds of models with fitting Parameters and regularizations.
get_inp_out_size
get_inp_out_size (dls)
returns input and output size of a timeseries databunch
2,1)) test_eq(get_inp_out_size(dls),(
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
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)
='gru').fit(1,1e-4) RNNLearner(dls,rnn_type
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.
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)
1) TCNLearner(dls).fit(
/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
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)
='gru').fit(1,3e-2) CRNNLearner(dls,rnn_type
0.00% [0/1 00:00<?]
epoch | train_loss | valid_loss | fun_rmse | time |
---|
0.00% [0/12 00:00<?]
Autoregressive Learner
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)
1) AR_TCNLearner(dls).fit(
0.00% [0/1 00:00<?]
epoch | train_loss | valid_loss | fun_rmse | time |
---|
0.00% [0/12 00:00<?]
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)
1) AR_RNNLearner(dls).fit(
epoch | train_loss | valid_loss | fun_rmse | time |
---|---|---|---|---|
0 | 0.058972 | 0.063309 | 0.251510 | 00:00 |