Pytorch 代码注释公式格式还原

Pytorch 代码注释公式格式还原

由于不熟悉语法,在理解公式过程中,出现障碍。
把公式还原,方便阅读,同时也学习公式表示语法:

pytorch BCE损失函数(loss function)代码注释如下:

The loss can be described as:

.. math::
    \text{loss}(x, class) = -\log\left(\frac{\exp(x[class])}{\sum_j \exp(x[j])}\right)
                   = -x[class] + \log\left(\sum_j \exp(x[j])\right)

or in the case of the `weight` argument being specified:

.. math::
    \text{loss}(x, class) = weight[class] \left(-x[class] + \log\left(\sum_j \exp(x[j])\right)\right)

The losses are averaged across observations for each minibatch.

对照如下:

在这里插入图片描述

参考文献:
https://www.jianshu.com/p/e74eb43960a1

Tips:
看不懂公式时,前后加上$符号,在markdown中即可还原(单个为行内,两个为行间)。
如:
\text{loss}(x, class) = weight[class] \left(-x[class] + \log\left(\sum_j \exp(x[j])\right)\right)加上美元符后显示为:

  • 5
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值