Search code examples
pythonpytorchdocstring

How to properly display Pytorch's math notation inside docstring?


When looking at the docstring of Pytorch functions, the math notations are not properly displayed, e.g.: 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)

Only if I use my IDE to display the documentation, it renders the latex notation properly.

Is there any switch for displaying math on the website?


Solution

  • The docs in source code won't render unless you try some script injection via Greasemonkey or so. But first have a look at the standard docs where you can find the rendered formula.