Classification prediction | MATLAB implements PSO-CNN particle swarm algorithm to optimize convolutional neural network data classification prediction

Classification prediction | MATLAB implements PSO-CNN particle swarm algorithm to optimize convolutional neural network data classification prediction

Classification effect

Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here

Basic description

1.Matlab implements PSO-CNN multi-feature classification prediction, multi-feature input model, running environment Matlab2018b and above;
2. Optimize convolutional neural network (CNN) classification prediction based on particle swarm algorithm (PSO), the optimization parameters are, learning rate, Batch processing, regularization parameters;
3. Two-class and multi-class models with multiple feature inputs and single output. The comments in the program are detailed and can be used by directly replacing the data;
the programming language is matlab, and the program can produce classification effect diagrams, iterative optimization diagrams, and confusion matrix diagrams;
4. data is a data set, input 12 features, divided into four categories; main is The main program, the rest are function files, no need to run, data and program content can be obtained in the download area.

programming

%%  优化算法参数设置
SearchAgents_no = 3;                  % 数量
Max_iteration = 5;                    % 最大迭代次数
dim = 3;                              % 优化参数个数

 
%% 建立模型
lgraph = [
 
 convolution2dLayer([1, 1], 32)  % 卷积核大小 3*1 生成32张特征图
 batchNormalizationLayer         % 批归一化层
 reluLayer                       % Relu激活层

 dropoutLayer(0.2)               % Dropout层
 fullyConnectedLayer(num_class, "Name", "fc")                     % 全连接层
 softmaxLayer("Name", "softmax")                                  % softmax激活层
 classificationLayer("Name", "classification")];                  % 分类层




%% 参数设置
options = trainingOptions('adam', ...     % Adam 梯度下降算法
    'MaxEpochs', 10,...                 % 最大训练次数 
    'MiniBatchSize',best_hd, ...
    'InitialLearnRate', best_lr,...          % 初始学习率为0.001
    'L2Regularization', best_l2,...         % L2正则化参数
    'LearnRateSchedule', 'piecewise',...  % 学习率下降
    'LearnRateDropFactor', 0.1,...        % 学习率下降因子 0.1
    'LearnRateDropPeriod', 400,...        % 经过800次训练后 学习率
%% 训练
net = trainNetwork(p_train, t_train, lgraph, options);

%% 预测
t_sim1 = predict(net, p_train); 
t_sim2 = predict(net, p_test ); 

References

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

Guess you like

Origin blog.csdn.net/kjm13182345320/article/details/133385902