1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 【步态识别】基于CNN 步态能量图+HOG特征提取的步态识别算法的MATLAB仿真

【步态识别】基于CNN 步态能量图+HOG特征提取的步态识别算法的MATLAB仿真

时间:2020-03-19 01:46:39

相关推荐

【步态识别】基于CNN 步态能量图+HOG特征提取的步态识别算法的MATLAB仿真

卷积层的结构如下所示:

具体可以看如下的网址:

这个是传统的卷积神经网络。我们按这个进行设计。仿真结果如下:

他的识别率为88.89%。

然后我这里介绍下我们的改进思路,改进思路如下所示:

此外, 影响卷积网络的参数主要为学习率的设置,然后我们通过WOA优化算法计算最优的学习率。关于WOA的原理,请参考文献:

这个部分,将得到的最优的学习率为:0.0408

训练过程为:

通过测试可以知道,

GRNN识别率为80%

CNN的识别率为88.89%

基于改进CNN,识别率为:95.56%

部分核心代码如下:

clc;clear;close all;warning off;addpath 'subfunc\'rng(1);digitDatasetPath = ['步态能量图\'];imds = imageDatastore(digitDatasetPath,'IncludeSubfolders', true, 'LabelSource', 'foldernames');%划分数据为训练集合验证集,训练集中每个类别包含1张图像,验证集包含其余图像的标签numTrainFiles= 1;%设置每个类别的训练个数[imdsTrain, imdsValidation] = splitEachLabel(imds, numTrainFiles, 'randomize');%定义卷积神经网络的基础结构layers = [imageInputLayer([400 150 1]);%注意,400,150为能量图的大小,不能改%第1个卷积层convolution2dLayer(3, 8, 'Padding', 'same');%第一个卷积层batchNormalizationLayer;%第1个激励层reluLayer;%第1个池化层maxPooling2dLayer(2, 'Stride', 2);%第2个卷积层convolution2dLayer(3, 8, 'padding', 'same');batchNormalizationLayer;%第2个激励层reluLayer;%第2个池化层maxPooling2dLayer(2, 'Stride', 2);%第3个卷积层convolution2dLayer(3, 16, 'Padding', 'same');batchNormalizationLayer;%第3个激励层reluLayer;%第3个池化层maxPooling2dLayer(2, 'Stride', 2);%全连接层1fullyConnectedLayer(5);%softmaxsoftmaxLayer;%输出分类结果classificationLayer;];%设置训练参数Num= 10; %搜索数量Iters = 10; %迭代次数D = 1; %搜索空间维数woa_idx= zeros(1,D);woa_get= inf; %初始化种群的个体%初始化种群的个体Xmin = 0;Xmax = 1;xwoa=rand(Num,D);for t=1:Iterstfor i=1:Num%目标函数更新[pa(i)] = fitness(xwoa(i,:),imdsTrain, imdsValidation,layers);Fitout = pa(i);%更新if Fitout < woa_get woa_get = Fitout; woa_idx = xwoa(i,:);endend%调整参数c1 = 2-t*((1)/Iters); c2 =-1+t*((-1)/Iters);%w = 0.1+0.8*(cos(std(pa)));%位置更新for i=1:Numrng(i);r1 = rand();r2 = rand();K1 = 2*c1*r1-c1; K2 = 2*r2; l=(c2-1)*rand + 1; rand_flag = rand(); if rand_flag<0.5 if abs(K1)>=1RLidx = floor(Num*rand()+1);X_rand = xwoa(RLidx, :);D_X_rand = abs(K2*X_rand(1:D)-xwoa(i,1:D)); xwoa(i,1:D)= X_rand(1:D)-K1*D_X_rand;elseD_Leader = abs(K2*woa_idx(1:D)-xwoa(i,1:D)); xwoa(i,1:D)= woa_idx(1:D)-K1*D_Leader; endelsedistLeader = abs(woa_idx(1:D)-xwoa(i,1:D));xwoa(i,1:D) = distLeader*exp(l).*cos(l.*2*pi)+woa_idx(1:D);endend[pb] = fitness(woa_idx,imdsTrain, imdsValidation,layers);endrng(1);options = trainingOptions('sgdm', ...'InitialLearnRate', abs(woa_idx/5), ...'MaxEpochs', 200, ...'Shuffle', 'every-epoch', ...'ValidationData', imdsValidation, ...'ValidationFrequency', 10, ...'Verbose', false, ...'Plots', 'training-progress');%使用训练集训练网络net = trainNetwork(imdsTrain, layers, options);%对验证图像进行分类并计算精度YPred = classify(net, imdsValidation);YValidation = imdsValidation.Labels;accuracy = sum(YPred == YValidation) / numel(YValidation);accuracy

运行结果如下:

A05-77

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。