Mercurial > hg > camir-aes2014
comparison toolboxes/RBM/gen_classify.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function [count total] = gen_classify(W, visB, hidB,mW,test_file,test_label); | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % RBM for generative classification % | |
4 % conf: training setting % | |
5 % WW = [W visB hidB] % | |
6 % mW: mask of connections % | |
7 % -*-sontran2012-*- % | |
8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
9 %% Loading data & label | |
10 vars = whos('-file', test_file); | |
11 A = load(test_file,vars(1).name); | |
12 data = A.(vars(1).name); | |
13 vars = whos('-file', test_label); | |
14 A = load(test_label,vars(1).name); | |
15 label = A.(vars(1).name); | |
16 assert(size(data,1) == size(label,1),'[KRBM-GEN] Number of data and label mismatch'); | |
17 Classes = unique(label)'; | |
18 lNum = size(Classes,2); | |
19 %% Loading structure | |
20 [total visNum]= size(data); | |
21 sNum = 500; % fix | |
22 bNum = floor(total/sNum); % divide the testing samples to batches of sNum | |
23 %% Classifying | |
24 count = 0; | |
25 for i=1:bNum | |
26 % Find the position of softmax unit which make lowest free energy | |
27 L = lowest_fenergy(data((i-1)*sNum + 1:i*sNum,:),W, visB, hidB,Classes); | |
28 count = count + sum(L==label((i-1)*sNum + 1:i*sNum)); | |
29 end | |
30 L = lowest_fenergy(data(bNum*sNum + 1:total,:),W, visB, hidB,Classes); | |
31 count = count + sum(L==label(bNum*sNum + 1:total)); | |
32 fprintf('Correct rate: %f (%d/%d)\n',count/total,count,total); | |
33 clear A vars data lNum sNum bNum out; | |
34 end | |
35 |