asb: head /dev/brain > /dev/www

My home, musings, and wanderings on the world wide web.

Why you have, in fact, used a neural network!

Have you ever used a logistic regression? Would you like to be able to say you have used a neural network – perhaps in your next interview? Here’s your cheat code.

NB: NFL applies insomuch as you will have to know what we are talking about in this post. This is not a tutorial.

Logistic regression

A lot has been said and is known about the logistic regression. Refer Chapter 11 for a thorough discussion. I’ll attempt a quick recap.

The learning problem is to learn the distribution of a categorical response conditional on a set of covariates , i.e. . For the binary response case, there are two values that can take, e.g. , , etc. Traditionally, one of the two responses is encoded as and the other . As such, the learning problem is transformed to learning which is modeled as a Bernoulli outcome with probability of success parametrized as . From here, one can write the log likelihood under standard assumptions and maximiize it to obtain the parameter estimate . In this set up, we have still not chosen the function . Different forms of give rise to different classifiers. One choice – the logistic regression – chooses to be:

A tale of two interpretations

Logit regression has been reinterpreted in innumerable ways. Heck, even this post is a rehashing of one of these interpretations. For our sake, however, we will examine two interpretations and their equivalence.

Using the log odds-ratio

The standard intepretation coming from econometrics and the (generalized) linear models camp is the log-odds interpretation. In this interpretation, one linearly models the log of odds-ratio:

Note that rearranging this is equivalent to the defintion of given above. However, what is more important for this discussion is to note that can be written as a function composition – applied on the input vector of covariates () and the parameter vector to be learned (). Here is the logistic function and is the dot product of two vectors.

Using a log-linear model

Another interpretation of a logistic regression is as a log-linear model. The difficulty is that the log-linear method is used to estimate outcomes which have support in whereas we need to model which is a probability distribution with support in [0, 1]. The trick to overcome this is to model – an un-normalized probability for each of the binary outcomes as a log-linear model. The true probability is then realized from by normalizing it over all possible outcomes.

Expnonentiating and summing the two un-normalized probabilities, we get (say) which we use to find a normalized probability distribution:

Note that in this formulation, I use to denote model parameters and not . This is because the parameter estimates are in fact different. Contrast the probability of success across the two interpretations:

This arises out of the fact that the log-linear formulation is over-identified because if we know , we automatically know . The over-identification is resolved by setting which reconciles the two expressions above. See the wiki for an explanation.

Once again, we notice that even this formulation of the logistic regression can be factorized into a function composition where where is the softmax function and is the dot product.

Generalization to the multinomial case with the softmax function

The other advantage to choosing the log-linear formulation is that it is easily generalized to the case of the n-ary categorical variable – equivalent to the multinomial logit case. One can easily replicate the discussion above to derive:

NNs as function composition machinery

The class of neural networks that we are going to use here is the simple feed-forward multi-layer perceptron (MLP). For a quick recap, a MLP is a directed acyclical graph which has each layer fully-connected to the next layer. The simplest MLP will have at least three layers: the input layer (to which the data is fed), an output layer (which outputs the results) and one (or more for deeper architectures) hidden layer. Goodfellow et al. (Ch. 1, p. 5) describe:

A multilayer perceptron is just a mathematical function mapping some set of input values to output values. The function is formed by composing many simpler functions. We can think of each application of a different mathematical function as providing a new representation of the input.

Emphasis added.

In fact, in Figure 1.3, the book provides the MLP graph that represents the log-odds formulation of a logistic regression (as the composition , further decomposing into elementary operations and ).

MLP design of a multinomial logit

Similarly, the log-linear interpretation of the logistic regression model can be used to design an n-ary MLP classifier with the following layers:

  1. Input layer of covariates.
  2. Fully connected hidden layer with n linear units (the function).
  3. Fully connected output layer with a softmax unit (the function).
  • The cost function to be minimized under supervision is the cross-entropy, which it turns out (Goodfellow et al., Ch. 5, pp 131-132), is equivalent to maximizing likelihood of the observed sample.

This here is the blueprint of your cheat code promised in the beginning of the post! ;) See this lecture for a full exposition on this design.

tl;dr

This is the key insight that motivated this article: NNs are arbitrary function composition machinery that can be tuned to learn model parameters. This was illustrated by decomposing the multinomial logistic regression as a (quite shallow, in fact) composition of functions and then re-assembling it as a MLP. Indeed, Bengio (Ch. 2, pp. 15 - 16) summarizes that a diverse set of (machine?) learning techniques such as GLM, kernel machines, decision trees, boosting machines, stacking, and even the human cortex etc. are networks with increasingly complex or deep (à la deep learning) compositions of simple functions.