pytorch-forecasting icon indicating copy to clipboard operation
pytorch-forecasting copied to clipboard

TCN of pytorch-forecasting

Open wangbingnan136 opened this issue 4 years ago • 24 comments

wangbingnan136 avatar Jun 05 '21 00:06 wangbingnan136

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Codecov Report

Merging #549 (d4bc616) into master (06dcc29) will decrease coverage by 0.02%. The diff coverage is 88.09%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #549      +/-   ##
==========================================
- Coverage   89.12%   89.09%   -0.03%     
==========================================
  Files          24       25       +1     
  Lines        3788     3907     +119     
==========================================
+ Hits         3376     3481     +105     
- Misses        412      426      +14     
Flag Coverage Δ
cpu 89.09% <88.09%> (-0.03%) :arrow_down:
pytest 89.09% <88.09%> (-0.03%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pytorch_forecasting/__init__.py 100.00% <ø> (ø)
pytorch_forecasting/models/base_model.py 87.65% <58.33%> (-0.47%) :arrow_down:
.../models/temporal_convolutional_network/__init__.py 91.07% <91.07%> (ø)
pytorch_forecasting/models/__init__.py 100.00% <100.00%> (ø)
pytorch_forecasting/models/baseline.py 94.73% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 06dcc29...d4bc616. Read the comment docs.

codecov-commenter avatar Jun 05 '21 06:06 codecov-commenter

Ok,I will do that as soon as I can!

wangbingnan136 avatar Jun 05 '21 16:06 wangbingnan136

I have modified TCN according to your suggestion,thanks a lot!

wangbingnan136 avatar Jun 07 '21 21:06 wangbingnan136

I'm sorry.I do not know how the checks above works? Can you give me some complete examples of code testing?So that I can do the test myself.

wangbingnan136 avatar Jun 09 '21 13:06 wangbingnan136

In the directory tests/test_models are multiple files that test a network. I suggest to pretty much copy paste the test_nbeats.py. as this is very similar to what you are trying to do.

jdb78 avatar Jun 13 '21 12:06 jdb78

There seems to be an import error: https://github.com/jdb78/pytorch-forecasting/pull/549/checks?check_run_id=2783133836

jdb78 avatar Jun 13 '21 12:06 jdb78

I have fixed the import error

wangbingnan136 avatar Jun 21 '21 06:06 wangbingnan136

@wangbingnan136: How do we approach the multi-horizon forecasting issue with TCNs? Is it supposed to be re-current or a multi-horizon forecast? In case of the later, it is a bit unclear to me how to leverage covariates in the decoder.

jdb78 avatar Jul 01 '21 14:07 jdb78

@wangbingnan136: How do we approach the multi-horizon forecasting issue with TCNs? Is it supposed to be re-current or a multi-horizon forecast? In case of the later, it is a bit unclear to me how to leverage covariates in the decoder.

Tcn can only support the output mode of vector output, It just like nbeats or simple LSTM.

image

which I think is what you mean "re-current," that is, TCN only has an encoder structure and no decoder structure. We use the latent vector obtained by the encoder to directly connect to a fully connected layer to complete the forecasting task.

If we want to approach the multi-horizon forecasting issue with TCNs,we can direct use Wavenet ,which supports the structure of encoder+decoder.

wangbingnan136 avatar Jul 01 '21 14:07 wangbingnan136

@wangbingnan136 Could you check the implementation? I am not really sure it is correct. Adding a skip connection (optional in the paper) dramatically improved the performance. Could you check it and confirm the implementation is correct before we merge?

jdb78 avatar Jul 08 '21 15:07 jdb78

I think there are some changes required when I compare with https://www.mdpi.com/2079-9292/8/8/876

jdb78 avatar Jul 08 '21 15:07 jdb78

Ok,I will see

wangbingnan136 avatar Jul 09 '21 05:07 wangbingnan136

I have implemented the skip connection function according to https://github.com/philipperemy/keras-tcn/blob/master/tcn/tcn.py

and test the data in tutorial: image

The performance of model becomes better.

wangbingnan136 avatar Jul 09 '21 10:07 wangbingnan136

@wangbingnan136 , could you revert the version to after the lock-file fix (best to use git pull before continuing the work) and use the pre-commit hooks?

I believe the main issue is that M-TCN uses a slightly modified architecture and currently, the model uses convolutions along features and not time.

jdb78 avatar Jul 09 '21 10:07 jdb78

@wangbingnan136 , could you revert the version to after the lock-file fix (best to use git pull before continuing the work) and use the pre-commit hooks?

I believe the main issue is that M-TCN uses a slightly modified architecture and currently, the model uses convolutions along features and not time.

Ok,I have reverted the version.

wangbingnan136 avatar Jul 09 '21 10:07 wangbingnan136

image

I think the model uses convolutions along time.

24 is the length of time steps

wangbingnan136 avatar Jul 09 '21 10:07 wangbingnan136

@wangbingnan136 Many thanks for making the TCN model available. However, I am not sure which version of the following you are actually implementing:

May I ask you to be more specific on which one you are using. I assume it is the last one?

StatMixedML avatar Jul 13 '21 14:07 StatMixedML

@wangbingnan136 Many thanks for making the TCN model available. However, I am not sure which version of the following you are actually implementing:

May I ask you to be more specific on which one you are using.

Actually it is almost the same as https://github.com/philipperemy/keras-tcn. I think the related paper is this one:https://arxiv.org/pdf/1803.01271.pdf 《An Empirical Evaluation of Generic Convolutional and Recurrent Networks for Sequence Modeling》

wangbingnan136 avatar Jul 13 '21 14:07 wangbingnan136

Actually it is almost the same as https://github.com/philipperemy/keras-tcn. I think the related paper is this one:https://arxiv.org/pdf/1803.01271.pdf 《An Empirical Evaluation of Generic Convolutional and Recurrent Networks for Sequence Modeling》

Ok I see, many thanks for clarifying!

StatMixedML avatar Jul 13 '21 14:07 StatMixedML

Actually it is almost the same as https://github.com/philipperemy/keras-tcn. I think the related paper is this one:https://arxiv.org/pdf/1803.01271.pdf 《An Empirical Evaluation of Generic Convolutional and Recurrent Networks for Sequence Modeling》

Ok I see, many thanks for clarifying!

You are welcome~

wangbingnan136 avatar Jul 13 '21 14:07 wangbingnan136

Actually, seeing this, we should probably switch to Probabilistic forecasting with temporal convolutional neural network as it has a proper decoder (The quantile loss is trivial and would be supported anyways).

jdb78 avatar Jul 13 '21 16:07 jdb78

Actually, seeing this, we should probably switch to Probabilistic forecasting with temporal convolutional neural network as it has a proper decoder (The quantile loss is trivial and would be supported anyways).

I see.I may need some time to study the network structure of the tcn in this paper。

wangbingnan136 avatar Jul 13 '21 17:07 wangbingnan136

Actually, seeing this, we should probably switch to Probabilistic forecasting with temporal convolutional neural network as it has a proper decoder (The quantile loss is trivial and would be supported anyways).

@jdb78 I would also opt for this version. Would love to be part of supporting the implementation.

StatMixedML avatar Jul 13 '21 19:07 StatMixedML