Derivative of Softmax Loss Function
Derivative of Softmax Loss Function
A softmax classifier:
\[
p_j = \frac{\exp{o_j}}{\sum_{k}\exp{o_k}}
\]
It has been used in a loss function of the form
\[
L = - \sum_{j} y_j \log p_j
\]
where o is a vector. We need the derivative of \(L\) with respect to \(o\). We can get the partial of \(o_i\) :
\[
\frac{\partial{p_j}}{\partial{o_i}} = p_i (1-p_i), \quad i = j \\
\frac{\partial{p_j}}{\partial{o_i}} = - p_i p_j, \quad i \ne j
\]
Hence the derivative of Loss with respect to \(o\) is:
\[
\begin{align}
\frac{\partial{L}}{\partial{o_i}} & = - \sum_k y_k \frac{\partial{\log p_k}}{\partial{o_i}} \\
& = - \sum_k y_k \frac{1}{p_k} \frac{\partial{p_k}}{\partial{o_i}} \\
& = -y_i(1-p_i) - \sum_{k\ne i} y_k \frac{1}{p_k} (-p_kp_i) \\
& = -y_i + y_i p_i + \sum_{k\ne i} y_k p_i \\
& = p_i (\sum_k y_k) - y_i \\
\end{align}
\]
Given that \(\sum_k y_k = 1\) as \(y\) is a vector with only one non-zero element, which is 1. By other words, this is a classification problem.
\[
\frac{\partial L}{\partial o_i} = p_i - y_i
\]
Reference
Derivative of Softmax loss function
Derivative of Softmax Loss Function的更多相关文章
- Derivative of the softmax loss function
Back-propagation in a nerual network with a Softmax classifier, which uses the Softmax function: \[\ ...
- loss function
什么是loss? loss: loss是我们用来对模型满意程度的指标.loss设计的原则是:模型越好loss越低,模型越差loss越高,但也有过拟合的情况. loss function: 在分 ...
- 损失函数 hinge loss vs softmax loss
1. 损失函数 损失函数(Loss function)是用来估量你模型的预测值 f(x) 与真实值 Y 的不一致程度,它是一个非负实值函数,通常用 L(Y,f(x)) 来表示. 损失函数越小,模型的鲁 ...
- 【深度学习】一文读懂机器学习常用损失函数(Loss Function)
最近太忙已经好久没有写博客了,今天整理分享一篇关于损失函数的文章吧,以前对损失函数的理解不够深入,没有真正理解每个损失函数的特点以及应用范围,如果文中有任何错误,请各位朋友指教,谢谢~ 损失函数(lo ...
- (Review cs231n)loss function and optimization
分类器需要在识别物体变化时候具有很好的鲁棒性(robus) 线性分类器(linear classifier)理解为模板的匹配,根据数量,表达能力不足,泛化性低:理解为将图片看做在高维度区域 线性分类器 ...
- 机器学习中的损失函数 (着重比较:hinge loss vs softmax loss)
https://blog.csdn.net/u010976453/article/details/78488279 1. 损失函数 损失函数(Loss function)是用来估量你模型的预测值 f( ...
- 基于Caffe的Large Margin Softmax Loss的实现(中)
小喵的唠叨话:前一篇博客,我们做完了L-Softmax的准备工作.而这一章,我们开始进行前馈的研究. 小喵博客: http://miaoerduo.com 博客原文: http://www.miao ...
- 基于Caffe的Large Margin Softmax Loss的实现(上)
小喵的唠叨话:在写完上一次的博客之后,已经过去了2个月的时间,小喵在此期间,做了大量的实验工作,最终在使用的DeepID2的方法之后,取得了很不错的结果.这次呢,主要讲述一个比较新的论文中的方法,L- ...
- loss function与cost function
实际上,代价函数(cost function)和损失函数(loss function 亦称为 error function)是同义的.它们都是事先定义一个假设函数(hypothesis),通过训练集由 ...
随机推荐
- Overview of .rdp file settings
On this page you will find an overview of most of the available .rdp file settings which can be used ...
- AVL树的Java实现
AVL树:平衡的二叉搜索树,其子树也是AVL树. 以下是我实现AVL树的源码(使用了泛型): import java.util.Comparator; public class AVLTree< ...
- PHP 多个构造函数
class A { function __construct() { $a = func_get_args(); $i = func_num_args(); if (method_exists($th ...
- js 获取某个某个区间内的随机整数
//获取某个某个区间内的随机整数 ,获取到的值域为[min,max)function get_random_num(min,max){ if(/^-?\d+$/.test(min) && ...
- vim删除.swp
非正常关闭vi编辑器时会生成一个.swp文件 关于swp文件 使用vi,经常可以看到swp这个文件,那这个文件是怎么产生的呢,当你打开一个文件,vi就会生成这么一个.(filename)swp文件以备 ...
- mysql--表数据操作
查询: 简单查询 ####查询的字段必须在表中存在 #### 对查询出来的数据进行修改时,不会修改原来的数据,只是修改了可视化的,我们看到的数据. # 查一个数据 select 字段名 from 表名 ...
- HSRP(Hot Standby Router Protocol)
一.简介 HSRP(Hot Standby Router Protocol 热备份路由器协议)是Cisco的专有协议.HSRP把多台路由器组成一个“热备份组”,形成一个虚拟路由器.这个组内 ...
- Linq中join多字段匹配
错误示范: var projectSubmitInfos = (from project in db.T_PM_Project join member in db.T_PM_Member on pro ...
- MSSQL2008 数据库展开报错:值不能为空。 参数名: viewInfo (Microsoft.SqlServer.Management.SqlStudio.Explorer)
今天打开数据库,结果出现:值不能为空. 参数名: viewInfo (Microsoft.SqlServer.Management.SqlStudio.Explorer) 百度之后找到其中一种解决方案 ...
- 解决Qt下ssl出错的办法
在使用 QNetworkAccessManager 时出现的ssl错误:qt.network.ssl: QSslSocket: cannot resolve SSL_set_psk_client_ca ...