-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFetchAndLearn.m
More file actions
27 lines (19 loc) · 996 Bytes
/
Copy pathFetchAndLearn.m
File metadata and controls
27 lines (19 loc) · 996 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
function [Tab] = FetchAndLearn(netFilePath,layer)
if (~exist('netFilePath', 'var'))
netFilePath = 'CNN.mat';
end
%%Inizializzo un data store e creo la partizione di test
imdstr = imageDatastore('contrasted','IncludeSubfolders',true,'LabelSource','foldernames');
load(netFilePath, 'netTransfer');
%%Ridimensiono le immagini in modo che siano compatibili con l'input di
%%densenet e faccio una dataset augmentation
inputSize = netTransfer.Layers(1).InputSize;
augimds = augmentedImageDatastore(inputSize(1:2),imdstr);
%%Scelgo che layer deve fermarsi la rete, in modo da estrarre le features,
%%usando una rete pretrained ho una particolare efficenza a livello computazionale in
%%quanto estraggo le features scorrendo una sola volta i dati di input
%%richiedendo le attivazioni del layer con la funzione activations
features = activations(netTransfer,augimds,layer,'OutputAs','rows');
save(netFilePath, 'netTransfer', 'layer');
Tab = table(features, imdstr.Labels);
end