Skip to main content

TCN based models for time series forecasting.

Project description

TCN_Seq2Seq

Implementation of different TCN based Sequence-to-Sequence models for timeseries forecasting. Currently, only works for a numerical class label.

The project includes wrapper classes for the models that add some additional features like simple saving and loading of the trained models and automated hyperparameter tuning. Also, there is functionality for basic data preprocessing as well as saving and loading the preprocessing configurations.
The project is written in Python 3.8 using Tensorflow 2.5.0

TCN_Seq2Seq is on PyPI, so you can use pip to install it.

pip install --upgrade pip
pip install tcn-sequence-models

Models

Three models exist:

1. TCN-TCN model with attention.

The structure of the TCN-TCN model with attention can be seen below.

drawing

2. "Normal" TCN-TCN model without attention.

The structure of the "normal" TCN-TCN model without attention can be seen below.

drawing

There are two versions of the TCN-TCN models, an autoregressive model and a none-autoregressive model.

Autoregressive model: For training, teacher-forcing is used for the decoder. In addition to other decoder input data that is defined by the user, always the ground truth of the previous time step is added as an additional feature. For example at position x(n+1) the ground truth at position x(n) is added as an additional input. During inference, the predictions of the previous time step is used instead. The autoregressive model can be trained fast in a parallel way. However, inference is slow because the decoder needs to be passed m times when the output length is m.

None-regressive model: For the none-regressive model only the input features are used for the decoder that the user provides. If the user does not provide any features for the decoder, a dummy feature is created with all 1s so that the decoder has some input. Without any input the model would not work. This model is fast during training and inference.

3. TCN-RNN model.

The architecture of the TCN-RNN model can be seen in the following image:

drawing

TCN blocks

The TCN blocks use as many layers as needed to get a connection from first timestep's input to last timestep's output. The padding mode in the models can be set by the user. If padding is set to 'causal', a timestep only gets information from the previous timesteps. If set to 'same' or 'valid', also information from future timesteps are used which might improve the predictions.

The encoder of the "normal" TCN-TCN model will always have "causal" padding since only the last output of the encoder is used. Also, for the decoder of the TCN-TCN models in the autoregressive mode, padding will always be causal. The picture below shows the TCN block with 'causal' padding. drawing

One TCN cell (residual block) is structured like this (when choosing ReLu as activation function):

drawing

Inputs

The models expect input sequences for the encoder and optionally for the decoder.

Examples

For examples, please refer to the notebooks.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tcn_sequence_models-0.0.8.tar.gz (23.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tcn_sequence_models-0.0.8-py3-none-any.whl (34.5 kB view details)

Uploaded Python 3

File details

Details for the file tcn_sequence_models-0.0.8.tar.gz.

File metadata

  • Download URL: tcn_sequence_models-0.0.8.tar.gz
  • Upload date:
  • Size: 23.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.5

File hashes

Hashes for tcn_sequence_models-0.0.8.tar.gz
Algorithm Hash digest
SHA256 f628b2daa62bb5949ed16a6aa639ae4e0d7b3a90fae6b320fa70f265de006867
MD5 f13f86383a2da1eb0036568e4b5dadb1
BLAKE2b-256 52906b9fbda39f6972339eefd5a54a006528c4b842401a66b7fb2406cf3285a9

See more details on using hashes here.

File details

Details for the file tcn_sequence_models-0.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for tcn_sequence_models-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 38926c4dda09cef0774838df62e91aff3b53bdaf62ac2ce40864217a19a97a1f
MD5 f338e5b010e23eb246c53588d20dbf57
BLAKE2b-256 c443fd6c62edc2e6ee438d3f92e9eba27fba708e87af0374ca46bcd7b8a87d7a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page