如何解决记录 jit 编译的 PyTorch 类方法 (Sphinx)
我在尝试使用 Sphinx 记录自定义 PyTorch 模型时遇到问题:jit 编译的方法在文档中显示时没有文档字符串。我该如何解决?我检查了 Python Sphinx autodoc and decorated members 和 How to autodoc decorated methods with sphinx?,但建议的解决方案似乎不起作用。当我尝试使用 {X > 0 && (
<div>
{fields.map((field,index) => {
...
时,我得到
..automethod
这是一个 MWE;目前我通过编写 AttributeError: '_CachedForward' object has no attribute '__getattr__'
并在 my_forward
中调用它来规避这个问题。
forward
解决方法
在运行 Sphinx 时将 PYTORCH_JIT
环境变量设置为 0。这将禁用脚本和跟踪注释(装饰器)。
见https://pytorch.org/docs/stable/jit.html#disable-jit-for-debugging。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。