网站付款链接怎么做,长沙互联网装修公司,wordpress的html编辑器插件,html5手机资讯网站模板多维时序 | MATLAB实现WOA-CNN鲸鱼算法优化卷积神经网络的数据多变量时间序列预测 目录 多维时序 | MATLAB实现WOA-CNN鲸鱼算法优化卷积神经网络的数据多变量时间序列预测效果一览基本介绍程序设计参考资料 效果一览 基本介绍 多维时序 | MATLAB实现WOA-CNN鲸鱼算法优化卷积神经…多维时序 | MATLAB实现WOA-CNN鲸鱼算法优化卷积神经网络的数据多变量时间序列预测 目录 多维时序 | MATLAB实现WOA-CNN鲸鱼算法优化卷积神经网络的数据多变量时间序列预测效果一览基本介绍程序设计参考资料 效果一览 基本介绍 多维时序 | MATLAB实现WOA-CNN鲸鱼算法优化卷积神经网络的数据多变量时间序列预测 MATLAB实现WOA-CNN鲸鱼算法优化卷积神经网络的数据多变量时间序列预测 输入7个特征输出1个即多输入单输出优化参数为学习率批大小正则化系数。 运行环境Matlab2018及以上,运行主程序main即可其余为函数文件无需运行,所有程序放在一个文件夹,data为数据集 命令窗口输出RMSE、MAE、R2、MAPE。 程序设计
完整程序和数据下载方式(订阅《智能学习》专栏同时获取《智能学习》专栏收录程序3份数据订阅后私信我获取)MATLAB实现WOA-CNN鲸鱼算法优化卷积神经网络的数据多变量时间序列预测专栏外只能获取该程序。
%% 记录最佳参数
Best_pos(1, 2) round(Best_pos(1, 2));
best_lr Best_pos(1, 1);
best_hd Best_pos(1, 2);
best_l2 Best_pos(1, 3);%% 建立模型
% ---------------------- 修改模型结构时需对应修改fical.m中的模型结构 --------------------------
layers [sequenceInputLayer(f_) % 输入层fullyConnectedLayer(outdim) % 输出回归层regressionLayer];%% 参数设置
% ---------------------- 修改模型参数时需对应修改fical.m中的模型参数 --------------------------
options trainingOptions(adam, ... % Adam 梯度下降算法MaxEpochs, 500, ... % 最大训练次数 500InitialLearnRate, best_lr, ... % 初始学习率 best_lrLearnRateSchedule, piecewise, ... % 学习率下降LearnRateDropFactor, 0.5, ... % 学习率下降因子 0.1LearnRateDropPeriod, 400, ... % 经过 400 次训练后 学习率为 best_lr * 0.5Shuffle, every-epoch, ... % 每次训练打乱数据集ValidationPatience, Inf, ... % 关闭验证L2Regularization, best_l2, ... % 正则化参数Plots, training-progress, ... % 画出曲线Verbose, false);%% 训练模型
net trainNetwork(p_train, t_train, layers, options);%% 仿真验证
t_sim1 predict(net, p_train);
t_sim2 predict(net, p_test );%% 数据反归一化
T_sim1 mapminmax(reverse, t_sim1, ps_output);
T_sim2 mapminmax(reverse, t_sim2, ps_output);
T_sim1double(T_sim1);
T_sim2double(T_sim2);
%% 均方根误差
error1 sqrt(sum((T_sim1 - T_train).^2) ./ M);
error2 sqrt(sum((T_sim2 - T_test ).^2) ./ N);
%_________________________________________________________________________%
% The Whale Optimization Algorithm
function [Best_Cost,Best_pos,curve]WOA(pop,Max_iter,lb,ub,dim,fobj)% initialize position vector and score for the leader
Best_poszeros(1,dim);
Best_Costinf; %change this to -inf for maximization problems%Initialize the positions of search agents
Positionsinitialization(pop,dim,ub,lb);curvezeros(1,Max_iter);t0;% Loop counter% Main loop
while tMax_iterfor i1:size(Positions,1)% Return back the search agents that go beyond the boundaries of the search spaceFlag4ubPositions(i,:)ub;Flag4lbPositions(i,:)lb;Positions(i,:)(Positions(i,:).*(~(Flag4ubFlag4lb)))ub.*Flag4ublb.*Flag4lb;% Calculate objective function for each search agentfitnessfobj(Positions(i,:));% Update the leaderif fitnessBest_Cost % Change this to for maximization problemBest_Costfitness; % Update alphaBest_posPositions(i,:);endenda2-t*((2)/Max_iter); % a decreases linearly fron 2 to 0 in Eq. (2.3)% a2 linearly dicreases from -1 to -2 to calculate t in Eq. (3.12)a2-1t*((-1)/Max_iter);% Update the Position of search agents for i1:size(Positions,1)r1rand(); % r1 is a random number in [0,1]r2rand(); % r2 is a random number in [0,1]A2*a*r1-a; % Eq. (2.3) in the paperC2*r2; % Eq. (2.4) in the paperb1; % parameters in Eq. (2.5)l(a2-1)*rand1; % parameters in Eq. (2.5)p rand(); % p in Eq. (2.6)for j1:size(Positions,2)if p0.5 if abs(A)1rand_leader_index floor(pop*rand()1);X_rand Positions(rand_leader_index, :);D_X_randabs(C*X_rand(j)-Positions(i,j)); % Eq. (2.7)Positions(i,j)X_rand(j)-A*D_X_rand; % Eq. (2.8)elseif abs(A)1D_Leaderabs(C*Best_pos(j)-Positions(i,j)); % Eq. (2.1)Positions(i,j)Best_pos(j)-A*D_Leader; % Eq. (2.2)endelseif p0.5distance2Leaderabs(Best_pos(j)-Positions(i,j));% Eq. (2.5)Positions(i,j)distance2Leader*exp(b.*l).*cos(l.*2*pi)Best_pos(j);endendendtt1;curve(t)Best_Cost;[t Best_Cost]
end
参考资料 [1] https://blog.csdn.net/kjm13182345320/article/details/129215161 [2] https://blog.csdn.net/kjm13182345320/article/details/128105718