Mercurial > hg > camir-aes2014
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolboxes/RBM/gen_evaluate.m Tue Feb 10 15:05:51 2015 +0000 @@ -0,0 +1,27 @@ +function [ output_args ] = gen_evaluate( data,label,WW,Classes) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% generative classification % +% WW = [W visB hidB] % +% mW: mask of connections % +% -*-sontran2012-*- % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Loading data & label +assert(size(data,1) == size(label,1),'[KRBM-GEN] Number of data and label mismatch'); +lNum = size(Classes); +%% Loading structure +[total visNum]= size(data); +sNum = 500; % fix +bNum = ceil(total/sNum); % divide the testing samples to batches of sNum +%% Classifying +count = 0; +for i=1:bNum + % Find the position of softmax unit which make lowest free energy + L = lowest_fenergy(data((i-1)*sNum + 1:i*sNum,:),WW,lNum,Classes); + count = count + sum(L==label((i-1)*sNum + 1:i*sNum)); +end +L = lowest_fenergy(data(bNum*sNum + 1:total,:),WW,Classes); +count = count + sum(L==label(bNum*sNum + 1:total)); +fprintf('Correct rate: %f (%d/%d)',count/total,count,total; +clear A vars data lNum sNum bNum out; +end +