salesforce / CoST

PyTorch code for CoST: Contrastive Learning of Disentangled Seasonal-Trend Representations for Time Series Forecasting (ICLR 2022)
BSD 3-Clause "New" or "Revised" License
214 stars 43 forks source link

einsum() operands do not broadcast with remapped shapes #17

Open immusferr opened 2 years ago

immusferr commented 2 years ago

Hi, Gerald. I am trying to running your code on my own dataset. But I got some problems here:

RuntimeError: einsum() operands do not broadcast with remapped shapes [original->remapped]: [32, 37, 320]->[32, 37, 1, 320] [101, 320, 160]->[1, 101, 160, 320]

gorold commented 2 years ago

Hey, thanks for your interest in our work, could you provide more information on this error (the full error log) and the dimensions of the data you are working with? I can't really tell whats wrong from just this error message.

yyyujintang commented 1 year ago

I met the same problem. ` import torch

from torch import nn

import torchinfo

from torchinfo import summary

net = CoSTEncoder( input_dims=12, output_dims=3, kernels=[1, 2, 4, 8, 16, 32, 64, 128], length=3000, hidden_dims=64, depth=10, )

summary(net,input_size=(1,121,12),col_names=["kernel_size","output_size","num_params","mult_adds"]) ` And I get the error einsum(): operands do not broadcast with remapped shapes [original->remapped]: [1, 61, 3]->[1, 61, 1, 3] [1501, 3, 1]->[1, 1501, 1, 3]

yyyujintang commented 1 year ago

I figure out the problem, the length in CoSTEncoder must match your dataset. For example, my length is 121, then change it in the Enocder part. ` import torch

from torch import nn

import torchinfo

from torchinfo import summary

net = CoSTEncoder( input_dims=12, output_dims=3, kernels=[1, 2, 4, 8, 16, 32, 64, 128], length=121, hidden_dims=64, depth=10, ) ` summary(net,input_size=(1,121,12),col_names=["kernel_size","output_size","num_params","mult_adds"])

17103023 commented 1 year ago

My dataset is similar to yours, with a total of 8 columns and 1681 rows, and the runtime reports such an error

Traceback (most recent call last): File "train.py", line 109, in out, eval_res = tasks.eval_forecasting(model, data, train_slice, valid_slice, test_slice, scaler, pred_lens, n_covariate_cols, args.max_train_length-1) File "/userdata/lwy/CoST-main/tasks/forecasting.py", line 55, in eval_forecasting lr = eval_protocols.fit_ridge(train_features, train_labels, valid_features, valid_labels) File "/userdata/lwy/CoST-main/tasks/_eval_protocols.py", line 25, in fit_ridge lr = Ridge(alpha=alpha).fit(train_features, train_y) File "/userdata/lwy/.local/lib/python3.8/site-packages/sklearn/linear_model/_ridge.py", line 762, in fit return super().fit(X, y, sample_weight=sample_weight) File "/userdata/lwy/.local/lib/python3.8/site-packages/sklearn/linear_model/_ridge.py", line 542, in fit X, y = self._validate_data(X, y, File "/userdata/lwy/.local/lib/python3.8/site-packages/sklearn/base.py", line 433, in _validate_data X, y = check_X_y(X, y, check_params) File "/userdata/lwy/.local/lib/python3.8/site-packages/sklearn/utils/validation.py", line 63, in inner_f return f(*args, *kwargs) File "/userdata/lwy/.local/lib/python3.8/site-packages/sklearn/utils/validation.py", line 814, in check_X_y X = check_array(X, accept_sparse=accept_sparse, File "/userdata/lwy/.local/lib/python3.8/site-packages/sklearn/utils/validation.py", line 63, in inner_f return f(args, kwargs) File "/userdata/lwy/.local/lib/python3.8/site-packages/sklearn/utils/validation.py", line 669, in check_array raise ValueError("Found array with %d sample(s) (shape=%s) while a" ValueError: Found array with 0 sample(s) (shape=(0, 320)) while a minimum of 1 is required.