logistic回归和softmax回归

时间:2023-03-10 06:52:03
logistic回归和softmax回归

logistic:二分类

softmax:多分类

logistic回归

在 logistic 回归中,我们的训练集由 logistic回归和softmax回归 个已标记的样本构成:logistic回归和softmax回归。由于 logistic 回归是针对二分类问题的,因此类标记 logistic回归和softmax回归

假设函数(hypothesis function): logistic回归和softmax回归

代价函数(损失函数):logistic回归和softmax回归

我们的目标是训练模型参数logistic回归和softmax回归,使其能够最小化代价函数。

假设函数就相当于我们在线性回归中要拟合的直线函数。

softmax回归

在 softmax回归中,我们的训练集由 logistic回归和softmax回归 个已标记的样本构成:logistic回归和softmax回归。由于softmax回归是针对多分类问题(相对于 logistic 回归针对二分类问题),因此类标记 logistic回归和softmax回归 可以取 logistic回归和softmax回归 个不同的值(而不是 2 个)。我们有 logistic回归和softmax回归

对于给定的测试输入 logistic回归和softmax回归,我们想用假设函数针对每一个类别j估算出概率值 logistic回归和softmax回归。也就是说,我们想估计 logistic回归和softmax回归 的每一种分类结果出现的概率。因此,我们的假设函数将要输出一个 logistic回归和softmax回归 维的向量(向量元素的和为1)来表示这 logistic回归和softmax回归 个估计的概率值。 具体地说,我们的假设函数 logistic回归和softmax回归 形式如下:

假设函数:logistic回归和softmax回归
其中 logistic回归和softmax回归 是模型的参数。请注意 logistic回归和softmax回归这一项对概率分布进行归一化,使得所有概率之和为 1 。

为了方便起见,我们同样使用符号 logistic回归和softmax回归 来表示全部的模型参数。在实现Softmax回归时,将 logistic回归和softmax回归 用一个 logistic回归和softmax回归 的矩阵来表示会很方便,该矩阵是将 logistic回归和softmax回归 按行罗列起来得到的,如下所示:

logistic回归和softmax回归

也就是说logistic回归和softmax回归表示的是x属于不同类别的概率组成的向量。

代价函数:logistic回归和softmax回归
logistic回归和softmax回归 是示性函数,其取值规则为
 值为真的表达式 

值得注意的是,logistic回归代价函数是softmax代价函数的特殊情况。因此,logistic回归代价函数可以改为:

logistic回归和softmax回归
一点个人理解:

为什么二分类中参数只有一个logistic回归和softmax回归,而k分类中参数却有k个。

其实二分类中的logistic回归和softmax回归是y=1情况下的参数,而y=0情况下其实未给出参数,因为y=0的假设函数值可以通过1-(y=1的假设函数值)得到。同理,k分类中参数其实只需要k-1个参数就可以了,多余的一个参数是冗余的。
具体冗余参数有什么负面影响,参考Softmax回归 http://ufldl.stanford.edu/wiki/index.php/Softmax%E5%9B%9E%E5%BD%92

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.****.net/vincent2610/article/details/52708863?locationNum=14
知乎:https://www.zhihu.com/question/23765351