forked from omrysendik/DCor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalcNetFeatures.m
38 lines (32 loc) · 1.19 KB
/
CalcNetFeatures.m
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
37
38
function [styleFeatures, ACorrFeatures,DiversityFeatures,SmoothnessFeatures] = CalcNetFeatures(net, img, params)
truncatedNet = net;
truncatedNet.layers = net.layers(1:params.lastLayerNum);
dzdy = [];
res = [];
newRes = vl_simplenn(truncatedNet,single(img),dzdy,res,...
'accumulate', false, ...
'mode', 'test', ...
'conserveMemory', 0, ...
'backPropDepth', 1, ...
'sync', 0, ...
'cudnn', 0) ;
styleFeatures = {};
for k=1:length(params.styleMatchLayerInds)
curLayerInd = params.styleMatchLayerInds(k);
styleFeatures{k} = newRes(curLayerInd+1).x;
end
ACorrFeatures = {};
for k=1:length(params.ACorrMatchLayerInds)
curLayerInd = params.ACorrMatchLayerInds(k);
ACorrFeatures{k} = newRes(curLayerInd+1).x;
end
DiversityFeatures = {};
for k=1:length(params.DiversityMatchLayerInds)
curLayerInd = params.DiversityMatchLayerInds(k);
DiversityFeatures{k} = newRes(curLayerInd+1).x;
end
SmoothnessFeatures = {};
for k=1:length(params.SmoothnessMatchLayerInds)
curLayerInd = params.SmoothnessMatchLayerInds(k);
SmoothnessFeatures{k} = newRes(curLayerInd+1).x;
end