Classification prediction | Matlab implements NGO-CNN-SVM northern goshawk algorithm optimization convolution support vector machine classification prediction

Classification prediction | Matlab implements NGO-CNN-SVM northern goshawk algorithm optimization convolution support vector machine classification prediction

Classification effect

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

Basic description

1. Matlab implements NGO-CNN-SVM Northern Goshawk algorithm to optimize convolution support vector machine classification prediction (complete source code and data)
2. The optimization parameters are: learning rate, batch processing size, and regularization parameters.
3. There are many pictures, including classification effect diagrams, iterative optimization diagrams, and confusion matrix diagrams.
4.The included case data can be used to directly run main to produce a picture with one click.
Note that the program and data are placed in one folder, and the running environment is Matlab2020 and above.
5. Code features: parametric programming, parameters can be easily changed, code programming ideas are clear, and comments are detailed.
6. Enter multiple features and divide them into four categories.

programming

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

%% 建立模型
lgraph = layerGraph();                                                   % 建立空白网络结构
tempLayers = [
    sequenceInputLayer([num_dim, 1, 1], "Name", "sequence")              % 建立输入层,输入数据结构为[num_dim, 1, 1]
    sequenceFoldingLayer("Name", "seqfold")];                            % 建立序列折叠层
lgraph = addLayers(lgraph, tempLayers);                                  % 将上述网络结构加入空白结构中
tempLayers = [
    convolution2dLayer([3, 1], 16, "Name", "conv_1", "Padding", "same")  % 建立卷积层,卷积核大小[3, 1]16个特征图
    reluLayer("Name", "relu_1")                                          % Relu 激活层

lgraph = addLayers(lgraph, tempLayers);                                  % 将上述网络结构加入空白结构中

tempLayers = [
    sequenceUnfoldingLayer("Name", "sequnfold")                          softmaxLayer("Name", "softmax")                                  % softmax激活层
    classificationLayer("Name", "classification")];                  % 分类层
lgraph = addLayers(lgraph, tempLayers);                              % 将上述网络结构加入空白结构中
lgraph = connectLayers(lgraph, "seqfold/out", "conv_1");             % 折叠层输出 连接 卷积层输入
lgraph = connectLayers(lgraph, "seqfold/miniBatchSize", "sequnfold/miniBatchSize"); 
                                                                     % 折叠层输出连接反折叠层输入
lgraph = connectLayers(lgraph, "relu_2", "sequnfold/in");            % 激活层输出 连接 反折叠层输入

%% 参数设置
options = trainingOptions('adam', ...     % Adam 梯度下降算法
    'MaxEpochs', 500,...                 % 最大训练次数 
    'InitialLearnRate', best_lr,...          % 初始学习率为0.001
    'L2Regularization', best_l2,...         % L2正则化参数
    'LearnRateSchedule', 'piecewise',...  % 学习率下降
    'LearnRateDropFactor', 0.1,...        % 学习率下降因子 0.1
    'LearnRateDropPeriod', 400,...        % 经过训练后 学习率为 0.001*0.1
    'Shuffle', 'every-epoch',...          % 每次训练打乱数据集
    'ValidationPatience', Inf,...         % 关闭验证
    'Plots', 'training-progress',...      % 画出曲线
    'Verbose', false);

%% 训练
net = trainNetwork(p_train, t_train, lgraph, options);

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/133252835