微❤关注“电气仔推送”获得资料(专享优惠)
程序内容:
该程序是预测类的基础性代码,程序对河北某地区的气象数据进行详细统计,程序最终得到pm2.5的预测结果,通过更改数据很容易得到风速预测结果。程序主要分为三部分,分别是基于LSTM算法、基于ELM算法和基于LSTM和批处理组合算法,本次提供的三种基础性代码是对同一数据进行处理分析,并得到相应的预测结果,程序采用matlab编写,无需其他软件包,注释清楚,方便学习,可自行跟换数据!
部分程序:
%%% 权重更新函数
data_length=size(train_data,1);
data_num=size(train_data,2);
weight_preh_h_temp=weight_preh_h;
%% 更新weight_preh_h权重
for m=1:output_num
delta_weight_preh_h_temp(:,m)=2*Error(m,1)*pre_h_state;
end
weight_preh_h_temp=weight_preh_h_temp-yita*delta_weight_preh_h_temp;
%% 更新weight_outputgate_x
for num=1:output_num
for m=1:data_length
delta_weight_outputgate_x(m,:)=(2*weight_preh_h(:,num)*Error(num,1).*tanh(cell_state(:,n)))'.*exp(-output_gate_input).*(output_gate.^2)*train_data(m,n);
end
weight_outputgate_x=weight_outputgate_x-yita*delta_weight_outputgate_x;
end
%% 更新weight_inputgate_x
for num=1:output_num
for m=1:data_length
delta_weight_inputgate_x(m,:)=2*(weight_preh_h(:,num)*Error(num,1))'.*output_gate.*(ones(size(cell_state(:,n)))-tanh(cell_state(:,n)).^2)'.*gate.*exp(-input_gate_input).*(input_gate.^2)*train_data(m,n);
end
输出结果: