程序员

逻辑回归为什么用交叉熵损失函数

2020-09-14  本文已影响0人  顾子豪

1 Logistic Regression(逻辑回归)

\mathrm{z}=\mathrm{w}^{\mathrm{T}} \mathrm{x}+\mathrm{b}

2损失函数

L(\hat{y}, y)=-y \log (\hat{y})-(1-y) \log (1-\hat{y})
\mathrm{J}(\mathrm{w}, \mathrm{b})=\frac{1}{\mathrm{m}}\sum_{\mathrm{i}=1}^{\mathrm{m}}\mathrm{L}\left(\hat{\mathrm{y}}^{(\mathrm{i})}, \mathrm{y}^{(\mathrm{i})}\right)=\frac{1}{\mathrm{m}} \sum_{\mathrm{i}=1}^{\mathrm{m}}\left(\mathrm{ylog}\left(\hat{\mathrm{y}}^{(\mathrm{i})}\right)-\left(1-\mathrm{y}^{(\mathrm{i})}\right) \log\left(1-\hat{\mathrm{y}}^{(\mathrm{i})}\right)\right)

3 为什么逻辑回归的损失函数是这样的形式

p(y \mid x)=\hat{y}^{y}(1-\hat{y})^{(1-y)}

\log p(y \mid x)=\operatorname{ylog}(\hat{y})+(1-y) \log (1-\hat{y})=-L(\hat{y}, y)

\log \prod_{\mathrm{i}=1}^{\mathrm{m}} \mathrm{p}\left(\mathrm{y}^{(\mathrm{i})} \mid \mathrm{x}^{(\mathrm{i})}\right)=\sum_{\mathrm{i}=1}^{\mathrm{m}} \log \mathrm{p}\left(\mathrm{y}^{(\mathrm{i})} \mid \mathrm{x}^{(\mathrm{i})}\right)=-\sum_{\mathrm{i}=1}^{\mathrm{m}} \mathrm{L}\left(\hat{\mathrm{y}}^{(\mathrm{i})}, \mathrm{y}^{(\mathrm{i})}\right)

J(w, b)=\frac{1}{m} \sum_{i=1}^{m} L\left(\hat{y}^{(i)}, y^{(i)}\right)
参考链接(侵删):
https://blog.csdn.net/weixin_41537599/article/details/80585201

上一篇下一篇

猜你喜欢

热点阅读