shark::Energy< RBM > Struct Template Reference

The Energy function determining the Gibbs distribution of an RBM. More...

#include <shark/Unsupervised/RBM/Energy.h>

Public Types

typedef RBM::HiddenType HiddenType
 
typedef RBM::VisibleType VisibleType
 
typedef HiddenType::SufficientStatistics HiddenStatistics
 
typedef VisibleType::SufficientStatistics VisibleStatistics
 
typedef HiddenType::StatisticsBatch HiddenStatisticsBatch
 
typedef VisibleType::StatisticsBatch VisibleStatisticsBatch
 

Public Member Functions

 Energy (RBM const &rbm)
 
RealVector energy (RealMatrix const &hidden, RealMatrix const &visible) const
 Calculates the Energy given the states of batches of hidden and visible variables . More...
 
void inputHidden (RealMatrix &inputs, RealMatrix const &visibleStates) const
 Calculates the input of the hidden neurons given the state of the visible in a batch-vise fassion. More...
 
void inputVisible (RealMatrix &inputs, RealMatrix const &hiddenStates) const
 Calculates the input of the visible neurons given the state of the hidden. More...
 
template<class BetaVector >
RealVector logUnnormalizedProbabilityHidden (RealMatrix const &hiddenState, RealMatrix const &visibleInput, BetaVector const &beta) const
 Computes the logarithm of the unnormalized probability of each state of the hidden neurons in a batch by using the precomputed input/activation of the visible neurons. More...
 
template<class BetaVector >
RealVector logUnnormalizedProbabilityVisible (RealMatrix const &visibleState, RealMatrix const &hiddenInput, BetaVector const &beta) const
 Computes the logarithm of the unnormalized probability of each state of the visible neurons in a batch by using the precomputed input/activation of the hidden neurons. More...
 
template<class BetaVector >
RealVector logUnnormalizedProbabilityVisible (RealMatrix const &visibleStates, BetaVector const &beta) const
 Computes the logarithm of the unnormalized probability for each state of the visible neurons from a batch. More...
 
template<class BetaVector >
RealVector logUnnormalizedProbabilityHidden (RealMatrix const &hiddenStates, BetaVector const &beta) const
 Computes the logarithm of the unnormalized probability of each state of the hidden neurons from a batch. More...
 
RealVector energyFromHiddenInput (RealMatrix const &hiddenInput, RealMatrix const &hidden, RealMatrix const &visible) const
 Optimization of the calculation of the energy, when the input of the hidden units is already available. More...
 
RealVector energyFromVisibleInput (RealMatrix const &visibleInput, RealMatrix const &hidden, RealMatrix const &visible) const
 Optimization of the calculation of the energy, when the input of the visible units is already available. More...
 

Detailed Description

template<class RBM>
struct shark::Energy< RBM >

The Energy function determining the Gibbs distribution of an RBM.

General Energy function which uses the information given by the neurons to automatize the calculation of the value of the energy for certain states, the derivative of the energy and the factorization of the probability.

Following (but slightly simplifying from the formulas given by) Welling at al. a general form of an RBM's Energy function is given by \( E(\vec v,\vec h)= f_h(\vec h) + f_v(\vec v) + \sum_{k,l} \phi_{hk}(\vec h) W_{k,l} \phi_{vl}(\vec v) \) We call \( f_h(\vec h) \) and \( f_v(\vec v) \) the term of the Energy (energy term) associated to the hidden or the visible neurons respectively. \( \sum_{k,l} \phi_{hk}(\vec h) W_{k,l} \phi_{vl}(\vec v) \) is called the interaction term. In the standard case of an binary RBM we have \( f_h(\vec h) = \vec h \vec c \) and \( f_v(\vec v) = \vec v \vec b \), where \( \vec c \) and \( \vec b \) are the vectors of the bias parameters for the hidden and the visible neurons respectively. Furthermore, the interaction term simplifies to \( \vec h W \vec v \), so we have just one singe 'phi-function' for each layer that is the identity function.

Definition at line 57 of file Energy.h.

Member Typedef Documentation

◆ HiddenStatistics

template<class RBM >
typedef HiddenType::SufficientStatistics shark::Energy< RBM >::HiddenStatistics

Definition at line 62 of file Energy.h.

◆ HiddenStatisticsBatch

template<class RBM >
typedef HiddenType::StatisticsBatch shark::Energy< RBM >::HiddenStatisticsBatch

Definition at line 66 of file Energy.h.

◆ HiddenType

template<class RBM >
typedef RBM::HiddenType shark::Energy< RBM >::HiddenType

Definition at line 58 of file Energy.h.

◆ VisibleStatistics

template<class RBM >
typedef VisibleType::SufficientStatistics shark::Energy< RBM >::VisibleStatistics

Definition at line 63 of file Energy.h.

◆ VisibleStatisticsBatch

template<class RBM >
typedef VisibleType::StatisticsBatch shark::Energy< RBM >::VisibleStatisticsBatch

Definition at line 67 of file Energy.h.

◆ VisibleType

template<class RBM >
typedef RBM::VisibleType shark::Energy< RBM >::VisibleType

Definition at line 59 of file Energy.h.

Constructor & Destructor Documentation

◆ Energy()

template<class RBM >
shark::Energy< RBM >::Energy ( RBM const &  rbm)
inline

Definition at line 69 of file Energy.h.

Member Function Documentation

◆ energy()

template<class RBM >
RealVector shark::Energy< RBM >::energy ( RealMatrix const &  hidden,
RealMatrix const &  visible 
) const
inline

Calculates the Energy given the states of batches of hidden and visible variables .

Definition at line 75 of file Energy.h.

References shark::batchSize(), shark::Energy< RBM >::energyFromHiddenInput(), shark::Energy< RBM >::inputHidden(), and SIZE_CHECK.

◆ energyFromHiddenInput()

template<class RBM >
RealVector shark::Energy< RBM >::energyFromHiddenInput ( RealMatrix const &  hiddenInput,
RealMatrix const &  hidden,
RealMatrix const &  visible 
) const
inline

Optimization of the calculation of the energy, when the input of the hidden units is already available.

Parameters
hiddenInputthe vector of inputs of the hidden neurons
hiddenthe states of the hidden neurons
visiblethe states of the visible neurons
Returns
the value of the energy function

Definition at line 192 of file Energy.h.

References shark::batchSize().

Referenced by shark::Energy< RBM >::energy().

◆ energyFromVisibleInput()

template<class RBM >
RealVector shark::Energy< RBM >::energyFromVisibleInput ( RealMatrix const &  visibleInput,
RealMatrix const &  hidden,
RealMatrix const &  visible 
) const
inline

Optimization of the calculation of the energy, when the input of the visible units is already available.

Parameters
visibleInputthe vector of inputs of the visible neurons
hiddenthe states of the hidden neurons
visiblethe states of the visible neurons
Returns
the value of the energy function

Definition at line 214 of file Energy.h.

References shark::batchSize().

◆ inputHidden()

template<class RBM >
void shark::Energy< RBM >::inputHidden ( RealMatrix &  inputs,
RealMatrix const &  visibleStates 
) const
inline

Calculates the input of the hidden neurons given the state of the visible in a batch-vise fassion.

Parameters
inputsthe batch of vectors the input of the hidden neurons is stored in
visibleStatesthe batch of states of the visible neurons@
Todo:
Remove this and replace fully by the rbm method if possible

Definition at line 90 of file Energy.h.

References shark::RBM< VisibleLayerT, HiddenLayerT, randomT >::inputHidden().

Referenced by shark::Energy< RBM >::energy(), and shark::Energy< RBM >::logUnnormalizedProbabilityVisible().

◆ inputVisible()

template<class RBM >
void shark::Energy< RBM >::inputVisible ( RealMatrix &  inputs,
RealMatrix const &  hiddenStates 
) const
inline

Calculates the input of the visible neurons given the state of the hidden.

Parameters
inputsthe vector the input of the visible neurons is stored in
hiddenStatesthe state of the hidden neurons
Todo:
Remove this and replace fully by the rbm method if possible

Definition at line 100 of file Energy.h.

References shark::RBM< VisibleLayerT, HiddenLayerT, randomT >::inputVisible().

Referenced by shark::Energy< RBM >::logUnnormalizedProbabilityHidden().

◆ logUnnormalizedProbabilityHidden() [1/2]

template<class RBM >
template<class BetaVector >
RealVector shark::Energy< RBM >::logUnnormalizedProbabilityHidden ( RealMatrix const &  hiddenState,
RealMatrix const &  visibleInput,
BetaVector const &  beta 
) const
inline

Computes the logarithm of the unnormalized probability of each state of the hidden neurons in a batch by using the precomputed input/activation of the visible neurons.

Parameters
hiddenStatethe batch of states of the hidden neurons
visibleInputthe batch of current inputs for he visible units given hiddenState
betathe inverse temperature
Returns
the unnormalized probability

Definition at line 112 of file Energy.h.

References shark::batchSize(), and SIZE_CHECK.

Referenced by shark::Energy< RBM >::logUnnormalizedProbabilityHidden().

◆ logUnnormalizedProbabilityHidden() [2/2]

template<class RBM >
template<class BetaVector >
RealVector shark::Energy< RBM >::logUnnormalizedProbabilityHidden ( RealMatrix const &  hiddenStates,
BetaVector const &  beta 
) const
inline

Computes the logarithm of the unnormalized probability of each state of the hidden neurons from a batch.

Parameters
hiddenStatesa batch of states of the hidden neurons
betathe inverse temperature

Definition at line 179 of file Energy.h.

References shark::Energy< RBM >::inputVisible(), shark::Energy< RBM >::logUnnormalizedProbabilityHidden(), and SIZE_CHECK.

◆ logUnnormalizedProbabilityVisible() [1/2]

template<class RBM >
template<class BetaVector >
RealVector shark::Energy< RBM >::logUnnormalizedProbabilityVisible ( RealMatrix const &  visibleState,
RealMatrix const &  hiddenInput,
BetaVector const &  beta 
) const
inline

Computes the logarithm of the unnormalized probability of each state of the visible neurons in a batch by using the precomputed input/activation of the hidden neurons.

Parameters
visibleStatethe batch of states of the hidden neurons
hiddenInputthe batch of current inputs for he visible units given visibleState
betathe inverse temperature
Returns
the unnormalized probability

Definition at line 141 of file Energy.h.

References shark::batchSize(), and SIZE_CHECK.

Referenced by shark::Energy< RBM >::logUnnormalizedProbabilityVisible().

◆ logUnnormalizedProbabilityVisible() [2/2]

template<class RBM >
template<class BetaVector >
RealVector shark::Energy< RBM >::logUnnormalizedProbabilityVisible ( RealMatrix const &  visibleStates,
BetaVector const &  beta 
) const
inline

Computes the logarithm of the unnormalized probability for each state of the visible neurons from a batch.

Parameters
visibleStatesthe batch of states of the hidden neurons
betathe inverse temperature

Definition at line 166 of file Energy.h.

References shark::Energy< RBM >::inputHidden(), shark::Energy< RBM >::logUnnormalizedProbabilityVisible(), and SIZE_CHECK.


The documentation for this struct was generated from the following file: