annotate toolboxes/RBM/lowest_fenergy.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 L = lowest_fenergy(V,W,visB,hidB,Classes)
wolffd@0 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 3 % Return the labels L(Classes) to the lowest energy softmax unit %
wolffd@0 4 % visP: hidden states %
wolffd@0 5 % visN: reconstructed data (with softmax) %
wolffd@0 6 % WW = [W visB hidB] %
wolffd@0 7 % F(v) = -\sum_i v_ia_i - \sum_jlog(1+e^(x_j)) %
wolffd@0 8 % -*-sontran2012-*- %
wolffd@0 9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 10 lNum = size(Classes,2);
wolffd@0 11 sNum = size(V,1);
wolffd@0 12 F = zeros(sNum,lNum);
wolffd@0 13 out = zeros(sNum,lNum);
wolffd@0 14 for i=1:lNum
wolffd@0 15 F(:,i) = 1;
wolffd@0 16 X = [V F]*W + repmat(hidB,sNum,1);
wolffd@0 17 out(:,i) = sum(repmat(visB,sNum,1).*[V F],2) + sum(log(1+exp(X)),2);
wolffd@0 18 F(:,i) = 0;
wolffd@0 19 end
wolffd@0 20 L = softmax2discrete(out,Classes);
wolffd@0 21 end
wolffd@0 22