1.完整项目描述和程序获取
>面包多安全交易平台:https://mbd.pub/o/bread/ZJeXlZZr
>如果链接失效,可以直接打开本站店铺搜索相关店铺:
>如果链接失效,程序调试报错或者项目合作也可以加微信或者QQ联系。
2.部分仿真图预览
3.算法概述
vgg16总共有16层,13个卷积层和3个全连接层,第一次经过64个卷积核的两次卷积后,采用一次pooling,第二次经过两次128个卷积核卷积后,再采用pooling,再重复两次三个512个卷积核卷积后,再pooling,最后经过三次全连接。
4.部分源码
.......................................................................
train_P = [];
train_T = [];
test_P = [];
test_T = [];
for i=1:length(types)
i
types{i}
trainingImages = imageDatastore(['images/train/' types{i}],'IncludeSubfolders',true,'LabelSource','foldernames');
testImages = imageDatastore(['images/test/' types{i}],'IncludeSubfolders',true,'LabelSource','foldernames');
augimdsTrain = augmentedImageDatastore(inputSize(1:2),trainingImages);
augimdsTest = augmentedImageDatastore(inputSize(1:2),testImages);
trainingFeatures = activations(net,augimdsTrain,'fc8','OutputAs','channels');
testFeatures = activations(net,augimdsTest,'fc8','OutputAs','channels');
train_P = [train_P;squeeze(trainingFeatures(1,1,:,:))'];
train_T = [train_T;trainingImages.Labels];
test_P = [test_P;squeeze(testFeatures(1,1,:,:))'];
test_T = [test_T;testImages.Labels];
end
nest = fitcecoc(train_P,train_T);
[predictedLabels scores]= predict(nest,test_P);
accuracy = mean(predictedLabels == test_T);
targets = zeros(size(scores'));
for i=1:size(test_T,1)
I = find(types==test_T(i));
targets(I(1),i) = 1;
end
cmat = confusionmat(test_T,predictedLabels);
figure;
imagesc(cmat);
xlabel('Target Class');
ylabel('Predicted Class');
title(['VGG16 accuracy= ' num2str(100*accuracy),'%']);
colorbar
figure;
plotroc(targets,scores')
A540