..1 . 1 ..2 ..3 ..5 ..6
1971 2
google 500500100
Datadenowizarddeno wizard7 3imdsTrainimdsValidation
unzip(Data.zip);
imds = imageDatastore(Data,
IncludeSubfolders,true,
LabelSource,foldernames);
[imdsTrain,imdsValidation] = splitEachLabel(imds,0.7,randomized);
subplot(1,2,1);
imshow(Data/deno/deno_03.jpg); title(); subplot(1,2,2); imshow(Data/wizard/wizard_01.jpg); title();
1
GoogleNet 3 loss3-classifierproboutput
net = googlenet;
lgraph = layerGraph(net);
inputSize = net.Layers(1).InputSize;
lgraph = removeLayers(lgraph, {loss3-classifier,prob,output});
numClasses = numel(categories(imdsTrain.Labels));
newLayers = [
fullyConnectedLayer(numClasses,Name,fc,
WeightLearnRateFactor,10,BiasLearnRateFactor,10)
softmaxLayer(Name,softmax)
classificationLayer(Name,classoutput)];
lgraph = addLayers(lgraph,newLayers);
lgraph = connectLayers(lgraph,pool5-drop_7x7_s1,fc);
2
0 freezeWeight 110 0 createLgraphUsingConnections
layers = lgraph.Layers;
connections = lgraph.Connections;
layers(1:110) = freezeWeights(layers(1:110));
lgraph = createLgraphUsingConnections(layers,connections);
30 augimdsTrainaugimdsValidation
pixelRange = [-30 30];
imageAugmenter = imageDataAugmenter(
RandXReflection,true,
RandXTranslation,pixelRange,
RandYTranslation,pixelRange);
augimdsTrain = augmentedImageDatastore(inputSize(1:2),imdsTrain,
DataAugmentation,imageAugmenter);
augimdsValidation = augmentedImageDatastore(inputSize(1:2),imdsValidation);
options = trainingOptions(sgdm,
MiniBatchSize,10,
MaxEpochs,6,
InitialLearnRate,1e-4,
ValidationData,augimdsValidation,
ValidationFrequency,3,
ValidationPatience,Inf,
Verbose,false ,
Plots,training-progress);
214Epoch1Epoch2 90%100%93.33%
net = trainNetwork(augimdsTrain,lgraph,options);
3
4 denowizard
[YPred,probs] = classify(net,augimdsValidation);
idx = randperm(numel(imdsValidation.Files),4);
for i = 1:4
subplot(2,2,i)
I = readimage(imdsValidation,idx(i));
imshow(I)
label = YPred(idx(i));
title(string(label) + , + num2str(100*max(probs(idx(i),:)),3) + %);
end
4
93.33%6.67% 66.7%
500500 google
subplot(2,2,1);
imshow(Data/deno/deno_07.jpg); title(());
subplot(2,2,2); imshow(Data/deno/deno_84.jpg); title(());
subplot(2,2,3); imshow(Data/wizard/wizard_02.jpg); title(()); subplot(2,2,4); imshow(Data/wizard/wizard_51.jpg); title(());
5
5 5% 6.67%
6
Reviews
There are no reviews yet.