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