首页 > 编程知识 正文

像的特征与区域的特征,猪脸识别

时间:2023-05-05 09:53:07 阅读:195346 作者:4112

深度网络既然在图像识别方面有很高的准确率,那将某一层网络输出数据作为图像特征也应该是可行的。该程序给出了使用Alexnet第七层作为激活层提取图像特征的示例。代码如下:

clear;trainPath = fullfile(pwd,'image');trainData = imageDatastore(trainPath,... 'IncludeSubfolders',true,'LabelSource','foldernames');[trainingImages,testImages] = splitEachLabel(trainData,0.7,'randomized');numTrainImages = numel(trainingImages.Labels);%加载预训练模型net = alexnet;%指定用来提取特征的层layer = 'fc7';%提取指定层训练数据特征trainingFeatures = activations(net,trainingImages,layer);%提取指定层测试数据特征testFeatures = activations(net,testImages,layer);%获取训练数据标签trainingLabels = trainingImages.Labels;%获取测试数据标签testLabels = testImages.Labels;save('alexnetFeature.mat','trainingFeatures','trainingLabels','trainingFeatures','testLabels');

相关内容可参看Matlab图像识别/检索系列(7)-10行代码完成深度学习网络之取中间层数据作为特征。

转载于:https://blog.51cto.com/8764888/2086352

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。