Free Energy Approximation
Restricted Boltzmann Machines
Machine Learning
Artificial Intelligence
Statistical Mechanics

The Free energy approximation Equation in Restriction Boltzmann Machines

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

Introduction

Restricted Boltzmann Machines (RBMs) are a type of stochastic neural network used for unsupervised learning. They consist of visible and hidden units with symmetric connections between them but none within the layers themselves. Understanding the probabilistic framework of RBMs requires grasping the concept of free energy, a central idea borrowed from statistical physics. In this article, we delve into the free energy approximation equation within RBMs, exploring its importance and providing relevant examples.

Basics of Free Energy in RBMs

In the context of RBMs, free energy is utilized to measure how well the model represents the data. The lower the free energy, the better the representation. Specifically, free energy for a visible vector vv is given by:

F(v)=_i(v_ib_i)22σ_i2_jlog(1+exp(a_j+_iv_iw_ijσ_i))F(v) = - \sum\_{i} \frac{(v\_i - b\_i)^2}{2\sigma\_i^2} - \sum\_{j} \log \left(1 + \exp\left(a\_j + \sum\_{i} \frac{v\_i w\_{ij}}{\sigma\_i}\right)\right)

where: • viv_i represents the visible units • bib_i are the biases of the visible units • σi\sigma_i is the standard deviation of the Gaussian visible units • aja_j is the bias of the hidden units • wijw_{ij} represents the weight between visible unit ii and hidden unit jj

Importance of Free Energy

Free energy is crucial for several reasons:

  1. Model Evaluation: It helps evaluate how well the RBM represents the training data. The lower the free energy, the better the data's energy landscape is fit.
  2. Optimization: The energy landscape guides the optimization process. Gradient descent methods can be applied to minimize the free energy, thereby optimizing the weights and biases of the network.
  3. Inference: During inference, calculating free energy allows the determination of how likely a visible vector is, facilitating the generation of new data samples from the model.

Derivation of Free Energy

Given an RBM with a visible vector vv and hidden vector hh, the joint probability P(v,h)P(v, h) can be expressed using the energy function E(v,h)E(v, h):

P(v,h)=eE(v,h)ZP(v, h) = \frac{e^{-E(v, h)}}{Z}

where Z=v,heE(v,h)Z = \sum_{v, h} e^{-E(v, h)} is the partition function that normalizes the probabilities. The energy function E(v,h)E(v, h) is defined as:

E(v,h)=bTvcThvTWhE(v, h) = - b^T v - c^T h - v^T W h

where bb, cc, and WW are biases of the visible and hidden layers, and weights connecting them, respectively. Free energy F(v)F(v) is then derived by marginalizing over all possible hidden vectors:

F(v)=_i(v_ib_i)22σ_i2_jlog(1+ea_j+_iv_iw_ijσ_i)F(v) = - \sum\_i \frac{(v\_i - b\_i)^2}{2 \sigma\_i^2} - \sum\_j \log \left(1 + e^{a\_j + \sum\_i \frac{v\_i w\_{ij}}{\sigma\_i}}\right)

Example

To exemplify, consider a simple RBM with binary visible and hidden units (common in Bernoulli RBMs). The energy function then simplifies to:

E(v,h)=_ib_iv_i_jc_jh_j_i,jv_iw_ijh_jE(v, h) = - \sum\_i b\_i v\_i - \sum\_j c\_j h\_j - \sum\_{i, j} v\_i w\_{ij} h\_j

For a visible vector vv, free energy becomes:

F(v)=_ib_iv_i_jlog(1+exp(c_j+_iv_iw_ij))F(v) = - \sum\_{i} b\_i v\_i - \sum\_{j} \log\left(1 + \exp\left(c\_j + \sum\_{i} v\_i w\_{ij}\right)\right)

This expression is crucial in determining the RBM's effectiveness in representing input data.

Advantages of the Free Energy Approach

  1. Computational Feasibility: Free energy calculations simplify the marginalization over hidden units, making the learning process computationally feasible.
  2. Facilitates Learning: By leveraging properties of exponential families, the calculation of gradients with respect to parameters becomes tractable.
  3. Generalization: Enhances the RBM's ability to generalize by smoothing energy landscapes and avoiding overfitting to specific configurations.

Summary of Key Points

ConceptExplanation
Free EnergyMeasures representation quality of the data by the model. Lower energy indicates better representation.
Energy FunctionMathematical formulation used to infer the probability distribution across visible and hidden units.
Joint ProbabilityP(v,h)=eE(v,h)ZP(v, h) = \frac{e^{-E(v, h)}}{Z} helps in understanding interactions between variables.
RBM OptimizationMinimizing free energy indicates model optimization, guiding weight and bias adjustment for better data representation.
MarginalizationFree energy simplifies computations by marginalizing hidden variables, crucial for tractable learning and inference algorithms.

Conclusion

The free energy approximation in RBMs is an indispensable tool that aids in model evaluation, optimization, and inference. Understanding its principles lays the groundwork for advancing machine learning models and algorithms, enhancing their ability to learn from data in unsupervised settings. Exploring these foundations equips practitioners with the knowledge to harness RBMs' full potential in diverse applications including pattern recognition, collaborative filtering, and feature learning.


Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

All Rights Reserved.