阅读量:6
目录
效果一览
基本介绍
1.Matlab基于Transformer-LSTM多变量时间序列多步预测;
2.多变量时间序列数据集(负荷数据集),采用前96*2个时刻预测的特征和负荷数据预测未来96个时刻的负荷数据;
3.excel数据方便替换,运行环境matlab2023及以上,展示最后96个时间步的预测对比图,评价指标MAE、MAPE、RMSE、MSE、R2;
注:程序和数据放在一个文件夹。
4.程序语言为matlab,程序可出预测效果图,指标图;
5.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。
程序设计
- 完整程序和数据获取方式私信博主回复Matlab基于Transformer-LSTM多变量时间序列多步预测。
% 数据归一化 [p_train, ps_input] = mapminmax(P_train, 0, 1); p_test = mapminmax('apply', P_test, ps_input); [t_train, ps_output] = mapminmax(T_train, 0, 1); t_test = mapminmax('apply', T_test, ps_output); %% 数据平铺 for i = 1:size(p_train,2) trainD{i,:} = (reshape(p_train(:,i),or_dim,[])); end for i = 1:size(p_test,2) testD{i,:} = (reshape(p_test(:,i),or_dim,[])); end targetD = t_train'; targetD_test = t_test'; %% 模型 numChannels = or_dim; maxPosition = 256*2; numHeads = 4; numKeyChannels = numHeads*32; layers = [ sequenceInputLayer(numChannels,Name="input") positionEmbeddingLayer(numChannels,maxPosition,Name="pos-emb"); additionLayer(2, Name="add") options = trainingOptions(solver, ... 'Plots','none', ... 'MaxEpochs', maxEpochs, ... 'MiniBatchSize', miniBatchSize, ... 'Shuffle', shuffle, ... 'InitialLearnRate', learningRate, ... 'GradientThreshold', gradientThreshold, ... 'ExecutionEnvironment', executionEnvironment);
参考资料
[1] http://t.csdn.cn/pCWSp
[2] https://download.csdn.net/download/kjm13182345320/87568090?spm=1001.2014.3001.5501
[3] https://blog.csdn.net/kjm13182345320/article/details/129433463?spm=1001.2014.3001.5501