时序预测 | 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

相关推荐
智码看视界12 小时前
第4篇:循环神经网络及其变体 LSTM/GRU 实战
python·自然语言处理·gru·lstm·循环神经网络·情感分析·梯度消失
zx_741484813 天前
【深度学习入门】循环神经网络(RNN)与长短期记忆网络(LSTM)详解
rnn·深度学习·lstm
在所不辞兄8 天前
【零基础学智能仿真-16】循环神经网络与LSTM/GRU——学习力学响应的历史记忆
人工智能·rnn·神经网络·gru·lstm·工程技术·工程仿真
简简单单做算法8 天前
基于鲸鱼算法和贝叶斯联合优化的BiLSTM(WOA-BO-BiLSTM)一维时间序列预测算法matlab仿真
matlab·时间序列预测·鲸鱼算法·贝叶斯联合优化·woa-bo-bilstm
2601_9620990810 天前
在Python中使用LSTM和PyTorch进行时间序列预测
pytorch·机器学习·lstm·时间序列预测·数据预处理
LlmCraft|大模型工程实践14 天前
【PyTorch NLP实战】从零实现 LSTM 酒店评论情感分析(附完整代码逐行讲解)
pytorch·自然语言处理·lstm
空堂与归16 天前
RNN记不住长序列怎么办?用 LSTM 三门一通道接旁路
人工智能·rnn·nlp·lstm
现代野蛮人16 天前
【深度学习实验】—— 基于 LSTM 与 Optuna 调参的丙型肝炎预测
人工智能·深度学习·lstm
Zguigo18 天前
【DL】GRU|update gate|reset gate
rnn·gru·lstm
Zguigo22 天前
【DL】LSTM|Cell State|三个门
人工智能·rnn·lstm