时序预测 | MATLAB实现基于LSTM长短期记忆神经网络的时间序列预测-递归预测未来(多指标评价)

时序预测 | MATLAB实现基于LSTM长短期记忆神经网络的时间序列预测-递归预测未来(多指标评价)

目录

    • [时序预测 | MATLAB实现基于LSTM长短期记忆神经网络的时间序列预测-递归预测未来(多指标评价)](#时序预测 | MATLAB实现基于LSTM长短期记忆神经网络的时间序列预测-递归预测未来(多指标评价))

预测结果







基本介绍

Matlab实现LSTM长短期记忆神经网络时间序列预测未来(完整程序和数据)

1.Matlab实现LSTM长短期记忆神经网络时间序列预测未来;

2.运行环境Matlab2018及以上,data为数据集,单变量时间序列预测;

3.递归预测未来数据,可以控制预测未来大小的数目,适合循环性、周期性数据预测;

4.命令窗口输出R2、MAE、MAPE、MBE、MSE等评价指标;

程序设计

clike 复制代码
%% 创建混合LSTM网络架构
% 输入特征维度
numFeatures  = f_;
% 输出特征维度
numResponses = 1;
FiltZise = 10;
%  创建"LSTM"模型
    layers = [...
        % 输入特征
        sequenceInputLayer([numFeatures 1 1],'Name','input')
        sequenceFoldingLayer('Name','fold')
        % LSTM特征学习
        lstmLayer(50,'Name','lstm1','RecurrentWeightsInitializer','He','InputWeightsInitializer','He')
        % LSTM输出
        lstmLayer(optVars.NumOfUnits,'OutputMode',"last",'Name','bil4','RecurrentWeightsInitializer','He','InputWeightsInitializer','He')
        dropoutLayer(0.25,'Name','drop3')
        % 全连接层
        fullyConnectedLayer(numResponses,'Name','fc')
        regressionLayer('Name','output')    ];

    layers = layerGraph(layers);
    layers = connectLayers(layers,'fold/miniBatchSize','unfold/miniBatchSize');

%% LSTM训练选项
% 批处理样本
MiniBatchSize =128;
% 最大迭代次数
MaxEpochs = 500;
    options = trainingOptions( 'adam', ...
        'MaxEpochs',500, ...
        'GradientThreshold',1, ...
        'InitialLearnRate',optVars.InitialLearnRate, ...
        'LearnRateSchedule','piecewise', ...
        'LearnRateDropPeriod',400, ...
        'LearnRateDropFactor',0.2, ...
        'L2Regularization',optVars.L2Regularization,...
        'Verbose',false, ...
        'Plots','none');

%% 训练混合网络
net = trainNetwork(XrTrain,YrTrain,layers,options);

参考资料

1\] https://blog.csdn.net/kjm13182345320/article/details/129036772?spm=1001.2014.3001.5502 \[2\] https://blog.csdn.net/kjm13182345320/article/details/128690229

相关推荐
Evand J2 小时前
【TCN与LSTM例程】TCN(时间卷积网络)与LSTM(长短期记忆)训练单输入单输出,用于拟合一段信号,便于降噪。MATLAB
网络·人工智能·matlab·lstm
vvoennvv2 小时前
【Python TensorFlow】 BiTCN-LSTM双向时间序列卷积长短期记忆神经网络时序预测算法(附代码)
python·神经网络·tensorflow·lstm·tcn
机器学习之心1 天前
经典粒子群优化算法PSO-LSTM回归+SHAP分析+多输出+新数据预测!Matlab代码实现
算法·lstm·pso-lstm·shap分析
vvoennvv2 天前
【Python TensorFlow】CNN-BiLSTM-Attention时序预测 卷积神经网络-双向长短期记忆神经网络组合模型带注意力机制(附代码)
python·神经网络·cnn·tensorflow·lstm·bilstm·注意力
vvoennvv2 天前
【Python TensorFlow】CNN-LSTM时序预测 卷积神经网络-长短期记忆神经网络组合模型时序预测算法(附代码)
python·神经网络·cnn·tensorflow·lstm
极客BIM工作室3 天前
LSTM门控机制:本质是神经元构成的小型网络
网络·机器学习·lstm
极客BIM工作室3 天前
LSTM门控结构:乘法设计的必然性分析
rnn·深度学习·lstm
shayudiandian4 天前
RNN与LSTM详解:AI是如何“记住”信息的?
人工智能·rnn·lstm
木头左4 天前
自适应门控循环单元GRU-O与标准LSTM在量化交易策略中的性能对比实验
深度学习·gru·lstm
中文Python5 天前
小白中文Python-双色球LSTM模型出号程序
开发语言·人工智能·python·lstm·中文python·小白学python