✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
个人主页:Matlab科研工作室
个人信条:格物致知。
针对影响芒果产量的相关气象要素繁多,它们与产量之间的关联关系复杂,难以用数学函数准确地描述的问题,提出一种基于自注意力机制门控循环单元和卷积神经网络组合(attention CGRU)模型.首先,利用CNN卷积层(1D CNN)提取局部特征;其次将attention机制用于进一步提取依赖特征,然后双向门控循环单元(GRU)会充分考虑年份之间的关联性,学习长期依赖特征;最后,利用广西某地3个气象站所收集到的24个芒果生产周期年份(从前一年第22旬到当年第21旬)每旬9个气象要素及芒果产量数据进行分析建模,建立了芒果产量预测attention CGRU模型.
⛄ 部分代码
clc
clear all
n=40;
G=600;
PD=21;
SD=6;
rows=8;
cols=10;
basep=compute_P((1/3)*ones(1,rows,cols));
basep
basem=compute_M((1/3)*ones(1,rows,cols));
% disp('run improvedssa');
% pause(3);
% [improved_ssa_bestsolution,improved_ssa_Ps,improved_ssa_Ms]=improved_ssa(n,G,PD,SD,rows,cols);
% maxf=compute_f_(improved_ssa_bestsolution)
% disp('run ssa');
% pause(3);
% [ssa_bestsolution,ssa_Ps,ssa_Ms]=ssa(n,G,PD,SD,rows,cols);
%
% maxf=compute_f_(ssa_bestsolution)
% pause(3);
disp('run ga');
pause(3);
[ga_bestsolution,ga_Ps,ga_Ms]=ga(G,n,rows,cols);
maxf=compute_f_(ga_bestsolution)
disp('run improvedga');
pause(3);
[improved_ga_bestsolution,improved_ga_Ps,improved_ga_Ms]=improved_ga(G,n,rows,cols);
maxf=compute_f_(improved_ga_bestsolution)
disp('run pso');
pause(3);
[pso_bestsolution,pso_Ps,pso_Ms]=pso(G,n,rows,cols);
maxf=compute_f_(pso_bestsolution)
% disp('run goa');
% pause(3);
% [goa_bestsolution,goa_Ps,goa_Ms]=goa(G,n,rows,cols);
% maxf=compute_f_(goa_bestsolution)
%
% disp('run imporved_goa');
% pause(3);
% [improved_goa_bestsolution,improved_goa_Ps,improved_goa_Ms]=improved_goa(G,n,rows,cols);
% maxf=compute_f_(improved_goa_bestsolution)
figure(1);
% plot(1:length(improved_ssa_Ps),improved_ssa_Ps,'-','Color',[242/255 158/255 195/255]);
% hold on;
% plot(1:length(ssa_Ps),ssa_Ps,'-','Color',[22/255 107/255 201/255]);
% hold on;
plot(1:length(ga_Ps),ga_Ps,'-','Color',[1 0 0]);
hold on;
plot(1:length(improved_ga_Ps),improved_ga_Ps,'-','Color',[144 238 144]/255);
hold on;
plot(1:length(pso_Ps),pso_Ps,'-','Color',[140 81 25]/255);
hold on;
% plot(1:length(goa_Ps),goa_Ps,'-','Color',[128/255 0/255 128/255]);
% hold on;
% plot(1:length(improved_goa_Ps),improved_goa_Ps,'-','Color',[4 4 4]/255);
% hold on;
plot(1:G,basep*ones(1,G),'--','Color',[0,0,255]/255);
hold on;
ylabel('杈撳嚭鍔熺巼');
xlabel('杩唬娆℃暟');
% legend({'鏀硅繘ssa','ssa','ga','鏀硅繘ga','pso','goa','鏀硅繘goa','浼樺寲鍓嶈緭鍑哄姛鐜?});
legend({'ga','鏀硅繘ga','pso','浼樺寲鍓嶈緭鍑哄姛鐜?});
figure(2);
% plot(1:length(improved_ssa_Ms),improved_ssa_Ms,'-','Color',[1 0.1 0.1]);
% hold on;
% plot(1:length(ssa_Ms),ssa_Ms,'-','Color',[0.1 0 1]);
% hold on;
plot(1:length(ga_Ms),ga_Ms,'-','Color',[1 128/255 0]);
hold on;
plot(1:length(improved_ga_Ms),improved_ga_Ms,'-','Color',[0.4 0.6 0.78]);
hold on;
plot(1:length(pso_Ms),pso_Ms,'-','Color',[0.6 0.1 0.4]);
hold on;
% plot(1:length(goa_Ms),goa_Ms,'-','Color',[231/255 27/255 100/255]);
% hold on;
% plot(1:length(improved_goa_Ms),improved_goa_Ms,'-','Color',[4 4 4]/255);
% hold on;
plot(1:G,basem*ones(1,G),'--','Color',[0,0,255]/255);
hold on;
% legend({'鏀硅繘ssa','ssa','ga','鏀硅繘ga','pso','goa','鏀硅繘goa','浼樺寲
⛄ 运行结果
⛄ 参考文献
[1] 林靖皓, 秦亮曦, 苏永秀,等. 基于自注意力机制的双向门控循环单元和卷积神经网络的芒果产量预测[J]. 计算机应用, 2020, 40(S01):5.
[2] 徐鹏, 皋军, 邵星,等. 一种基于注意力机制和卷积门控循环单元模型的轴承故障诊断方法:, CN114118282A[P]. 2022.
[3] 杨淑莹李军广. 基于注意力机制的门控循环单元网络学生成绩预测[J]. 天津理工大学学报, 2022, 38(4):32-37.