为 PyTorch 创建离线 PDF 文档时出错

问题描述

我想在我的系统上为 PyTorch 文档制作离线 PDF。从几个资源#1#2#3

阅读后
git clone https://github.com/pytorch/pytorch

cd pytorch/docs/

make latexpdf

前两个命令工作正常。第三个命令导致以下错误

Traceback (most recent call last):
  File "source/scripts/build_activation_images.py",line 70,in <module>
    function = torch.nn.modules.activation.__dict__[function_name]()
KeyError: 'SiLU'

如何克服这个错误并制作 PyTorch 的 PDF 文档?


1.4.0 是我系统中 PyTorch 的版本

print(torch.__version__)
1.4.0

3.8.3 是我系统中的 Python 版本

python -V
Python 3.8.3

解决方法

您机器上安装的 PyTorch 版本 (1.4.0) 比您克隆的版本(最新)旧。两种解决方法:

  1. 签出到您已安装的版本(如果您想要 1.4 版本的文档):
import { USER_STATE_CHANGE,ADD_LIST } from "../constants";

const initialState = {
  currentUser: null,list: null,};



export const user = (state = initialState,action) => {
  switch (action.type){
      case USER_STATE_CHANGE:
        return {
          ...state,currentUser: action.currentUser,};
      case ADD_LIST: 
      return{
        ...state,list: [...action.payload],}
      default:
        return state
  }
  
};
  1. 升级到最新的 PyTorch 版本(如果您想要最新的文档):
git clone https://github.com/pytorch/pytorch

# move back to the 1.4 release,which you have installed in your machine
cd pytorch
git checkout release/1.4

cd docs
make latexpdf