基于自组织长短期记忆神经网络的时间序列预测(MATLAB)

LSTM是为了解决RNN 的梯度消失问题而诞生的特殊循环神经网络。该网络开发了一种异于普通神经元的节点结构,引入了3 个控制门的概念。该节点称为LSTM 单元。LSTM 神经网络避免了梯度消失的情况,能够记忆更长久的历史信息,更能有效地拟合长期时间序列数据的变化趋势。因此,如今在语音识别,序列预测等方面,LSTM 被广泛地应用于这些领域,取得了很多丰硕的成果。在构建 LSTM 网络的过程中,结构的确定是一大挑战。大多数方法都是采用启发式的方式确定最佳的隐藏层神经元个数,效率大大降低。为了解决这一问题,自组织方法被广泛应用于此。自组织方法大致有两个方向,增加神经元个数以及减少神经元个数,通常被称为生长以及剪枝。比如如下的基于敏感度分析的一种自组织 LSTM 神经网络的预测算法:

鉴于此,采用一种基于自组织长短期记忆神经网络进行时间序列预测,运行环境为MATLAB 2018。

Matlab 复制代码
function  [TrainTargets,TrainOutputs] = fuzzfcm(x)
x = x';
%
Delays = [1 2 3];
[Inputs, Targets] = TimeSeries(x, Delays);
Inputs = Inputs';
Targets = Targets';
nData = size(Inputs,1);

% Shuffling Data
PERM = 1:nData; % Permutation to Shuffle Data
%
pTrain=0.80;
nTrainData=round(pTrain*nData);
TrainInd=PERM(1:nTrainData);
TrainInputs=Inputs(TrainInd,:);
TrainTargets=Targets(TrainInd,:);
%
pTest=1-pTrain;
nTestData=nData-nTrainData;
TestInd=PERM(nTrainData+1:end);
TestInputs=Inputs(TestInd,:);
TestTargets=Targets(TestInd,:);

%% FCM FIS Generation Method and Parameters       
        nCluster=10;        
        Exponent=2;       
        MaxIt=100;          
        MinImprovment=1e-5;  
        DisplayInfo=1;
        FCMOptions=[Exponent MaxIt MinImprovment DisplayInfo];
        fis=genfis3(TrainInputs,TrainTargets,'sugeno',nCluster,FCMOptions);
        
% Training ANFIS Structure
MaxEpoch=100;                 
ErrorGoal=0;                
InitialStepSize=0.01;         
StepSizeDecreaseRate=0.9;     
StepSizeIncreaseRate=1.1;    
TrainOptions=[MaxEpoch ...
              ErrorGoal ...
              InitialStepSize ...
              StepSizeDecreaseRate ...
              StepSizeIncreaseRate];
DisplayInfo=true;
DisplayError=true;
DisplayStepSize=true;
DisplayFinalResult=true;
DisplayOptions=[DisplayInfo ...
                DisplayError ...
                DisplayStepSize ...
                DisplayFinalResult];
OptimizationMethod=1;
% 0: Backpropagation
% 1: Hybrid
fis=anfis([TrainInputs TrainTargets],fis,TrainOptions,DisplayOptions,[],OptimizationMethod);

% Apply ANFIS to Data
Outputs=evalfis(Inputs,fis);
TrainOutputs=Outputs(TrainInd,:);
TestOutputs=Outputs(TestInd,:);

% Error Calculation
TrainErrors=TrainTargets-TrainOutputs;
TrainMSE=mean(TrainErrors.^2);
TrainRMSE=sqrt(TrainMSE);
TrainErrorMean=mean(TrainErrors);
TrainErrorSTD=std(TrainErrors);
%
TestErrors=TestTargets-TestOutputs;
TestMSE=mean(TestErrors.^2);
TestRMSE=sqrt(TestMSE);
TestErrorMean=mean(TestErrors);
TestErrorSTD=std(TestErrors);

%Results
% figure;
% PlotResults(TrainTargets,TrainOutputs,'Train Data');
% figure;
% PlotResults(TestTargets,TestOutputs,'Test Data');
% figure;
% PlotResults(Targets,Outputs,'All Data');
% figure;
%     plotregression(TrainTargets, TrainOutputs, 'Train Data', ...
%                    TestTargets, TestOutputs, 'Test Data', ...
%                    Targets, Outputs, 'All Data');

完整代码:https://mbd.pub/o/bread/mbd-ZJ2Ykpxs


end

擅长领域:现代信号处理,机器学习,深度学习,数字孪生,时间序列分析,设备缺陷检测、设备异常检测、设备智能故障诊断与健康管理PHM等。

相关推荐
han_hanker5 分钟前
重新认识枚举enum
开发语言
sunywz12 分钟前
【AI RAG知识库】05.【导入】【节点5】node_item_name_recognition
人工智能
彩云回13 分钟前
长文档处理(Long Document Processing)策略
人工智能
AIGS00120 分钟前
企业AI落地:从RAG到AgentRAG的技术跃迁
java·人工智能·人工智能ai大模型应用
程序员cxuan22 分钟前
Claude Code 焚诀(一):Claude Code 六种心智模型
人工智能·后端
FlagOS智算系统软件栈27 分钟前
FlagOS技术工作坊:当AI开始“自己部署自己”,大模型基础设施进入“无人驾驶”时代
人工智能
Tairitsu_H32 分钟前
[LC优选算法#18] 前缀和 | 除⾃⾝以外数组的乘积 | 和为K的⼦数组 | 和可被K整除的⼦数组
算法·前缀和·哈希算法
一楼的猫33 分钟前
AI写作检测机制技术深度解析:200+维度检测、叙事指纹与网文AI辅助怎么过审
人工智能·学习·安全·chatgpt·ai写作
心中有国也有家38 分钟前
鸿蒙 Flutter 本地存储实战:Hive CE 从入门到精讲
人工智能·hive·flutter·华为·harmonyos
雪隐43 分钟前
用Flutter做背单词APP-01服务器?不存在的,我家里就有
前端·人工智能·后端