From a statistical learning perspective, modern neural networks can indeed be understood as a large-scale maximum likelihood estimation (MLE) process. Specifically, a neural network is a parameterized function, and the most common way to train a neural network is to perform maximum likelihood estimation on the data.
Coin Tossing
MLE (Maximum Likelihood Estimation) is one of the core ideas in statistics.
One-sentence summary:
MLE selects, from all possible model parameters, the one that "makes the observed data most likely."
Below, you find a damaged coin with uneven texture. So you don't know if it is fair. That is, when you toss this coin, you don't know the probability of heads or tails. You want to know: what is the probability of getting heads.
Thus, you decide to toss it 10 times consecutively and obtain the following result: heads 8 times, tails 2 times.
Suppose this were a fair coin. Then we set the prior hypothesis .
Under this prior hypothesis, the probability of obtaining the above result is:
That is, if this were a fair coin, then the probability of getting 8 heads and 2 tails in 10 tosses is about — clearly, this number is considered impossible in probability and statistics. So you can clearly feel that this coin is not fair.
Now we propose another hypothesis: suppose the probability of heads is . Then the probability of the above result is:
We also find that when , the probability of the above result is maximized, achieving the maximum value .
This shows that if the probability of heads is 0.8, then the likelihood of observing this data is greatest.
Thus:
This is maximum likelihood estimation.
Likelihood Function
Given data:
Suppose we have model parameters: .
The likelihood function is defined as:
Maximum Likelihood Estimation (MLE) is:
Many people feel confused when first learning this:
Since and have exactly the same expression, why change the name?
The key lies in different perspectives:
- Probability perspective:
The parameter is a fixed known value, while the data is random.
We ask: "Given the parameter, how likely are different data outcomes?" - Likelihood perspective:
The data is a fixed observed value, while the parameter is a varying unknown quantity.
We ask: "Under different parameter values, how likely is this observed data?"
According to the conditional formula:
If the data contains many samples, multiplying many small numbers yields a result approaching zero, which can cause numerical underflow in computers.
Thus we take the logarithm, converting multiplication into addition:
After taking the logarithm, the values stay within an acceptable range, making optimization easier.
Therefore, almost all practical training optimizes:
This form is called Log-Likelihood.
In the likelihood function, we need to find the parameter that maximizes the likelihood.
Solving for Parameters
If is differentiable, typically satisfies:
And the second-order condition ensures a maximum:
Take the simplest Bernoulli distribution as an example:
- Data
- Model:
We have the likelihood function:
Convert to log-likelihood:
Take the derivative with respect to and set to 0:
Solve to obtain:
In neural networks, the MLE parameter corresponds to the network's weights and biases, typically denoted as:
where is the number of layers, is the weight matrix of the -th layer, and is the bias vector.
In other words: a neural network is a function family
It defines the conditional probability distribution:
Training a neural network = selecting parameters that maximize the probability of the observed data:
Take classification as an example: a binary classification neural network outputs:
We see that maximizing the likelihood can be written as minimizing the cross-entropy loss function as the cost function:
Finally, we obtain the cross-entropy loss:
Here represents all weights and biases.
Take regression as another example: suppose
Log-likelihood:
We see that the maximum likelihood objective is equivalent to minimizing the mean squared error, where = the weights and biases of the neural network.
The hidden assumption here is that the errors follow a Gaussian distribution. If we instead assume a Laplace distribution, MLE would lead to the MAE loss. This explains why different tasks choose different loss functions — they correspond to different assumptions about the data distribution.
In neural networks, maximum likelihood estimation means finding, among all possible combinations of weights and biases, the set that makes the training data most likely to occur.
Therefore, every time we use gradient descent to update weights, we are essentially performing MLE optimization.