目录




matlab2022a
- ...................................................................
-
- %CNN-GRU-ATT
- layers = func_model(Dim);
-
- %设置
- %迭代次数
- %学习率为0.001
- options = trainingOptions('adam', ...
- 'MaxEpochs', 1500, ...
- 'InitialLearnRate', 1e-4, ...
- 'LearnRateSchedule', 'piecewise', ...
- 'LearnRateDropFactor', 0.1, ...
- 'LearnRateDropPeriod', 1000, ...
- 'Shuffle', 'every-epoch', ...
- 'Plots', 'training-progress', ...
- 'Verbose', false);
-
- %训练
- Net = trainNetwork(Nsp_train2, NTsp_train, layers, options);
-
- figure
- subplot(211);
- plot(1: Num1, Tat_train,'-bs',...
- 'LineWidth',1,...
- 'MarkerSize',6,...
- 'MarkerEdgeColor','k',...
- 'MarkerFaceColor',[0.9,0.0,0.0]);
- hold on
- plot(1: Num1, T_sim1,'g',...
- 'LineWidth',2,...
- 'MarkerSize',6,...
- 'MarkerEdgeColor','k',...
- 'MarkerFaceColor',[0.9,0.9,0.0]);
-
- legend('真实值', '预测值')
- xlabel('预测样本')
- ylabel('预测结果')
- grid on
-
- subplot(212);
- plot(1: Num1, Tat_train-T_sim1','-bs',...
- 'LineWidth',1,...
- 'MarkerSize',6,...
- 'MarkerEdgeColor','k',...
- 'MarkerFaceColor',[0.9,0.0,0.0]);
- legend('真实值', '预测值')
- xlabel('预测样本')
- ylabel('预测误差')
- grid on
- ylim([-50,50]);
- figure
- subplot(211);
- plot(1: Num2, Tat_test,'-bs',...
- 'LineWidth',1,...
- 'MarkerSize',6,...
- 'MarkerEdgeColor','k',...
- 'MarkerFaceColor',[0.9,0.0,0.0]);
- hold on
- plot(1: Num2, T_sim2,'g',...
- 'LineWidth',2,...
- 'MarkerSize',6,...
- 'MarkerEdgeColor','k',...
- 'MarkerFaceColor',[0.9,0.9,0.0]);
- legend('真实值', '预测值')
- xlabel('测试样本')
- ylabel('测试结果')
- grid on
- subplot(212);
- plot(1: Num2, Tat_test-T_sim2','-bs',...
- 'LineWidth',1,...
- 'MarkerSize',6,...
- 'MarkerEdgeColor','k',...
- 'MarkerFaceColor',[0.9,0.0,0.0]);
- legend('真实值', '预测值')
- xlabel('预测样本')
- ylabel('预测误差')
- grid on
- ylim([-50,50]);
- 116
CNN-GRU-Attention模型结合了卷积神经网络(CNN)、门控循环单元(GRU)和注意力机制(Attention)来进行时间序列数据的回归预测。CNN用于提取时间序列的局部特征,GRU用于捕获时间序列的长期依赖关系,而注意力机制则用于在预测时强调重要的时间步。
在时间序列回归任务中,CNN用于捕获局部特征和模式:

GRU用于捕捉时间序列的长期依赖关系:


最后,通过反向传播算法调整所有参数以最小化预测误差,并在整个训练集上迭代优化模型。
OOOOO
OOO
O