Skip to content

Commit

Permalink
修改: doc/tutorial/TorchScript/jit.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxinwei committed Nov 21, 2023
1 parent bee0f5a commit 2643875
Show file tree
Hide file tree
Showing 8 changed files with 1,909 additions and 2,214 deletions.
3 changes: 2 additions & 1 deletion doc/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ datasets/
*.pkl
*.params
*.pth
*.onnx
*.onnx
data/
3 changes: 2 additions & 1 deletion doc/recipes/activation/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 激活函数

```{toctree}
tanh
sigmoid
silu
tanh
```
2,425 changes: 348 additions & 2,077 deletions doc/recipes/cifar/cifar10-resnet18-relu.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/recipes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
```{toctree}
cifar/index
benchmark
activation/indexgit
activation/index
```
27 changes: 13 additions & 14 deletions doc/tutorial/TorchScript/jit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -117,32 +117,31 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"空列表被假设为 `List[Tensor]` 和空字典 `Dict[str, Tensor]`。要实例化其他类型的空列表或字典,请使用 Python 3 类型注解。\n",
"空列表被假设为 `list[Tensor]` 和空字典 `dict[str, Tensor]`。要实例化其他类型的空列表或字典,请使用 Python 3 类型注解。\n",
"\n",
"比如:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import torch\n",
"import torch.nn as nn\n",
"from typing import Dict, List, Tuple\n",
"from torch import nn\n",
"\n",
"class EmptyDataStructures(torch.nn.Module):\n",
" def __init__(self):\n",
" super().__init__()\n",
"\n",
" def forward(self, x: torch.Tensor) -> Tuple[List[Tuple[int, float]], Dict[str, int]]:\n",
" def forward(self, x: torch.Tensor) -> tuple[list[tuple[int, float]], dict[str, int]]:\n",
" # This annotates the list to be a `List[Tuple[int, float]]`\n",
" my_list: List[Tuple[int, float]] = []\n",
" my_list: list[tuple[int, float]] = []\n",
" for i in range(10):\n",
" my_list.append((i, x.item()))\n",
"\n",
" my_dict: Dict[str, int] = {}\n",
" my_dict: dict[str, int] = {}\n",
" return my_list, my_dict\n",
"\n",
"x = torch.jit.script(EmptyDataStructures())"
Expand All @@ -164,12 +163,12 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import torch\n",
"import torch.nn as nn\n",
"from torch import nn\n",
"from typing import Optional\n",
"\n",
"class M(nn.Module):\n",
Expand Down Expand Up @@ -215,7 +214,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand All @@ -241,7 +240,7 @@
" [1., 1.]])"
]
},
"execution_count": 6,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -285,7 +284,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand All @@ -305,7 +304,7 @@
"120"
]
},
"execution_count": 8,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -494,7 +493,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
"version": "3.10.13"
},
"orig_nbformat": 4
},
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/quant/fx-graph-mode-qat.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"source": [
"# FX Graph QAT\n",
"\n",
"以 [resnet18_cifar10_relu_cutout](../cifar/cifar10-resnet18-relu) 网络为例展示如何进行 QAT FX Graph 训练。"
"以 [resnet18_cifar10_relu_cutout](cifar10-resnet18-relu) 网络为例展示如何进行 QAT FX Graph 训练。"
]
},
{
Expand Down
Loading

0 comments on commit 2643875

Please sign in to comment.