https://groups.google.com/forum/#!topic/matconvnet/m2BPIPVxB5o
I've used imagenet pretrained model for training my dataset. Here is my code:
net = load('YourTrainedModel.mat');
mdl.classes = net.net_classes;
mdl.layers = net.net_layers;
mdl.layers{end}.type = 'softmax';
ds=load('YourDataSet.mat');
trainSet = [ones(1,numel(ds.y2)) 3*ones(1,numel(ds.y2))];
data = single(reshape(cat(4,ds.x1,ds.
dataMean = mean(data(:,:,:,trainSet == 1), 4);
testSize = size(ds.y2,2);
confMat = zeros(numOfClasses, numOfClasses);
i=1;
while i<=testSize
im=ds.x2(:,:,:,i);
im_ = single(im);
im_=im_-dataMean;
res = vl_simplenn(mdl, im_) ;
scores1= squeeze(gather(res(end).x)) ;
[bestScore, best] = max(scores);
confMat(ds.y2(1,i),best) = confMat(ds.y2(1,i),best)+1;
i = i+1;
end
for i=1:numOfClasses
s = sum(confMat(i,:));
for j=1:numOfClasses
confMat(i,j) = confMat(i,j)/s*100;
end
end
'Deep Learning > Matconvnet' 카테고리의 다른 글
matconvnet 테스트 이미지에 딥러닝모델 적용하고, 피쳐 뽑아 SVM으로 분류하는 예제 (1) | 2017.05.15 |
---|---|
assertition failed vl_simplenn.m (0) | 2017.05.13 |