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.14k stars 643 forks source link

PatchTST output/target tensor mismatch in loss function #803

Open E-Penguin opened 1 year ago

E-Penguin commented 1 year ago

edit Having read the other issues, this might be related to #738 & #713 as it's trying a multivariate input/univariate output. I'm happy to make some code changes if you point me in the right direction /edit

Runtime Error when using PatchTST (it works with, for example TSTPlus):

    return _VF.broadcast_tensors(tensors)  # type: ignore[attr-defined]
RuntimeError: The size of tensor a (241920) must match the size of tensor b (70) at non-singleton dimension 0

Code to reproduce:

from tsai.basics import *

X, y, splits = get_regression_data('AppliancesEnergy', split_data=False)
tfms = [None, TSRegression()]
batch_tfms = TSStandardize(by_sample=True)
batch_size = 70
reg = TSRegressor(X, y, splits=splits, path='models', arch="PatchTST", tfms=tfms, batch_tfms=batch_tfms, batch_size=batch_size, metrics=rmse, verbose=True)
reg.fit_one_cycle(100, 3e-4)
reg.export("reg.pkl")

from tsai.inference import load_learner

reg = load_learner("models/reg.pkl")
raw_preds, target, preds = reg.get_X_preds(X[splits[1]], y[splits[1]])
print(raw_preds)
oguiza commented 1 year ago

Hi @E-Penguin, this is not yet currently supported by PatchTST. For now, you can only use it with univariate datasets, or multivariate datasets where you predict all input variables (in fact, this is a duplicate of https://github.com/timeseriesAI/tsai/issues/713).

MALIK2k21 commented 7 months ago

Hi @oguiza I just wanted to confirm if this issue is still unresolved(multivariate input ---> univariate output)?. I have traied but got mismatch error so I just wanted to know if you had a solution for this now? Thank you