Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does Current model support multivariate input and univariate output? #7

Open
Essie0715 opened this issue May 28, 2023 · 6 comments
Open

Comments

@Essie0715
Copy link

Thank you for sharing your code. My task is to use multiple time series (historical temperature, wind, humidity, etc.) as input features and a single output forecasting target (predict the future temperature). The original model in the paper is multiple input and multiple output models. But I want to make it a single output model only. Where should I start to modify the model to fit my purpose?

@YunhaoZhang-Mars
Copy link
Collaborator

Yes, the current model only supports (multiple input)->(multiple output) mode. To fit your (multiple input)->(single output) task, you need to modify the decoder, we can come up with two ways: 1) use the same decoder as our original paper (i.e. each dimension will make a prediction of the target series), and sum over the predicted series of all dimensions to get the final result; 2) flatten the encoded 2D vector array into a 1D sequence to be used as keys and values in the decoder. We think the first method may work better as it distinguishes the time and dimension axes and it is also easier to implement.

@zmce2018
Copy link

Hello Zhang,

I have got the same question here. I am a little bit confused when you say 'each dimension will make a prediction of the target series)'. Does that mean all the dimensions will learn the same single output? If that is the case, should we take the average instead of sum? Thank you so much for your time.

@YunhaoZhang-Mars
Copy link
Collaborator

Let me be more precise: each dimension will output a series and all these outputs contribute to the final prediction. The outputs of all dimensions will not be the same as the corresponding encoded vectors are not the same. You can try both sum and average to aggregate the outputs and select the one that performs better. The key is to first aggregate these outputs to get a single series and then compute the loss w.r.t the future ground truth.

@zzx5520
Copy link

zzx5520 commented Aug 12, 2023

您好,有一些问题想向您请教,您前面关于多维时间序列进行单维特征预测的解释中,可不可以理解为依然使用您的源码,最终decoder的输出依然包含所有维度预测结果,但在进行结果输出时只导出我们期望特征的预测结果(使用切片只要预测列的结果),并用对应单维特征进行损失计算,期望您的回复

@YunhaoZhang-Mars
Copy link
Collaborator

您说的操作当然是可行的,不过我的意思是这样的:当前模型输出的tensor形状为[batch_size, dim, pred_len],注意到在未经过训练前该输出没有任何物理含义。我们使用sum(dim = 1)将其形状转变为[batch_size, pred_len]作为单维特征的预测结果,并计算loss。这样做的好处是输入的各个维度都对最终的预测结果有一定的贡献,我猜测效果应该略好于直接取出单一维度的方案。

@zzx5520
Copy link

zzx5520 commented Aug 13, 2023

十分感谢您的回答,‘当前模型输出的tensor形状为[batch_size, dim, pred_len],将其形状转变为[batch_size, pred_len]作为单维特征的预测结果,并计算loss。’对我的帮助很大。我进行了尝试,关于sum这个我有一点疑问,如果我在维度方向对所有维度进行求和,那不是只是得到了一个单维输出,但似乎并不是我期望的输出,比如说在进行温度预测时,有诸多影响因素作为其他特征一起输入模型,期望对未来温度进行预测,如果使用sum,是不是说输出结果为所有特征求和后的预测结果而不是温度的预测结果呢,不知道是不是我的理解依然有问题。
此前,我参照那您说的把[batch_size, dim, pred_len]转变为[batch_size, pred_len],得到预测维度结果(未进行求和,其实本质上我认为我进行的依然是切片只保留预测维度),然后进行loss计算,这样是不是没有考虑您你说的‘输入的各个维度都对最终的预测结果有一定的贡献’呢?
期望您的回答

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants