京东金融大数据竞赛猪脸识别(3)- 图像特征提取之二

深度网络既然在图像识别方面有很高的准确率,那将某一层网络输出数据作为图像特征也应该是可行的。该程序给出了使用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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值