“交叉熵”反向传播推导
每天给你送来NLP技术干货!
作者 | godweiyang
出品 | 公众号:算法码上来(ID:GodNLP)
- BEGIN -
交叉熵(CrossEntropy)是常见的损失函数,本文详细推导一下它的梯度,面试大厂或者工程实践中都可能会用到。
前向传播
假设分类任务类别数是,隐层输出是维向量,标准的one-hot向量是,正确的类别是。那么交叉熵损失可以定义为:
其中,,是平滑参数。Softmax函数大家都很熟悉了,具体形式为:。
反向传播
对的梯度要分两种情况:
推导过程
根据求导法则有:
其中就是Softmax函数的梯度(这个推导比较简单,放在了文末):
下面分两种情况讨论:
当时:
当时:
Softmax梯度
回顾Softmax函数的形式:
这里也分两种情况讨论:
当时:
当时:
- END -
最近文章
阅读原文 最新评论
推荐文章
作者最新文章
你可能感兴趣的文章
Copyright Disclaimer: The copyright of contents (including texts, images, videos and audios) posted above belong to the User who shared or the third-party website which the User shared from. If you found your copyright have been infringed, please send a DMCA takedown notice to [email protected]. For more detail of the source, please click on the button "Read Original Post" below. For other communications, please send to [email protected].
版权声明:以上内容为用户推荐收藏至CareerEngine平台,其内容(含文字、图片、视频、音频等)及知识版权均属用户或用户转发自的第三方网站,如涉嫌侵权,请通知[email protected]进行信息删除。如需查看信息来源,请点击“查看原文”。如需洽谈其它事宜,请联系[email protected]。
版权声明:以上内容为用户推荐收藏至CareerEngine平台,其内容(含文字、图片、视频、音频等)及知识版权均属用户或用户转发自的第三方网站,如涉嫌侵权,请通知[email protected]进行信息删除。如需查看信息来源,请点击“查看原文”。如需洽谈其它事宜,请联系[email protected]。