maxjcohen / transformer

Implementation of Transformer model (originally from Attention is All You Need) applied to Time Series.
https://timeseriestransformer.readthedocs.io/en/latest/
GNU General Public License v3.0
842 stars 165 forks source link

How to change the program to a classification model ? #60

Closed HuskyXPZ closed 1 year ago

HuskyXPZ commented 1 year ago

I have a time series data and I want to change the program to a model for classification.

The following is the part I changed in the program

Before:

# Output module
output = self._linear(decoding)
output = torch.sigmoid(output)

After:

# Output module
output = self._linear(decoding) 
output_softmax = torch.softmax(output)

After the modification, the program has the following error:

ValueError: Expected target size (64, 3), got torch.Size([64])

By the way, my data size is (64,55,20), and my category labels have three.

maxjcohen commented 1 year ago

Hi, we're going to need more information in order to better understand what is happening. What line raises this error, and the full backtrace ? What are your labels shape ? Please see #18 for more information about applying the model to a classification task.