negative log likelihood

似然函数(likelihood function)

Overview

在机器学习中,似然函数是一种关于模型中参数的函数。“似然性(likelihood)”和"概率(probability)"词意相似,但在统计学中它们有着完全不同的含义:概率用于在已知参数的情况下,预测接下来的观测结果;似然性用于根据一些观测结果,估计给定模型的参数可能值。

Probability is used to describe the plausibility of some data, given a value for the parameter. Likelihood is used to describe the plausibility of a value for the parameter, given some data.

​ —from wikipedia[3]^[3]

其数学形式表示为:

假设XX是观测结果序列,它的概率分布fxf_{x}依赖于参数θ\theta,则似然函数表示为

L(θx)=fθ(x)=Pθ(X=x)L(\theta|x)=f_{\theta}(x)=P_{\theta}(X=x)

Definition

似然函数针对**离散型概率分布(Discrete probability distributions)连续型概率分布(Continuous probability distributions)**的定义通常不同.

离散型概率分布(Discrete probability distributions)

假设XX是离散随机变量,其概率质量函数pp依赖于参数θ\theta,则有

L(θx)=pθ(x)=Pθ(X=x)L(\theta|x)=p_{\theta}(x)=P_{\theta}(X=x)

L(θx)L(\theta|x)为参数θ\theta的似然函数,xx为随机变量XX的输出.

Sometimes the probability of "the value of for the parameter value " is written as P(X = x | θ) or P(X = x; θ).

连续型概率分布(Continuous probability distributions)

假设XX是连续概率分布的随机变量,其密度函数(density function)ff依赖于参数θ\theta,则有

L(θx)=fθ(x)L(\theta|x)=f_{\theta}(x)

最大似然估计(Maximum Likelihood Estimation,MLE)

假设每个观测结果xx是独立同分布的,通过似然函数L(θx)L(\theta|x)求使观测结果XX发生的概率最大的参数θ\theta,即argmaxθf(X;θ)argmax_{\theta}f(X;\theta)

在“模型已定,参数未知”的情况下,使用最大似然估计算法学习参数是比较普遍的。

对数似然(log likelihood)

由于对数函数具有单调递增的特点,对数函数和似然函数具有同一个最大值点。取对数是为了方便计算极大似然估计,MLE中直接求导比价困难,通常先取对数再求导,找到极值点。

负对数似然(negative log-likelihood)

实践中,softmax函数通常和负对数似然(negative log-likelihood,NLL)一起使用,这个损失函数非常有趣,如果我们将其与softmax的行为相关联起来一起理解.首先,让我们写下我们的损失函数:

L(y)=log(y)L(y)=-log(y)

回想一下,当我们训练一个模型时,我们渴望能够找到使得损失函数最小的一组参数(在一个神经网络中,参数指权重weights和偏移biases).

对数函数如下图红线所示:
负对数似然(negative log-likelihood)
由于是对概率分布求对数,概率pp的值为0p10\leq{p}\leq1,取对数后为红色线条在[0,1][0,1]区间中的部分,再对其取负数,得到负对数似然函数如下图所示:
负对数似然(negative log-likelihood)
我们希望得到的概率越大越好,因此概率越接近于1,则函数整体值越接近于0,即使得损失函数取到最小值。

最大似然估计的一般步骤如下:
(1) 写出似然函数;
(2) 对似然函数取对数,得到对数似然函数;
(3) 求对数似然函数的关于参数组的偏导数,并令其为0,得到似然方程组;
(4) 解似然方程组,得到参数组的值.

Reference

[1]王海良,李卓恒,林旭鸣.智能问答与深度学习[M].北京:电子工业出版社,2019:19-20.

[2]Lj Miranda.Understanding softmax and the negative log-likelihood.2017.

​ [link]https://ljvmiranda921.github.io/notebook/2017/08/13/softmax-and-the-negative-log-likelihood/

[3]wikipedia-likelihood function

​ [link]https://en.wikipedia.org/wiki/Likelihood_function#Log-likelihood

相关文章:

  • 2021-12-24
  • 2022-12-23
  • 2021-09-15
  • 2021-06-14
  • 2022-02-01
  • 2022-12-23
  • 2021-06-30
  • 2022-12-23
猜你喜欢
  • 2021-11-15
  • 2021-07-12
  • 2022-12-23
  • 2022-03-10
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案