timeseriesAI / tsai

Time series Timeseries Deep Learning Machine Learning Python Pytorch fastai | State-of-the-art Deep Learning library for Time Series and Sequences in Pytorch / fastai
https://timeseriesai.github.io/tsai/
Apache License 2.0
5.1k stars 639 forks source link

Multioutput Regression #618

Closed yangtzech closed 1 year ago

yangtzech commented 1 year ago

I am trying to do a multioutput regression. And I make no change but the data. But it seems the dls.c is set to be 1. An error will return: The size of tensor a (1024) must match the size of tensor b (2048) at non-singleton dimension 0. I have to change the input of the model manually, like from TST(dls.vars, dls.c, dls.len) to TST(dls.vars, manually_set_num_of_classes, dls.len). Then the code works without error. But during training, only one total metric will be shown:

epoch | train_loss | valid_loss | mae | _rmse | mape | time -- | -- | -- | -- | -- | -- | -- 0 | 22161.556641 | 21720.078125 | 65.117775 | 147.377319 | 13489878.000000 | 00:07 1 | 27359.021484 | 23133.435547 | 64.434105 | 152.096817 | 13433783.000000 | 00:07

Am I doing right by just changing the number of output classes in the model manually? Is it possible to show metrics of different outputs?

oguiza commented 1 year ago

Am I doing right by just changing the number of output classes in the model manually?

Yes, that's fine. By default, the dls.c is set to 1 for regression data. Alternatively, there's a separate parameter dls.d that will contain the number of outputs. You need a special custom head (3d or nd heads) to handle dls.d with dls.c=1. There are many types. You may want to take a look at them here: create_fc_head

Is it possible to show metrics of different outputs?

No there's no way to do that natively in tsai. You can create a custom metric for example for each output, or calculate them once the training is complete.

yangtzech commented 1 year ago

Thanks for your kind help and instruction. I'll have a try!