MATLAB实现CNN-BiLSTM卷积双向长短期记忆神经网络多输入多输出,运行环境Matlab2020及以上。采用特征融合的方法,通过卷积网络提取出浅层特征与深层特征并进行联接,对特征通过卷积进行融合,将获得的矢量信息输入LSTM单元。
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
% 创建"CNN-BiLSTM"模型
layers = [...
% 输入特征
sequenceInputLayer([numFeatures 1 1],'Name','input')
sequenceFoldingLayer('Name','fold')
% CNN特征提取
convolution2dLayer(FiltZise,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(128,'Name','lstm1','RecurrentWeightsInitializer','He','InputWeightsInitializer','He')
dropoutLayer(0.25,'Name','drop1')
% BiLSTM输出
bilstmLayer(32,'OutputMode',"last",'Name','bil4','RecurrentWeightsInitializer','He','InputWeightsInitializer','He')
dropoutLayer(0.25,'Name','drop2')
% 全连接层
fullyConnectedLayer(numResponses,'Name','fc')
regressionLayer('Name','output') ];
layers = layerGraph(layers);
layers = connectLayers(layers,'fold/miniBatchSize','unfold/miniBatchSize');
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
%% 训练选项
if gpuDeviceCount>0
mydevice = 'gpu';
else
mydevice = 'cpu';
end
options = trainingOptions('adam', ...
'MaxEpochs',MaxEpochs, ...
'MiniBatchSize',MiniBatchSize, ...
'GradientThreshold',1, ...
'InitialLearnRate',learningrate, ...
'LearnRateSchedule','piecewise', ...
'LearnRateDropPeriod',56, ...
'LearnRateDropFactor',0.25, ...
'L2Regularization',1e-3,...
'GradientDecayFactor',0.95,...
'Verbose',false, ...
'Shuffle',"every-epoch",...
'ExecutionEnvironment',mydevice,...
'Plots','training-progress');
————————————————
版权声明:本文为CSDN博主「机器学习之心」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
MATLAB实现RBF径向基神经网络多输入多输出预测
MATLAB实现BP神经网络多输入多输出预测
MATLAB实现DNN神经网络多输入多输出预测
[1] https://blog.csdn.net/kjm13182345320/article/details/116377961
[2] https://blog.csdn.net/kjm13182345320/article/details/127931217
[3] https://blog.csdn.net/kjm13182345320/article/details/127894261