-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKanserTransferCode.m
More file actions
36 lines (30 loc) · 966 Bytes
/
Copy pathKanserTransferCode.m
File metadata and controls
36 lines (30 loc) · 966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
clear
clc
fpath = '/Users/emirhanzeyrek/Documents/MATLAB/LessonTrain';
data = fullfile(fpath, 'veriSeti');
tdata = imageDatastore(data, 'IncludeSubfolders', true, 'LabelSource', 'foldername');
tdata = shuffle(tdata);
[trainRatio, valRatio, testRatio] = deal(0.7, 0.15, 0.15);
[trainingData, validationData, testData] = splitEachLabel(tdata, trainRatio, valRatio, testRatio, 'randomized');
net=alexnet;
layers=[
imageInputLayer([227 227])
net(2:end-3)
fullyConnectedLayer(3)
softmaxLayer
classificationLayer()
];
options=trainingOptions( ...
'sgdm', ...
'MiniBatchSize', 32, ...
'MaxEpochs',30, ...
'InitialLearnRate',0.0001, ...
'ValidationFrequency', 50, ...
'Plots', ...
'training-progress' ...
);
net = trainNetwork(trainingData,layers,options);
[Ypred,scores] = classify(net,testData);
accuracy = mean(Ypred == testData.Labels);
confusionchart(Ypred,testData.Labels);
save egitimli_agKanserTransfer