-
Notifications
You must be signed in to change notification settings - Fork 0
/
cnntest.m
32 lines (27 loc) · 875 Bytes
/
cnntest.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
function [er, bad, h] = cnntest(net, x, y, opts)
% feedforward
flag=0;
net{opts.row+1,1}.fv=[];
net{opts.row+1,1}.ffW=[];
net{opts.row+1,1}.o=[];
for nrow=1:opts.row+1
for ncol=1:opts.col
if nrow==opts.row+1 && ncol~=opts.col
continue;
end
% ignore bypassed patches
if nrow<=opts.row && ~net{opts.row+1,1}.pindex(nrow,ncol)
continue;
end
net{nrow,ncol} = cnnff(net{nrow,ncol}, x{nrow,ncol},flag);
net{opts.row+1,1}.fv=[net{opts.row+1,1}.fv;net{nrow,ncol}.fv];
net{opts.row+1,1}.ffW=[net{opts.row+1,1}.ffW,net{nrow,ncol}.ffW];
end
end
% fc output
net{opts.row+1,1}.o=softmax(net{opts.row+1,1}.ffW,net{opts.row+1,1}.fv,net{opts.row+1,1}.ffb);
[~, h] = max(net{opts.row+1,1}.o);
[~, a] = max(y{1,1});
bad = find(h ~= a);
er = numel(bad) / size(y{1,1}, 2);
end