赞
踩
MATLAB实现BO-CNN-BiLSTM贝叶斯优化卷积双向长短期记忆网络多输入分类预测。基于贝叶斯(bayes)优化卷积神经网络-双向长短期记忆网络(CNN-BiLSTM)分类预测,BO-CNN-BiLSTM/Bayes-CNN-BiLSTM多输入分类预测模型,输入多个特征,分四类。
1.优化参数为:学习率,隐含层节点,正则化参数。
2.可视化展示分类准确率等。
3.运行环境matlab2020b及以上。
%% 优化算法参数设置 %参数取值上界(学习率,隐藏层节点,正则化系数) %% 贝叶斯优化参数范围 %% 从主函数中获取训练数据 num_dim = evalin('base', 'num_dim'); num_class = evalin('base', 'num_class'); Lp_train = evalin('base', 'Lp_train'); t_train = evalin('base', 't_train'); T_train = evalin('base', 'T_train'); FiltZise= evalin('base', 'FiltZise'); %% 创建混合CNN-LSTM网络架构 % 创建"CNN-LSTM"模型 layers = [... % 输入特征 sequenceInputLayer([num_dim 1 1],'Name','input') sequenceFoldingLayer('Name','fold') % CNN特征提取 convolution2dLayer([FiltZise 1],32,'Padding','same','WeightsInitializer','he','Name','conv','DilationFactor',1); batchNormalizationLayer('Name','bn') eluLayer('Name','elu') averagePooling2dLayer(1,'Stride',FiltZise,'Name','pool1') % 展开层 sequenceUnfoldingLayer('Name','unfold') % 平滑层 flattenLayer('Name','flatten') % BiLSTM特征学习 bilstmLayer(optVars.NumOfUnits,'Name','bilstm1','RecurrentWeightsInitializer','He','InputWeightsInitializer','He') % LSTM输出 bilstmLayer(32,'OutputMode',"last",'Name','bil4','RecurrentWeightsInitializer','He','InputWeightsInitializer','He') dropoutLayer(0.25,'Name','drop1') % 全连接层 fullyConnectedLayer(num_class,'Name','fc') softmaxLayer('Name','sf') classificationLayer('Name','cf')]; layers = layerGraph(layers); layers = connectLayers(layers,'fold/miniBatchSize','unfold/miniBatchSize'); %% CNNLSTM训练选项 % 批处理样本 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');
[1] https://blog.csdn.net/kjm13182345320/article/details/129036772?spm=1001.2014.3001.5502
[2] https://blog.csdn.net/kjm13182345320/article/details/128690229
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。