Skip to main content
 首页 » 编程设计

python之如何在文档字符串中正确显示 Pytorch 的数学符号

2024年11月24日23dudu

在查看 Pytorch 函数的文档字符串时,数学符号显示不正确,例如: https://pytorch.org/docs/stable/_modules/torch/nn/modules/loss.html

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

只有当我使用我的 IDE 显示文档时,它才能正确呈现 latex 符号。

网站上是否有显示数学的开关?

请您参考如下方法:

除非您尝试通过 Greasemonkey 等方式注入(inject)脚本,否则源代码中的文档不会呈现。 但首先看看标准文档,您可以在其中找到 rendered formula .