tsai icon indicating copy to clipboard operation
tsai copied to clipboard

PatchTST output/target tensor mismatch in loss function

Open E-Penguin opened this issue 2 years ago • 2 comments

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)

E-Penguin avatar Jul 04 '23 20:07 E-Penguin

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).

oguiza avatar Sep 03 '23 16:09 oguiza

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

MALIK2k21 avatar Feb 14 '24 16:02 MALIK2k21