Wednesday 5 December 2018

testDNN analysis 10

% v2hall: to transform from visible (input) variables to all hidden (output) variables
%
% Hall = h2val(dnn, V)
%
%
%Output parameters:
% Hall: all hidden (output) variables, where # of row is number of data and # of col is # of hidden (output) nodes
%
%
%Input parameters:
% dnn: the Deep Neural Network model (dbn, rbm)
% V: visible (input) variables, where # of row is number of data and # of col is # of visible (input) nodes
%
%
%Version: 20130727

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Deep Neural Network:                                     %
%                                                          %
% Copyright (C) 2013 Masayuki Tanaka. All rights reserved. %
%                    mtanaka@ctrl.titech.ac.jp             %
%                                                          %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Hall = v2hall(dnn, V) %  dnn.rbm{i}(512 x 128, 128 x 132, 32 x 4), V(250 x 512)

if( isequal(dnn.type(3:5), 'RBM') ) % BBRBM
    Hall = cell(1,1);
    Hall{1} = sigmoid( bsxfun(@plus, V * dnn.W, dnn.b ) );

elseif( isequal(dnn.type(3:5), 'DBN') ) % BBDBN
    nrbm = numel( dnn.rbm ); % 3
    Hall = cell(nrbm,1); % 3 x 1
    H0 = V; % 1000 x 32  , 250 x 512

    for i=1:nrbm % 1:3
        H1 = v2h( dnn.rbm{i}, H0 ); % dnn.rbm{i}.type = BBRBM
        H0 = H1;
        Hall{i} = H1; % 1000 x 4(i=3) <- 1000="" 128="" 16="" 250="" 32="" 4="" 8="" i="1) " nbsp="" p="" x="">
    end
end