comparison toolboxes/RBM/gen_evaluate.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 [ output_args ] = gen_evaluate( data,label,WW,Classes)
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % generative classification %
4 % WW = [W visB hidB] %
5 % mW: mask of connections %
6 % -*-sontran2012-*- %
7 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8 %% Loading data & label
9 assert(size(data,1) == size(label,1),'[KRBM-GEN] Number of data and label mismatch');
10 lNum = size(Classes);
11 %% Loading structure
12 [total visNum]= size(data);
13 sNum = 500; % fix
14 bNum = ceil(total/sNum); % divide the testing samples to batches of sNum
15 %% Classifying
16 count = 0;
17 for i=1:bNum
18 % Find the position of softmax unit which make lowest free energy
19 L = lowest_fenergy(data((i-1)*sNum + 1:i*sNum,:),WW,lNum,Classes);
20 count = count + sum(L==label((i-1)*sNum + 1:i*sNum));
21 end
22 L = lowest_fenergy(data(bNum*sNum + 1:total,:),WW,Classes);
23 count = count + sum(L==label(bNum*sNum + 1:total));
24 fprintf('Correct rate: %f (%d/%d)',count/total,count,total;
25 clear A vars data lNum sNum bNum out;
26 end
27