Skip to content

Commit

Permalink
Version 2.0.0-alpha2
Browse files Browse the repository at this point in the history
  • Loading branch information
Mu Li committed Oct 7, 2021
1 parent 49b7d44 commit 8763bfc
Show file tree
Hide file tree
Showing 70 changed files with 289,136 additions and 20,296 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,5 @@ You can also preview them in nbviwer:
- [chapter_computer-vision/neural-style.ipynb](https://nbviewer.jupyter.org/format/slides/github/d2l-ai/d2l-zh-pytorch-slides/blob/main/chapter_computer-vision/neural-style.ipynb)
- [chapter_computer-vision/kaggle-cifar10.ipynb](https://nbviewer.jupyter.org/format/slides/github/d2l-ai/d2l-zh-pytorch-slides/blob/main/chapter_computer-vision/kaggle-cifar10.ipynb)
- [chapter_computer-vision/kaggle-dog.ipynb](https://nbviewer.jupyter.org/format/slides/github/d2l-ai/d2l-zh-pytorch-slides/blob/main/chapter_computer-vision/kaggle-dog.ipynb)
- [chapter_natural-language-processing-pretraining/bert.ipynb](https://nbviewer.jupyter.org/format/slides/github/d2l-ai/d2l-zh-pytorch-slides/blob/main/chapter_natural-language-processing-pretraining/bert.ipynb)
- [chapter_natural-language-processing-pretraining/bert-dataset.ipynb](https://nbviewer.jupyter.org/format/slides/github/d2l-ai/d2l-zh-pytorch-slides/blob/main/chapter_natural-language-processing-pretraining/bert-dataset.ipynb)
- [chapter_natural-language-processing-pretraining/bert-pretraining.ipynb](https://nbviewer.jupyter.org/format/slides/github/d2l-ai/d2l-zh-pytorch-slides/blob/main/chapter_natural-language-processing-pretraining/bert-pretraining.ipynb)
- [chapter_natural-language-processing-applications/natural-language-inference-and-dataset.ipynb](https://nbviewer.jupyter.org/format/slides/github/d2l-ai/d2l-zh-pytorch-slides/blob/main/chapter_natural-language-processing-applications/natural-language-inference-and-dataset.ipynb)
- [chapter_natural-language-processing-applications/natural-language-inference-bert.ipynb](https://nbviewer.jupyter.org/format/slides/github/d2l-ai/d2l-zh-pytorch-slides/blob/main/chapter_natural-language-processing-applications/natural-language-inference-bert.ipynb)
86 changes: 43 additions & 43 deletions chapter_attention-mechanisms/attention-scoring-functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
}
},
"source": [
"遮蔽softmax操作"
"掩蔽softmax操作"
]
},
{
Expand All @@ -52,7 +52,7 @@
"outputs": [],
"source": [
"def masked_softmax(X, valid_lens):\n",
" \"\"\"通过在最后一个轴上遮蔽元素来执行 softmax 操作\"\"\"\n",
" \"\"\"通过在最后一个轴上掩蔽元素来执行 softmax 操作\"\"\"\n",
" if valid_lens is None:\n",
" return nn.functional.softmax(X, dim=-1)\n",
" else:\n",
Expand Down Expand Up @@ -90,11 +90,11 @@
{
"data": {
"text/plain": [
"tensor([[[0.3708, 0.6292, 0.0000, 0.0000],\n",
" [0.5583, 0.4417, 0.0000, 0.0000]],\n",
"tensor([[[0.4873, 0.5127, 0.0000, 0.0000],\n",
" [0.4808, 0.5192, 0.0000, 0.0000]],\n",
"\n",
" [[0.2450, 0.5191, 0.2360, 0.0000],\n",
" [0.4620, 0.2529, 0.2851, 0.0000]]])"
" [[0.3309, 0.3171, 0.3520, 0.0000],\n",
" [0.3169, 0.2635, 0.4196, 0.0000]]])"
]
},
"execution_count": 3,
Expand All @@ -120,10 +120,10 @@
"data": {
"text/plain": [
"tensor([[[1.0000, 0.0000, 0.0000, 0.0000],\n",
" [0.3310, 0.4068, 0.2622, 0.0000]],\n",
" [0.2946, 0.3579, 0.3475, 0.0000]],\n",
"\n",
" [[0.3673, 0.6327, 0.0000, 0.0000],\n",
" [0.3206, 0.1533, 0.3454, 0.1807]]])"
" [[0.4633, 0.5367, 0.0000, 0.0000],\n",
" [0.3822, 0.1967, 0.2299, 0.1912]]])"
]
},
"execution_count": 4,
Expand Down Expand Up @@ -254,7 +254,7 @@
" <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
" <cc:Work>\n",
" <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
" <dc:date>2021-10-07T09:55:58.284756</dc:date>\n",
" <dc:date>2021-10-07T19:02:54.086852</dc:date>\n",
" <dc:format>image/svg+xml</dc:format>\n",
" <dc:creator>\n",
" <cc:Agent>\n",
Expand Down Expand Up @@ -285,8 +285,8 @@
"z\n",
"\" style=\"fill:#ffffff;\"/>\n",
" </g>\n",
" <g clip-path=\"url(#p2ac75e0adc)\">\n",
" <image height=\"23\" id=\"image9e1aa90b48\" transform=\"scale(1 -1)translate(0 -23)\" width=\"112\" x=\"34.240625\" xlink:href=\"data:image/png;base64,\n",
" <g clip-path=\"url(#p3db5efcb91)\">\n",
" <image height=\"23\" id=\"image62a7f96603\" transform=\"scale(1 -1)translate(0 -23)\" width=\"112\" x=\"34.240625\" xlink:href=\"data:image/png;base64,\n",
"iVBORw0KGgoAAAANSUhEUgAAAHAAAAAXCAYAAADTEcupAAAAeElEQVR4nO3YsQmAQBAF0X+aWp8tGFqDXZjZnC2YCV5uJnIcA/MKWBaGTbbcx/ZESZJxXnuv8NnQewH9Y0A4A8IZEM6AcAaEMyCcAeEMCGdAOAPClSVTk1/ofp0txurFC4QzIJwB4QwIZ0A4A8IZEM6AcAaEMyBcBc2IB/NA+hblAAAAAElFTkSuQmCC\" y=\"-36.13\"/>\n",
" </g>\n",
" <g id=\"matplotlib.axis_1\">\n",
Expand All @@ -295,10 +295,10 @@
" <defs>\n",
" <path d=\"M 0 0 \n",
"L 0 3.5 \n",
"\" id=\"mebf2be50cc\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
"\" id=\"m469ba72a49\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"39.820625\" xlink:href=\"#mebf2be50cc\" y=\"59.13\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"39.820625\" xlink:href=\"#m469ba72a49\" y=\"59.13\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_1\">\n",
Expand Down Expand Up @@ -334,7 +334,7 @@
" <g id=\"xtick_2\">\n",
" <g id=\"line2d_2\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"95.620625\" xlink:href=\"#mebf2be50cc\" y=\"59.13\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"95.620625\" xlink:href=\"#m469ba72a49\" y=\"59.13\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_2\">\n",
Expand Down Expand Up @@ -472,10 +472,10 @@
" <defs>\n",
" <path d=\"M 0 0 \n",
"L -3.5 0 \n",
"\" id=\"me5aac086a3\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
"\" id=\"m6717bc26c7\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"34.240625\" xlink:href=\"#me5aac086a3\" y=\"42.39\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"34.240625\" xlink:href=\"#m6717bc26c7\" y=\"42.39\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_4\">\n",
Expand All @@ -488,7 +488,7 @@
" <g id=\"ytick_2\">\n",
" <g id=\"line2d_4\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"34.240625\" xlink:href=\"#me5aac086a3\" y=\"53.55\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"34.240625\" xlink:href=\"#m6717bc26c7\" y=\"53.55\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_5\">\n",
Expand Down Expand Up @@ -625,7 +625,7 @@
" </g>\n",
" <g id=\"axes_2\">\n",
" <g id=\"patch_7\">\n",
" <path clip-path=\"url(#pf605bade82)\" d=\"M 152.815625 88.74 \n",
" <path clip-path=\"url(#p5703b3261a)\" d=\"M 152.815625 88.74 \n",
"L 152.815625 88.421484 \n",
"L 152.815625 7.518516 \n",
"L 152.815625 7.2 \n",
Expand All @@ -636,7 +636,7 @@
"z\n",
"\" style=\"fill:#ffffff;stroke:#ffffff;stroke-linejoin:miter;stroke-width:0.01;\"/>\n",
" </g>\n",
" <image height=\"82\" id=\"image53105073c0\" transform=\"scale(1 -1)translate(0 -82)\" width=\"4\" x=\"153\" xlink:href=\"data:image/png;base64,\n",
" <image height=\"82\" id=\"image7bd32578b2\" transform=\"scale(1 -1)translate(0 -82)\" width=\"4\" x=\"153\" xlink:href=\"data:image/png;base64,\n",
"iVBORw0KGgoAAAANSUhEUgAAAAQAAABSCAYAAABzJnWUAAAAnklEQVR4nJ2SOw5CMQwEjfTuf1QqChT/aMnskwxJl9F414ry6Nez7etclmE7qCLIAfRonABZLBy1o2FJEBzxxdD/M7R2NFh7EzpmHBhSm3z1H/YAaDEk1OfVBfCPCXCAEmPJppJRg1Fs0QyCYGhmw4jRIMjkSMgIjBBDapvGfrcrTYwDYINxsweAM8NpvAtgCeDIYqiMSIsYUrs/sdkHBN7KuQYqCJAAAAAASUVORK5CYII=\" y=\"-6\"/>\n",
" <g id=\"matplotlib.axis_3\"/>\n",
" <g id=\"matplotlib.axis_4\">\n",
Expand All @@ -645,10 +645,10 @@
" <defs>\n",
" <path d=\"M 0 0 \n",
"L 3.5 0 \n",
"\" id=\"m45eaff82a8\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
"\" id=\"m6f8fd63cd0\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"156.892625\" xlink:href=\"#m45eaff82a8\" y=\"88.74\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"156.892625\" xlink:href=\"#m6f8fd63cd0\" y=\"88.74\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_7\">\n",
Expand All @@ -671,7 +671,7 @@
" <g id=\"ytick_4\">\n",
" <g id=\"line2d_6\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"156.892625\" xlink:href=\"#m45eaff82a8\" y=\"56.124\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"156.892625\" xlink:href=\"#m6f8fd63cd0\" y=\"56.124\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_8\">\n",
Expand Down Expand Up @@ -712,7 +712,7 @@
" <g id=\"ytick_5\">\n",
" <g id=\"line2d_7\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"156.892625\" xlink:href=\"#m45eaff82a8\" y=\"23.508\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"156.892625\" xlink:href=\"#m6f8fd63cd0\" y=\"23.508\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_9\">\n",
Expand Down Expand Up @@ -759,10 +759,10 @@
" </g>\n",
" </g>\n",
" <defs>\n",
" <clipPath id=\"p2ac75e0adc\">\n",
" <clipPath id=\"p3db5efcb91\">\n",
" <rect height=\"22.32\" width=\"111.6\" x=\"34.240625\" y=\"36.81\"/>\n",
" </clipPath>\n",
" <clipPath id=\"pf605bade82\">\n",
" <clipPath id=\"p5703b3261a\">\n",
" <rect height=\"81.54\" width=\"4.077\" x=\"152.815625\" y=\"7.2\"/>\n",
" </clipPath>\n",
" </defs>\n",
Expand Down Expand Up @@ -892,7 +892,7 @@
" <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
" <cc:Work>\n",
" <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
" <dc:date>2021-10-07T09:55:58.492502</dc:date>\n",
" <dc:date>2021-10-07T19:02:54.269774</dc:date>\n",
" <dc:format>image/svg+xml</dc:format>\n",
" <dc:creator>\n",
" <cc:Agent>\n",
Expand Down Expand Up @@ -923,8 +923,8 @@
"z\n",
"\" style=\"fill:#ffffff;\"/>\n",
" </g>\n",
" <g clip-path=\"url(#p2b90109208)\">\n",
" <image height=\"23\" id=\"image6f941acd71\" transform=\"scale(1 -1)translate(0 -23)\" width=\"112\" x=\"34.240625\" xlink:href=\"data:image/png;base64,\n",
" <g clip-path=\"url(#pd6701352dd)\">\n",
" <image height=\"23\" id=\"imagef70d7964e4\" transform=\"scale(1 -1)translate(0 -23)\" width=\"112\" x=\"34.240625\" xlink:href=\"data:image/png;base64,\n",
"iVBORw0KGgoAAAANSUhEUgAAAHAAAAAXCAYAAADTEcupAAAAeElEQVR4nO3YsQmAQBAF0X+aWp8tGFqDXZjZnC2YCV5uJnIcA/MKWBaGTbbcx/ZESZJxXnuv8NnQewH9Y0A4A8IZEM6AcAaEMyCcAeEMCGdAOAPClSVTk1/ofp0txurFC4QzIJwB4QwIZ0A4A8IZEM6AcAaEMyBcBc2IB/NA+hblAAAAAElFTkSuQmCC\" y=\"-36.13\"/>\n",
" </g>\n",
" <g id=\"matplotlib.axis_1\">\n",
Expand All @@ -933,10 +933,10 @@
" <defs>\n",
" <path d=\"M 0 0 \n",
"L 0 3.5 \n",
"\" id=\"me43e292c38\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
"\" id=\"mbbc87a6648\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"39.820625\" xlink:href=\"#me43e292c38\" y=\"59.13\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"39.820625\" xlink:href=\"#mbbc87a6648\" y=\"59.13\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_1\">\n",
Expand Down Expand Up @@ -972,7 +972,7 @@
" <g id=\"xtick_2\">\n",
" <g id=\"line2d_2\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"95.620625\" xlink:href=\"#me43e292c38\" y=\"59.13\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"95.620625\" xlink:href=\"#mbbc87a6648\" y=\"59.13\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_2\">\n",
Expand Down Expand Up @@ -1110,10 +1110,10 @@
" <defs>\n",
" <path d=\"M 0 0 \n",
"L -3.5 0 \n",
"\" id=\"m8a614c6796\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
"\" id=\"m121fab6898\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"34.240625\" xlink:href=\"#m8a614c6796\" y=\"42.39\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"34.240625\" xlink:href=\"#m121fab6898\" y=\"42.39\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_4\">\n",
Expand All @@ -1126,7 +1126,7 @@
" <g id=\"ytick_2\">\n",
" <g id=\"line2d_4\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"34.240625\" xlink:href=\"#m8a614c6796\" y=\"53.55\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"34.240625\" xlink:href=\"#m121fab6898\" y=\"53.55\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_5\">\n",
Expand Down Expand Up @@ -1263,7 +1263,7 @@
" </g>\n",
" <g id=\"axes_2\">\n",
" <g id=\"patch_7\">\n",
" <path clip-path=\"url(#p1e2928c400)\" d=\"M 152.815625 88.74 \n",
" <path clip-path=\"url(#p8eb1855b59)\" d=\"M 152.815625 88.74 \n",
"L 152.815625 88.421484 \n",
"L 152.815625 7.518516 \n",
"L 152.815625 7.2 \n",
Expand All @@ -1274,7 +1274,7 @@
"z\n",
"\" style=\"fill:#ffffff;stroke:#ffffff;stroke-linejoin:miter;stroke-width:0.01;\"/>\n",
" </g>\n",
" <image height=\"82\" id=\"imagedf472ee7cb\" transform=\"scale(1 -1)translate(0 -82)\" width=\"4\" x=\"153\" xlink:href=\"data:image/png;base64,\n",
" <image height=\"82\" id=\"imagef6889f624e\" transform=\"scale(1 -1)translate(0 -82)\" width=\"4\" x=\"153\" xlink:href=\"data:image/png;base64,\n",
"iVBORw0KGgoAAAANSUhEUgAAAAQAAABSCAYAAABzJnWUAAAAnklEQVR4nJ2SOw5CMQwEjfTuf1QqChT/aMnskwxJl9F414ry6Nez7etclmE7qCLIAfRonABZLBy1o2FJEBzxxdD/M7R2NFh7EzpmHBhSm3z1H/YAaDEk1OfVBfCPCXCAEmPJppJRg1Fs0QyCYGhmw4jRIMjkSMgIjBBDapvGfrcrTYwDYINxsweAM8NpvAtgCeDIYqiMSIsYUrs/sdkHBN7KuQYqCJAAAAAASUVORK5CYII=\" y=\"-6\"/>\n",
" <g id=\"matplotlib.axis_3\"/>\n",
" <g id=\"matplotlib.axis_4\">\n",
Expand All @@ -1283,10 +1283,10 @@
" <defs>\n",
" <path d=\"M 0 0 \n",
"L 3.5 0 \n",
"\" id=\"m2280839f0b\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
"\" id=\"m17f167becb\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"156.892625\" xlink:href=\"#m2280839f0b\" y=\"88.74\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"156.892625\" xlink:href=\"#m17f167becb\" y=\"88.74\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_7\">\n",
Expand All @@ -1309,7 +1309,7 @@
" <g id=\"ytick_4\">\n",
" <g id=\"line2d_6\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"156.892625\" xlink:href=\"#m2280839f0b\" y=\"56.124\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"156.892625\" xlink:href=\"#m17f167becb\" y=\"56.124\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_8\">\n",
Expand Down Expand Up @@ -1350,7 +1350,7 @@
" <g id=\"ytick_5\">\n",
" <g id=\"line2d_7\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"156.892625\" xlink:href=\"#m2280839f0b\" y=\"23.508\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"156.892625\" xlink:href=\"#m17f167becb\" y=\"23.508\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_9\">\n",
Expand Down Expand Up @@ -1397,10 +1397,10 @@
" </g>\n",
" </g>\n",
" <defs>\n",
" <clipPath id=\"p2b90109208\">\n",
" <clipPath id=\"pd6701352dd\">\n",
" <rect height=\"22.32\" width=\"111.6\" x=\"34.240625\" y=\"36.81\"/>\n",
" </clipPath>\n",
" <clipPath id=\"p1e2928c400\">\n",
" <clipPath id=\"p8eb1855b59\">\n",
" <rect height=\"81.54\" width=\"4.077\" x=\"152.815625\" y=\"7.2\"/>\n",
" </clipPath>\n",
" </defs>\n",
Expand Down
Loading

0 comments on commit 8763bfc

Please sign in to comment.