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

Remove `input_size` parameter

Open kousu opened this issue 3 years ago • 7 comments

I tried running the current demo: https://github.com/zalandoresearch/pytorch-ts/blob/62a18cfd0f19fc2247fc7e79e77f44b8dab6c4c9/README.md

But I got

$ ./pts-demo.py 
/home/user/.local/lib/python3.10/site-packages/gluonts/json.py:101: UserWarning: Using `json`-module for json-handling. Consider installing one of `orjson`, `ujson` to speed up serialization and deserialization.
  warnings.warn(
/usr/lib/python3/dist-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: 1.16.0-unknown is an invalid version and will not be supported in a future release
  warnings.warn(
/usr/lib/python3/dist-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: 1.1build1 is an invalid version and will not be supported in a future release
  warnings.warn(

(pts-demo.py:215019): dbind-WARNING **: 21:15:46.081: AT-SPI: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files
  0%|                                                                                                                                           | 0/49 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/home/user/src/covid-ts/./pts-demo.py", line 36, in <module>
    predictor = estimator.train(training_data=training_data, num_workers=4)
  File "/home/user/src/pytorch-ts/pts/model/estimator.py", line 179, in train
    return self.train_model(
  File "/home/user/src/pytorch-ts/pts/model/estimator.py", line 151, in train_model
    self.trainer(
  File "/home/user/src/pytorch-ts/pts/trainer.py", line 67, in __call__
    output = net(*inputs)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/user/src/pytorch-ts/pts/model/deepar/deepar_network.py", line 246, in forward
    distr = self.distribution(
  File "/home/user/src/pytorch-ts/pts/model/deepar/deepar_network.py", line 221, in distribution
    rnn_outputs, _, scale, _ = self.unroll_encoder(
  File "/home/user/src/pytorch-ts/pts/model/deepar/deepar_network.py", line 200, in unroll_encoder
    outputs, state = self.rnn(inputs)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/rnn.py", line 767, in forward
    self.check_forward_args(input, hx, batch_sizes)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/rnn.py", line 692, in check_forward_args
    self.check_input(input, batch_sizes)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/rnn.py", line 205, in check_input
    raise RuntimeError(
RuntimeError: input.size(-1) must be equal to input_size. Expected 43, got 19

I tried to trace the code a bit but I got lost. I know 43 comes from https://github.com/zalandoresearch/pytorch-ts/blob/62a18cfd0f19fc2247fc7e79e77f44b8dab6c4c9/README.md?plain=1#L63 but I don't understand where the 19 is coming from.

kousu avatar Jul 29 '22 01:07 kousu

I simply set input_size=19 and everything seems to work, and the predictions seem reasonable.

some sample outputs

Figure_1 Figure_2 Figure_3

I don't really understand from your docs what input_size is supposed to do. It doesn't seem to be related to the shape of the demo's input data, which is (15831, 1).

kousu avatar Jul 29 '22 02:07 kousu

Got the same problem while trying to run the demo. Changing the input size to 19 does work, but I don't know what this parameter is supposed to mean. Thanks!

Andrei358 avatar Jul 29 '22 10:07 Andrei358

Right so the Input size is the size of the input vector to the model after all the temporal features and covariates have been concated to the target value… depending on the lags, freq, static dim, dynamic features in the dataset the size of the resulting vector can vary… the new gluonts api calculates this but I wanted to expose it to the end user… I should change it… hope this helps?

kashif avatar Jul 30 '22 16:07 kashif

That does help, thanks! :clinking_glasses:

Did you mean it to be a tunable hyperparameter? But it's not actually tunable, because it throws this exception if the number is wrong.

In the meantime, what do you do with your own models? Can we just set it to None to have gluonts figure out the right number for us? Right now in the model I'm developing I'm basically just putting in input_size=100, waiting for it to crash, and reading what number I should have put in, which is awkward.

kousu avatar Jul 30 '22 17:07 kousu

I changed the thread title based on

the new gluonts api calculates this but I wanted to expose it to the end user… I should change it…

If I misunderstood then please re-update it to whatever makes sense to you.

kousu avatar Jul 30 '22 17:07 kousu

It is both a tunable and non tunable thing, e.g. by adding more lags I can increase the size of the input size or by using or discarding potential covariates in the dataset the 8nput size can be reduced etc.

I agree it is awkward… I didn’t get time to move to the new gluonts api

kashif avatar Jul 30 '22 18:07 kashif

I saw you updated the readme in the meantime! Thanks a lot for that, @kashif :)

kousu avatar Aug 14 '22 22:08 kousu