Search This Blog

Showing posts with label Deep Learning. Show all posts
Showing posts with label Deep Learning. Show all posts

Saturday, April 22, 2017

Variational Inference - Part 1

Introduction

Practically intractable inference tasks emerges in several problems. For this reason the computation of the marginal or posterior probabilities has to be tackled in an approximate fashion.
Our objective is to approximate an intractable distribution using a simpler distribution . The more obvious choice for quantifying the diversity of two distributions, is the Kullback-Leibler divergence:

We could have chosen the but the expectation w.r.t. is assumed to be intractable.
We can observe that and is zero only if the two distributions are identical.

Inference as Optimization

Suppose that the probabilistic model we are focusing on is composed by observed variables, globally denoted as and latent variables, globally denoted as . Usually we want to compute the posterior distribution:

Where represents the alphabet containing the possible values of the hidden variables .
The presence of the and the necessary marginalization over , makes very difficult the exact computation of the .

In Variational Inference, we seek for a function that approximates the exact conditional . The inference problem is transformed in an optimization problem where we want to minimize the “distance” between the two distributions:

The objective is again not computable. In fact it depends on the Observed Data Log Likelihood :

Instead of minimizing the KL divergence, we optimize another function that is linked to the original objective.

The Evidence Lower Bound

The Observed Data Log Likelihood can be rewritten using an arbitrary distribution over the hidden variables:

Since is a concave function, using Jensen’s Inequality for the Observed Data Log Likelihood, we obtain:

where is the Evidence Lower Bound defined as:

For any choice of , is a lower bound for the Observed Data Log Likelihood.
We can observe that the Evidence Lower Bound is composed by two contributions (an Energy Term and an Entropic Term):

Difference between Likelihood and Evidence Lower Bound

An important observation is that the difference between the Observed Data Log Likelihood and the Evidence Lower Bound is proper the KL-divergence between the distribution and the posterior distribution (use (4) and (8)):

When is a good approximation of , the lower bound is closer to and, in particular, when the approximation is perfect (), .

In this way instead of reducing directly , we can find the that maximizes .

The maximization of reduces and provides, at the same time, an approximation of the posterior and of the log evidence (because tends to zero).

Now an important point is to find a family function that contains and that makes the optimization problem simpler.

References

  • K. Murphy, Machine Learning: A Probabilistic Approach (§21)
  • D. Barber, Bayesian Reasoning and Machine Learning (§28.3)
  • I. Goodfellow et al., Deep Learning (§19.1)
  • D. Blei et al., Variational Inference: A Review for Statisticians
Written using StackEdit [https://stackedit.io/editor#]

Sunday, July 17, 2016

Convolutional Layer of CNN in one Picture

A complete course at Stanford has devoted to Convolutional Neural Network.
The Course Notes (by Andrej Karpathy) are well written and they worth a look.

That course notes have inspired me to create a picture for summarising some concepts.



An interesting summary (adapted from here ) is the following:

Input Layer

  • Size: $W_1 \times H_1 \times D_1$
  • Hyperparameters:
    • Number of filters $K$
    • Dimension of the filter $F \times F \times D_1$
    • Stride: $S$
    • Amount of Zero Padding: $P$
Output Layer
  • Size: $W_2 \times H_2 \times D_2$
  • $W_2 = \frac{W_1 - F + 2P}{S} + 1$
  • $H_2 = \frac{H_1 - F + 2P}{S} + 1$
  • $D_2 = K$
The parameter sharing introduces $F \times F \times D_1$ per filter, for a total of $(F \times F \times D_1) \times K$ weights and $K$ biases

In the output volume, the d-th depth slice (of size $W_2 \times H2$) is the result of performing a valid convolution of the d-th filter over the input volume with a stride of $S$, and then offset by d-th bias.

Another interesting post on the Convolutional Neural Network is here

Saturday, July 16, 2016

TensorFlow on Databricks

TensorFlow is an Open Source Software Library for Machine Learning and AI tasks.
In these months is becoming a widely used tool in the AI community (and not only).

Databricks is an interesting Cluster Manager based on Apache Spark. It offers a Community Edition for free (pricing).

Since some ML tasks can be very computational intensive (e.g. training of the Deep Networks) could be a good idea to have a Cluster on Databricks and use it.

You can run this Notebook on your Databricks cluster (or import it).
Even though the Notebook says that "It is not required for the Databricks Community Edition", I experimented that it is necessary for the Community Edition as well.