master 09c8bacc0859 cached
168 files
12.3 MB
3.2M tokens
169 symbols
1 requests
Copy disabled (too large) Download .txt
Showing preview only (12,923K chars total). Download the full file to get everything.
Repository: ShusenTang/Dive-into-DL-PyTorch
Branch: master
Commit: 09c8bacc0859
Files: 168
Total size: 12.3 MB

Directory structure:
gitextract_ttpkw08n/

├── .github/
│   └── ISSUE_TEMPLATE/
│       └── bug_report.md
├── .gitignore
├── Dockerfile
├── LICENSE
├── code/
│   ├── chapter02_prerequisite/
│   │   ├── 2.2_tensor.ipynb
│   │   └── 2.3_autograd.ipynb
│   ├── chapter03_DL-basics/
│   │   ├── 3.10_mlp-pytorch.ipynb
│   │   ├── 3.11_underfit-overfit.ipynb
│   │   ├── 3.12_weight-decay.ipynb
│   │   ├── 3.13_dropout.ipynb
│   │   ├── 3.16_kaggle-house-price.ipynb
│   │   ├── 3.1_linear-regression.ipynb
│   │   ├── 3.2_linear-regression-scratch.ipynb
│   │   ├── 3.3_linear-regression-pytorch.ipynb
│   │   ├── 3.5_fashion-mnist.ipynb
│   │   ├── 3.6_softmax-regression-scratch.ipynb
│   │   ├── 3.7_softmax-regression-pytorch.ipynb
│   │   ├── 3.8_mlp.ipynb
│   │   ├── 3.9_mlp-scratch.ipynb
│   │   └── submission.csv
│   ├── chapter04_DL_computation/
│   │   ├── 4.1_model-construction.ipynb
│   │   ├── 4.2_parameters.ipynb
│   │   ├── 4.4_custom-layer.ipynb
│   │   ├── 4.5_read-write.ipynb
│   │   └── 4.6_use-gpu.ipynb
│   ├── chapter05_CNN/
│   │   ├── 5.10_batch-norm.ipynb
│   │   ├── 5.11_resnet.ipynb
│   │   ├── 5.12_densenet.ipynb
│   │   ├── 5.1_conv-layer.ipynb
│   │   ├── 5.2_padding-and-strides.ipynb
│   │   ├── 5.3_channels.ipynb
│   │   ├── 5.4_pooling.ipynb
│   │   ├── 5.5_lenet.ipynb
│   │   ├── 5.6_alexnet.ipynb
│   │   ├── 5.7_vgg.ipynb
│   │   ├── 5.8_nin.ipynb
│   │   └── 5.9_googlenet.ipynb
│   ├── chapter06_RNN/
│   │   ├── 6.2_rnn.ipynb
│   │   ├── 6.3_lang-model-dataset.ipynb
│   │   ├── 6.4_rnn-scratch.ipynb
│   │   ├── 6.5_rnn-pytorch.ipynb
│   │   ├── 6.7_gru.ipynb
│   │   └── 6.8_lstm.ipynb
│   ├── chapter07_optimization/
│   │   ├── 7.1_optimization-intro.ipynb
│   │   ├── 7.2_gd-sgd.ipynb
│   │   ├── 7.3_minibatch-sgd.ipynb
│   │   ├── 7.4_momentum.ipynb
│   │   ├── 7.5_adagrad.ipynb
│   │   ├── 7.6_rmsprop.ipynb
│   │   ├── 7.7_adadelta.ipynb
│   │   └── 7.8_adam.ipynb
│   ├── chapter08_computational-performance/
│   │   ├── 8.1_hybridize.ipynb
│   │   ├── 8.3_auto-parallelism.ipynb
│   │   ├── 8.4_model.pt
│   │   └── 8.4_multiple-gpus.ipynb
│   ├── chapter09_computer-vision/
│   │   ├── 9.11_neural-style.ipynb
│   │   ├── 9.1_image-augmentation.ipynb
│   │   ├── 9.2_fine-tuning.ipynb
│   │   ├── 9.3_bounding-box.ipynb
│   │   ├── 9.4_anchor.ipynb
│   │   ├── 9.5_multiscale-object-detection.ipynb
│   │   ├── 9.6.0_prepare_pikachu.ipynb
│   │   ├── 9.6_object-detection-dataset.ipynb
│   │   ├── 9.8_rcnn.ipynb
│   │   └── 9.9_semantic-segmentation-and-dataset.ipynb
│   ├── chapter10_natural-language-processing/
│   │   ├── 10.12_machine-translation.ipynb
│   │   ├── 10.3_word2vec-pytorch.ipynb
│   │   ├── 10.6_similarity-analogy.ipynb
│   │   ├── 10.7_sentiment-analysis-rnn.ipynb
│   │   └── 10.8_sentiment-analysis-cnn.ipynb
│   └── d2lzh_pytorch/
│       ├── __init__.py
│       └── utils.py
├── data/
│   ├── fr-en-small.txt
│   ├── kaggle_house/
│   │   ├── data_description.txt
│   │   ├── sample_submission.csv
│   │   ├── test.csv
│   │   └── train.csv
│   └── ptb/
│       ├── README
│       ├── ptb.test.txt
│       ├── ptb.train.txt
│       └── ptb.valid.txt
└── docs/
    ├── .nojekyll
    ├── README.md
    ├── _sidebar.md
    ├── chapter01_DL-intro/
    │   └── deep-learning-intro.md
    ├── chapter02_prerequisite/
    │   ├── 2.1_install.md
    │   ├── 2.2_tensor.md
    │   └── 2.3_autograd.md
    ├── chapter03_DL-basics/
    │   ├── 3.10_mlp-pytorch.md
    │   ├── 3.11_underfit-overfit.md
    │   ├── 3.12_weight-decay.md
    │   ├── 3.13_dropout.md
    │   ├── 3.14_backprop.md
    │   ├── 3.15_numerical-stability-and-init.md
    │   ├── 3.16_kaggle-house-price.md
    │   ├── 3.1_linear-regression.md
    │   ├── 3.2_linear-regression-scratch.md
    │   ├── 3.3_linear-regression-pytorch.md
    │   ├── 3.4_softmax-regression.md
    │   ├── 3.5_fashion-mnist.md
    │   ├── 3.6_softmax-regression-scratch.md
    │   ├── 3.7_softmax-regression-pytorch.md
    │   ├── 3.8_mlp.md
    │   └── 3.9_mlp-scratch.md
    ├── chapter04_DL_computation/
    │   ├── 4.1_model-construction.md
    │   ├── 4.2_parameters.md
    │   ├── 4.3_deferred-init.md
    │   ├── 4.4_custom-layer.md
    │   ├── 4.5_read-write.md
    │   └── 4.6_use-gpu.md
    ├── chapter05_CNN/
    │   ├── 5.10_batch-norm.md
    │   ├── 5.11_resnet.md
    │   ├── 5.12_densenet.md
    │   ├── 5.1_conv-layer.md
    │   ├── 5.2_padding-and-strides.md
    │   ├── 5.3_channels.md
    │   ├── 5.4_pooling.md
    │   ├── 5.5_lenet.md
    │   ├── 5.6_alexnet.md
    │   ├── 5.7_vgg.md
    │   ├── 5.8_nin.md
    │   └── 5.9_googlenet.md
    ├── chapter06_RNN/
    │   ├── 6.10_bi-rnn.md
    │   ├── 6.1_lang-model.md
    │   ├── 6.2_rnn.md
    │   ├── 6.3_lang-model-dataset.md
    │   ├── 6.4_rnn-scratch.md
    │   ├── 6.5_rnn-pytorch.md
    │   ├── 6.6_bptt.md
    │   ├── 6.7_gru.md
    │   ├── 6.8_lstm.md
    │   └── 6.9_deep-rnn.md
    ├── chapter07_optimization/
    │   ├── 7.1_optimization-intro.md
    │   ├── 7.2_gd-sgd.md
    │   ├── 7.3_minibatch-sgd.md
    │   ├── 7.4_momentum.md
    │   ├── 7.5_adagrad.md
    │   ├── 7.6_rmsprop.md
    │   ├── 7.7_adadelta.md
    │   └── 7.8_adam.md
    ├── chapter08_computational-performance/
    │   ├── 8.1_hybridize.md
    │   ├── 8.2_async-computation.md
    │   ├── 8.3_auto-parallelism.md
    │   └── 8.4_multiple-gpus.md
    ├── chapter09_computer-vision/
    │   ├── 9.11_neural-style.md
    │   ├── 9.1_image-augmentation.md
    │   ├── 9.2_fine-tuning.md
    │   ├── 9.3_bounding-box.md
    │   ├── 9.4_anchor.md
    │   ├── 9.5_multiscale-object-detection.md
    │   ├── 9.6_object-detection-dataset.md
    │   ├── 9.8_rcnn.md
    │   └── 9.9_semantic-segmentation-and-dataset.md
    ├── chapter10_natural-language-processing/
    │   ├── 10.10_beam-search.md
    │   ├── 10.11_attention.md
    │   ├── 10.12_machine-translation.md
    │   ├── 10.1_word2vec.md
    │   ├── 10.2_approx-training.md
    │   ├── 10.3_word2vec-pytorch.md
    │   ├── 10.4_fasttext.md
    │   ├── 10.5_glove.md
    │   ├── 10.6_similarity-analogy.md
    │   ├── 10.7_sentiment-analysis-rnn.md
    │   ├── 10.8_sentiment-analysis-cnn.md
    │   └── 10.9_seq2seq.md
    ├── docsify.js
    ├── index.html
    └── read_guide.md

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: bug相关issue请按照此模板填写否则会被直接关闭
title: ''
labels: ''
assignees: ''

---

**bug描述**
描述一下你遇到的bug, 例如报错位置、报错信息(重要, 可以直接截个图)等

**版本信息**
pytorch:
torchvision:
torchtext:
...


================================================
FILE: .gitignore
================================================
*.DS_Store
*.pyc
*checkpoint.ipynb
.mypy_cache*
.vscode*
# 皮卡丘数据集太大了
data/pikachu*
# Pascal VOC2012数据集, 约2G
data/VOCdevkit*


================================================
FILE: Dockerfile
================================================
FROM node:alpine
RUN npm i docsify-cli -g
COPY . /data
WORKDIR /data
CMD [ "docsify", "serve", "docs" ]

================================================
FILE: LICENSE
================================================
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


================================================
FILE: code/chapter02_prerequisite/2.2_tensor.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2.2 数据操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.4.1\n"
     ]
    }
   ],
   "source": [
    "import torch\n",
    "\n",
    "torch.manual_seed(0)\n",
    "torch.cuda.manual_seed(0)\n",
    "print(torch.__version__)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.2.1 创建`Tensor`\n",
    "\n",
    "创建一个5x3的未初始化的`Tensor`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[0.0000e+00, 1.0842e-19, 1.6162e+22],\n",
      "        [2.8643e-42, 5.6052e-45, 0.0000e+00],\n",
      "        [0.0000e+00, 0.0000e+00, 0.0000e+00],\n",
      "        [0.0000e+00, 0.0000e+00, 0.0000e+00],\n",
      "        [0.0000e+00, 1.0842e-19, 1.3314e+22]])\n"
     ]
    }
   ],
   "source": [
    "x = torch.empty(5, 3)\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "创建一个5x3的随机初始化的`Tensor`:\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[0.4963, 0.7682, 0.0885],\n",
      "        [0.1320, 0.3074, 0.6341],\n",
      "        [0.4901, 0.8964, 0.4556],\n",
      "        [0.6323, 0.3489, 0.4017],\n",
      "        [0.0223, 0.1689, 0.2939]])\n"
     ]
    }
   ],
   "source": [
    "x = torch.rand(5, 3)\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "创建一个5x3的long型全0的`Tensor`:\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[0, 0, 0],\n",
      "        [0, 0, 0],\n",
      "        [0, 0, 0],\n",
      "        [0, 0, 0],\n",
      "        [0, 0, 0]])\n"
     ]
    }
   ],
   "source": [
    "x = torch.zeros(5, 3, dtype=torch.long)\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "直接根据数据创建:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([5.5000, 3.0000])\n"
     ]
    }
   ],
   "source": [
    "x = torch.tensor([5.5, 3])\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "还可以通过现有的`Tensor`来创建,此方法会默认重用输入`Tensor`的一些属性,例如数据类型,除非自定义数据类型。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[1., 1., 1.],\n",
      "        [1., 1., 1.],\n",
      "        [1., 1., 1.],\n",
      "        [1., 1., 1.],\n",
      "        [1., 1., 1.]], dtype=torch.float64)\n",
      "tensor([[ 0.6035,  0.8110, -0.0451],\n",
      "        [ 0.8797,  1.0482, -0.0445],\n",
      "        [-0.7229,  2.8663, -0.5655],\n",
      "        [ 0.1604, -0.0254,  1.0739],\n",
      "        [ 2.2628, -0.9175, -0.2251]])\n"
     ]
    }
   ],
   "source": [
    "x = x.new_ones(5, 3, dtype=torch.float64)      # 返回的tensor默认具有相同的torch.dtype和torch.device\n",
    "print(x)\n",
    "\n",
    "x = torch.randn_like(x, dtype=torch.float)    # 指定新的数据类型\n",
    "print(x)                                    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "我们可以通过`shape`或者`size()`来获取`Tensor`的形状:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([5, 3])\n",
      "torch.Size([5, 3])\n"
     ]
    }
   ],
   "source": [
    "print(x.size())\n",
    "print(x.shape)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> 注意:返回的torch.Size其实就是一个tuple, 支持所有tuple的操作。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.2.2 操作\n",
    "### 算术操作\n",
    "* **加法形式一**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[ 1.3967,  1.0892,  0.4369],\n",
      "        [ 1.6995,  2.0453,  0.6539],\n",
      "        [-0.1553,  3.7016, -0.3599],\n",
      "        [ 0.7536,  0.0870,  1.2274],\n",
      "        [ 2.5046, -0.1913,  0.4760]])\n"
     ]
    }
   ],
   "source": [
    "y = torch.rand(5, 3)\n",
    "print(x + y)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* **加法形式二**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[ 1.3967,  1.0892,  0.4369],\n",
      "        [ 1.6995,  2.0453,  0.6539],\n",
      "        [-0.1553,  3.7016, -0.3599],\n",
      "        [ 0.7536,  0.0870,  1.2274],\n",
      "        [ 2.5046, -0.1913,  0.4760]])\n"
     ]
    }
   ],
   "source": [
    "print(torch.add(x, y))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[ 1.3967,  1.0892,  0.4369],\n",
      "        [ 1.6995,  2.0453,  0.6539],\n",
      "        [-0.1553,  3.7016, -0.3599],\n",
      "        [ 0.7536,  0.0870,  1.2274],\n",
      "        [ 2.5046, -0.1913,  0.4760]])\n"
     ]
    }
   ],
   "source": [
    "result = torch.empty(5, 3)\n",
    "torch.add(x, y, out=result)\n",
    "print(result)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* **加法形式三、inplace**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[ 1.3967,  1.0892,  0.4369],\n",
      "        [ 1.6995,  2.0453,  0.6539],\n",
      "        [-0.1553,  3.7016, -0.3599],\n",
      "        [ 0.7536,  0.0870,  1.2274],\n",
      "        [ 2.5046, -0.1913,  0.4760]])\n"
     ]
    }
   ],
   "source": [
    "# adds x to y\n",
    "y.add_(x)\n",
    "print(y)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> **注:PyTorch操作inplace版本都有后缀\"_\", 例如`x.copy_(y), x.t_()`**\n",
    "\n",
    "### 索引\n",
    "我们还可以使用类似NumPy的索引操作来访问`Tensor`的一部分,需要注意的是:**索引出来的结果与原数据共享内存,也即修改一个,另一个会跟着修改。** "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([1.6035, 1.8110, 0.9549])\n",
      "tensor([1.6035, 1.8110, 0.9549])\n"
     ]
    }
   ],
   "source": [
    "y = x[0, :]\n",
    "y += 1\n",
    "print(y)\n",
    "print(x[0, :]) # 源tensor也被改了"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 改变形状\n",
    "用`view()`来改变`Tensor`的形状:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([5, 3]) torch.Size([15]) torch.Size([3, 5])\n"
     ]
    }
   ],
   "source": [
    "y = x.view(15)\n",
    "z = x.view(-1, 5)  # -1所指的维度可以根据其他维度的值推出来\n",
    "print(x.size(), y.size(), z.size())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**注意`view()`返回的新tensor与源tensor共享内存,也即更改其中的一个,另外一个也会跟着改变。**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[2.6035, 2.8110, 1.9549],\n",
      "        [1.8797, 2.0482, 0.9555],\n",
      "        [0.2771, 3.8663, 0.4345],\n",
      "        [1.1604, 0.9746, 2.0739],\n",
      "        [3.2628, 0.0825, 0.7749]])\n",
      "tensor([2.6035, 2.8110, 1.9549, 1.8797, 2.0482, 0.9555, 0.2771, 3.8663, 0.4345,\n",
      "        1.1604, 0.9746, 2.0739, 3.2628, 0.0825, 0.7749])\n"
     ]
    }
   ],
   "source": [
    "x += 1\n",
    "print(x)\n",
    "print(y) # 也加了1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "如果不想共享内存,推荐先用`clone`创造一个副本然后再使用`view`。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[ 1.6035,  1.8110,  0.9549],\n",
      "        [ 0.8797,  1.0482, -0.0445],\n",
      "        [-0.7229,  2.8663, -0.5655],\n",
      "        [ 0.1604, -0.0254,  1.0739],\n",
      "        [ 2.2628, -0.9175, -0.2251]])\n",
      "tensor([2.6035, 2.8110, 1.9549, 1.8797, 2.0482, 0.9555, 0.2771, 3.8663, 0.4345,\n",
      "        1.1604, 0.9746, 2.0739, 3.2628, 0.0825, 0.7749])\n"
     ]
    }
   ],
   "source": [
    "x_cp = x.clone().view(15)\n",
    "x -= 1\n",
    "print(x)\n",
    "print(x_cp)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "另外一个常用的函数就是`item()`, 它可以将一个标量`Tensor`转换成一个Python number:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([2.3466])\n",
      "2.3466382026672363\n"
     ]
    }
   ],
   "source": [
    "x = torch.randn(1)\n",
    "print(x)\n",
    "print(x.item())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.2.3 广播机制"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[1, 2]])\n",
      "tensor([[1],\n",
      "        [2],\n",
      "        [3]])\n",
      "tensor([[2, 3],\n",
      "        [3, 4],\n",
      "        [4, 5]])\n"
     ]
    }
   ],
   "source": [
    "x = torch.arange(1, 3).view(1, 2)\n",
    "print(x)\n",
    "y = torch.arange(1, 4).view(3, 1)\n",
    "print(y)\n",
    "print(x + y)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.2.4 运算的内存开销"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n"
     ]
    }
   ],
   "source": [
    "x = torch.tensor([1, 2])\n",
    "y = torch.tensor([3, 4])\n",
    "id_before = id(y)\n",
    "y = y + x\n",
    "print(id(y) == id_before)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "x = torch.tensor([1, 2])\n",
    "y = torch.tensor([3, 4])\n",
    "id_before = id(y)\n",
    "y[:] = y + x\n",
    "print(id(y) == id_before)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "x = torch.tensor([1, 2])\n",
    "y = torch.tensor([3, 4])\n",
    "id_before = id(y)\n",
    "torch.add(x, y, out=y) # y += x, y.add_(x)\n",
    "print(id(y) == id_before)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.2.5 `Tensor`和NumPy相互转换\n",
    "**`numpy()`和`from_numpy()`这两个函数产生的`Tensor`和NumPy array实际是使用的相同的内存,改变其中一个时另一个也会改变!!!**\n",
    "### `Tensor`转NumPy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([1., 1., 1., 1., 1.]) [1. 1. 1. 1. 1.]\n",
      "tensor([2., 2., 2., 2., 2.]) [2. 2. 2. 2. 2.]\n",
      "tensor([3., 3., 3., 3., 3.]) [3. 3. 3. 3. 3.]\n"
     ]
    }
   ],
   "source": [
    "a = torch.ones(5)\n",
    "b = a.numpy()\n",
    "print(a, b)\n",
    "\n",
    "a += 1\n",
    "print(a, b)\n",
    "b += 1\n",
    "print(a, b)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### NumPy数组转`Tensor`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1. 1. 1. 1. 1.] tensor([1., 1., 1., 1., 1.], dtype=torch.float64)\n",
      "[2. 2. 2. 2. 2.] tensor([2., 2., 2., 2., 2.], dtype=torch.float64)\n",
      "[3. 3. 3. 3. 3.] tensor([3., 3., 3., 3., 3.], dtype=torch.float64)\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "a = np.ones(5)\n",
    "b = torch.from_numpy(a)\n",
    "print(a, b)\n",
    "\n",
    "a += 1\n",
    "print(a, b)\n",
    "b += 1\n",
    "print(a, b)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "直接用`torch.tensor()`将NumPy数组转换成`Tensor`,该方法总是会进行数据拷贝,返回的`Tensor`和原来的数据不再共享内存。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[4. 4. 4. 4. 4.] tensor([3., 3., 3., 3., 3.], dtype=torch.float64)\n"
     ]
    }
   ],
   "source": [
    "# 用torch.tensor()转换时不会共享内存\n",
    "c = torch.tensor(a)\n",
    "a += 1\n",
    "print(a, c)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.2.6 `Tensor` on GPU"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 以下代码只有在PyTorch GPU版本上才会执行\n",
    "if torch.cuda.is_available():\n",
    "    device = torch.device(\"cuda\")          # GPU\n",
    "    y = torch.ones_like(x, device=device)  # 直接创建一个在GPU上的Tensor\n",
    "    x = x.to(device)                       # 等价于 .to(\"cuda\")\n",
    "    z = x + y\n",
    "    print(z)\n",
    "    print(z.to(\"cpu\", torch.double))       # to()还可以同时更改数据类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}


================================================
FILE: code/chapter02_prerequisite/2.3_autograd.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.4.1\n"
     ]
    }
   ],
   "source": [
    "import torch\n",
    "\n",
    "print(torch.__version__)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2.3 自动求梯度\n",
    "## 2.3.1 概念\n",
    "上一节介绍的`Tensor`是这个包的核心类,如果将其属性`.requires_grad`设置为`True`,它将开始追踪(track)在其上的所有操作。完成计算后,可以调用`.backward()`来完成所有梯度计算。此`Tensor`的梯度将累积到`.grad`属性中。\n",
    "> 注意在调用`.backward()`时,如果`Tensor`是标量,则不需要为`backward()`指定任何参数;否则,需要指定一个求导变量。\n",
    "\n",
    "如果不想要被继续追踪,可以调用`.detach()`将其从追踪记录中分离出来,这样就可以防止将来的计算被追踪。此外,还可以用`with torch.no_grad()`将不想被追踪的操作代码块包裹起来,这种方法在评估模型的时候很常用,因为在评估模型时,我们并不需要计算可训练参数(`requires_grad=True`)的梯度。\n",
    "\n",
    "`Function`是另外一个很重要的类。`Tensor`和`Function`互相结合就可以构建一个记录有整个计算过程的非循环图。每个`Tensor`都有一个`.grad_fn`属性,该属性即创建该`Tensor`的`Function`(除非用户创建的`Tensor`s时设置了`grad_fn=None`)。\n",
    "\n",
    "下面通过一些例子来理解这些概念。\n",
    "\n",
    "## 2.3.2 `Tensor`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[1., 1.],\n",
      "        [1., 1.]], requires_grad=True)\n",
      "None\n"
     ]
    }
   ],
   "source": [
    "x = torch.ones(2, 2, requires_grad=True)\n",
    "print(x)\n",
    "print(x.grad_fn)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[3., 3.],\n",
      "        [3., 3.]], grad_fn=<AddBackward>)\n",
      "<AddBackward object at 0x10ed634a8>\n"
     ]
    }
   ],
   "source": [
    "y = x + 2\n",
    "print(y)\n",
    "print(y.grad_fn)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "注意x是直接创建的,所以它没有`grad_fn`, 而y是通过一个加法操作创建的,所以它有一个为`<AddBackward>`的`grad_fn`。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True False\n"
     ]
    }
   ],
   "source": [
    "print(x.is_leaf, y.is_leaf)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[27., 27.],\n",
      "        [27., 27.]], grad_fn=<MulBackward>) tensor(27., grad_fn=<MeanBackward1>)\n"
     ]
    }
   ],
   "source": [
    "z = y * y * 3\n",
    "out = z.mean()\n",
    "print(z, out)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "通过`.requires_grad_()`来用in-place的方式改变`requires_grad`属性:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n",
      "True\n",
      "<SumBackward0 object at 0x10ed63c50>\n"
     ]
    }
   ],
   "source": [
    "a = torch.randn(2, 2) # 缺失情况下默认 requires_grad = False\n",
    "a = ((a * 3) / (a - 1))\n",
    "print(a.requires_grad) # False\n",
    "a.requires_grad_(True)\n",
    "print(a.requires_grad) # True\n",
    "b = (a * a).sum()\n",
    "print(b.grad_fn)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.3.3 梯度 \n",
    "\n",
    "因为`out`是一个标量,所以调用`backward()`时不需要指定求导变量:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[4.5000, 4.5000],\n",
      "        [4.5000, 4.5000]])\n"
     ]
    }
   ],
   "source": [
    "out.backward() # 等价于 out.backward(torch.tensor(1.))\n",
    "print(x.grad)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "我们令`out`为 $o$ , 因为\n",
    "$$\n",
    "o=\\frac14\\sum_{i=1}^4z_i=\\frac14\\sum_{i=1}^43(x_i+2)^2\n",
    "$$\n",
    "所以\n",
    "$$\n",
    "\\frac{\\partial{o}}{\\partial{x_i}}\\bigr\\rvert_{x_i=1}=\\frac{9}{2}=4.5\n",
    "$$\n",
    "所以上面的输出是正确的。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "数学上,如果有一个函数值和自变量都为向量的函数 $\\vec{y}=f(\\vec{x})$, 那么 $\\vec{y}$ 关于 $\\vec{x}$ 的梯度就是一个雅可比矩阵(Jacobian matrix):\n",
    "\n",
    "$$\n",
    "J=\\left(\\begin{array}{ccc}\n",
    "   \\frac{\\partial y_{1}}{\\partial x_{1}} & \\cdots & \\frac{\\partial y_{1}}{\\partial x_{n}}\\\\\n",
    "   \\vdots & \\ddots & \\vdots\\\\\n",
    "   \\frac{\\partial y_{m}}{\\partial x_{1}} & \\cdots & \\frac{\\partial y_{m}}{\\partial x_{n}}\n",
    "   \\end{array}\\right)\n",
    "$$\n",
    "\n",
    "而``torch.autograd``这个包就是用来计算一些雅克比矩阵的乘积的。例如,如果 $v$ 是一个标量函数的 $l=g\\left(\\vec{y}\\right)$ 的梯度:\n",
    "\n",
    "$$\n",
    "v=\\left(\\begin{array}{ccc}\\frac{\\partial l}{\\partial y_{1}} & \\cdots & \\frac{\\partial l}{\\partial y_{m}}\\end{array}\\right)\n",
    "$$\n",
    "\n",
    "那么根据链式法则我们有 $l$ 关于 $\\vec{x}$ 的雅克比矩阵就为:\n",
    "\n",
    "$$\n",
    "v \\cdot J=\\left(\\begin{array}{ccc}\\frac{\\partial l}{\\partial y_{1}} & \\cdots & \\frac{\\partial l}{\\partial y_{m}}\\end{array}\\right) \\left(\\begin{array}{ccc}\n",
    "   \\frac{\\partial y_{1}}{\\partial x_{1}} & \\cdots & \\frac{\\partial y_{1}}{\\partial x_{n}}\\\\\n",
    "   \\vdots & \\ddots & \\vdots\\\\\n",
    "   \\frac{\\partial y_{m}}{\\partial x_{1}} & \\cdots & \\frac{\\partial y_{m}}{\\partial x_{n}}\n",
    "   \\end{array}\\right)=\\left(\\begin{array}{ccc}\\frac{\\partial l}{\\partial x_{1}} & \\cdots & \\frac{\\partial l}{\\partial x_{n}}\\end{array}\\right)\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "注意:grad在反向传播过程中是累加的(accumulated),这意味着每一次运行反向传播,梯度都会累加之前的梯度,所以一般在反向传播之前需把梯度清零。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[5.5000, 5.5000],\n",
      "        [5.5000, 5.5000]])\n",
      "tensor([[1., 1.],\n",
      "        [1., 1.]])\n"
     ]
    }
   ],
   "source": [
    "# 再来反向传播一次,注意grad是累加的\n",
    "out2 = x.sum()\n",
    "out2.backward()\n",
    "print(x.grad)\n",
    "\n",
    "out3 = x.sum()\n",
    "x.grad.data.zero_()\n",
    "out3.backward()\n",
    "print(x.grad)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[2., 4.],\n",
      "        [6., 8.]], grad_fn=<ViewBackward>)\n"
     ]
    }
   ],
   "source": [
    "x = torch.tensor([1.0, 2.0, 3.0, 4.0], requires_grad=True)\n",
    "y = 2 * x\n",
    "z = y.view(2, 2)\n",
    "print(z)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "现在 `y` 不是一个标量,所以在调用`backward`时需要传入一个和`y`同形的权重向量进行加权求和得到一个标量。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([2.0000, 0.2000, 0.0200, 0.0020])\n"
     ]
    }
   ],
   "source": [
    "v = torch.tensor([[1.0, 0.1], [0.01, 0.001]], dtype=torch.float)\n",
    "z.backward(v)\n",
    "\n",
    "print(x.grad)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "再来看看中断梯度追踪的例子:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor(1., requires_grad=True) True\n",
      "tensor(1., grad_fn=<PowBackward0>) True\n",
      "tensor(1.) False\n",
      "tensor(2., grad_fn=<ThAddBackward>) True\n"
     ]
    }
   ],
   "source": [
    "x = torch.tensor(1.0, requires_grad=True)\n",
    "y1 = x ** 2 \n",
    "with torch.no_grad():\n",
    "    y2 = x ** 3\n",
    "y3 = y1 + y2\n",
    "    \n",
    "print(x, x.requires_grad)\n",
    "print(y1, y1.requires_grad)\n",
    "print(y2, y2.requires_grad)\n",
    "print(y3, y3.requires_grad)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor(2.)\n"
     ]
    }
   ],
   "source": [
    "y3.backward()\n",
    "print(x.grad)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "为什么是2呢?$ y_3 = y_1 + y_2 = x^2 + x^3$,当 $x=1$ 时 $\\frac {dy_3} {dx}$ 不应该是5吗?事实上,由于 $y_2$ 的定义是被`torch.no_grad():`包裹的,所以与 $y_2$ 有关的梯度是不会回传的,只有与 $y_1$ 有关的梯度才会回传,即 $x^2$ 对 $x$ 的梯度。\n",
    "\n",
    "上面提到,`y2.requires_grad=False`,所以不能调用 `y2.backward()`。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# y2.backward() # 会报错 RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "如果我们想要修改`tensor`的数值,但是又不希望被`autograd`记录(即不会影响反向传播),那么我么可以对`tensor.data`进行操作."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([1.])\n",
      "False\n",
      "tensor([100.], requires_grad=True)\n",
      "tensor([2.])\n"
     ]
    }
   ],
   "source": [
    "x = torch.ones(1,requires_grad=True)\n",
    "\n",
    "print(x.data) # 还是一个tensor\n",
    "print(x.data.requires_grad) # 但是已经是独立于计算图之外\n",
    "\n",
    "y = 2 * x\n",
    "x.data *= 100 # 只改变了值,不会记录在计算图,所以不会影响梯度传播\n",
    "\n",
    "y.backward()\n",
    "print(x) # 更改data的值也会影响tensor的值\n",
    "print(x.grad)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}


================================================
FILE: code/chapter03_DL-basics/3.10_mlp-pytorch.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3.10 多层感知机的简洁实现"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.4.1\n"
     ]
    }
   ],
   "source": [
    "import torch\n",
    "from torch import nn\n",
    "from torch.nn import init\n",
    "import numpy as np\n",
    "import sys\n",
    "sys.path.append(\"..\") \n",
    "import d2lzh_pytorch as d2l\n",
    "\n",
    "print(torch.__version__)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3.10.1 定义模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "num_inputs, num_outputs, num_hiddens = 784, 10, 256\n",
    "    \n",
    "net = nn.Sequential(\n",
    "        d2l.FlattenLayer(),\n",
    "        nn.Linear(num_inputs, num_hiddens),\n",
    "        nn.ReLU(),\n",
    "        nn.Linear(num_hiddens, num_outputs), \n",
    "        )\n",
    "    \n",
    "for params in net.parameters():\n",
    "    init.normal_(params, mean=0, std=0.01)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3.10.2 读取数据并训练模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch 1, loss 0.0031, train acc 0.703, test acc 0.757\n",
      "epoch 2, loss 0.0019, train acc 0.824, test acc 0.822\n",
      "epoch 3, loss 0.0016, train acc 0.845, test acc 0.825\n",
      "epoch 4, loss 0.0015, train acc 0.855, test acc 0.811\n",
      "epoch 5, loss 0.0014, train acc 0.865, test acc 0.846\n"
     ]
    }
   ],
   "source": [
    "batch_size = 256\n",
    "train_iter, test_iter = d2l.load_data_fashion_mnist(batch_size)\n",
    "loss = torch.nn.CrossEntropyLoss()\n",
    "\n",
    "optimizer = torch.optim.SGD(net.parameters(), lr=0.5)\n",
    "\n",
    "num_epochs = 5\n",
    "d2l.train_ch3(net, train_iter, test_iter, loss, num_epochs, batch_size, None, None, optimizer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}


================================================
FILE: code/chapter03_DL-basics/3.11_underfit-overfit.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3.11 模型选择、欠拟合和过拟合\n",
    "## 3.11.4 多项式函数拟合实验"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.4.1\n"
     ]
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "import torch\n",
    "import numpy as np\n",
    "import sys\n",
    "sys.path.append(\"..\") \n",
    "import d2lzh_pytorch as d2l\n",
    "\n",
    "print(torch.__version__)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.11.4.1 生成数据集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "n_train, n_test, true_w, true_b = 100, 100, [1.2, -3.4, 5.6], 5\n",
    "features = torch.randn((n_train + n_test, 1))\n",
    "poly_features = torch.cat((features, torch.pow(features, 2), torch.pow(features, 3)), 1) \n",
    "labels = (true_w[0] * poly_features[:, 0] + true_w[1] * poly_features[:, 1]\n",
    "          + true_w[2] * poly_features[:, 2] + true_b)\n",
    "labels += torch.tensor(np.random.normal(0, 0.01, size=labels.size()), dtype=torch.float)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(tensor([[0.2398],\n",
       "         [1.6313]]), tensor([[0.2398, 0.0575, 0.0138],\n",
       "         [1.6313, 2.6610, 4.3408]]), tensor([ 5.1772, 22.2243]))"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "features[:2], poly_features[:2], labels[:2]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.11.4.2 定义、训练和测试模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def semilogy(x_vals, y_vals, x_label, y_label, x2_vals=None, y2_vals=None,\n",
    "             legend=None, figsize=(3.5, 2.5)):\n",
    "    d2l.set_figsize(figsize)\n",
    "    d2l.plt.xlabel(x_label)\n",
    "    d2l.plt.ylabel(y_label)\n",
    "    d2l.plt.semilogy(x_vals, y_vals)\n",
    "    if x2_vals and y2_vals:\n",
    "        d2l.plt.semilogy(x2_vals, y2_vals, linestyle=':')\n",
    "        d2l.plt.legend(legend)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "num_epochs, loss = 100, torch.nn.MSELoss()\n",
    "\n",
    "def fit_and_plot(train_features, test_features, train_labels, test_labels):\n",
    "    net = torch.nn.Linear(train_features.shape[-1], 1)\n",
    "    # 通过Linear文档可知,pytorch已经将参数初始化了,所以我们这里就不手动初始化了\n",
    "    \n",
    "    batch_size = min(10, train_labels.shape[0])    \n",
    "    dataset = torch.utils.data.TensorDataset(train_features, train_labels)\n",
    "    train_iter = torch.utils.data.DataLoader(dataset, batch_size, shuffle=True)\n",
    "    \n",
    "    optimizer = torch.optim.SGD(net.parameters(), lr=0.01)\n",
    "    train_ls, test_ls = [], []\n",
    "    for _ in range(num_epochs):\n",
    "        for X, y in train_iter:\n",
    "            l = loss(net(X), y.view(-1, 1))\n",
    "            optimizer.zero_grad()\n",
    "            l.backward()\n",
    "            optimizer.step()\n",
    "        train_labels = train_labels.view(-1, 1)\n",
    "        test_labels = test_labels.view(-1, 1)\n",
    "        train_ls.append(loss(net(train_features), train_labels).item())\n",
    "        test_ls.append(loss(net(test_features), test_labels).item())\n",
    "    print('final epoch: train loss', train_ls[-1], 'test loss', test_ls[-1])\n",
    "    semilogy(range(1, num_epochs + 1), train_ls, 'epochs', 'loss',\n",
    "             range(1, num_epochs + 1), test_ls, ['train', 'test'])\n",
    "    print('weight:', net.weight.data,\n",
    "          '\\nbias:', net.bias.data)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.11.4.3 三阶多项式函数拟合(正常)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "final epoch: train loss 0.00010175639908993617 test loss 9.790256444830447e-05\n",
      "weight: tensor([[ 1.1982, -3.3992,  5.6002]]) \n",
      "bias: tensor([5.0014])\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Created with matplotlib (http://matplotlib.org/) -->\n",
       "<svg height=\"184pt\" version=\"1.1\" viewBox=\"0 0 257 184\" width=\"257pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       " <defs>\n",
       "  <style type=\"text/css\">\n",
       "*{stroke-linecap:butt;stroke-linejoin:round;}\n",
       "  </style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 184.15625 \n",
       "L 257.378125 184.15625 \n",
       "L 257.378125 -0 \n",
       "L 0 -0 \n",
       "z\n",
       "\" style=\"fill:none;\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 51.378125 146.6 \n",
       "L 246.678125 146.6 \n",
       "L 246.678125 10.7 \n",
       "L 51.378125 10.7 \n",
       "z\n",
       "\" style=\"fill:#ffffff;\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" id=\"m1e3620be05\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"58.462009\" xlink:href=\"#m1e3620be05\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 0 -->\n",
       "      <defs>\n",
       "       <path d=\"M 31.78125 66.40625 \n",
       "Q 24.171875 66.40625 20.328125 58.90625 \n",
       "Q 16.5 51.421875 16.5 36.375 \n",
       "Q 16.5 21.390625 20.328125 13.890625 \n",
       "Q 24.171875 6.390625 31.78125 6.390625 \n",
       "Q 39.453125 6.390625 43.28125 13.890625 \n",
       "Q 47.125 21.390625 47.125 36.375 \n",
       "Q 47.125 51.421875 43.28125 58.90625 \n",
       "Q 39.453125 66.40625 31.78125 66.40625 \n",
       "z\n",
       "M 31.78125 74.21875 \n",
       "Q 44.046875 74.21875 50.515625 64.515625 \n",
       "Q 56.984375 54.828125 56.984375 36.375 \n",
       "Q 56.984375 17.96875 50.515625 8.265625 \n",
       "Q 44.046875 -1.421875 31.78125 -1.421875 \n",
       "Q 19.53125 -1.421875 13.0625 8.265625 \n",
       "Q 6.59375 17.96875 6.59375 36.375 \n",
       "Q 6.59375 54.828125 13.0625 64.515625 \n",
       "Q 19.53125 74.21875 31.78125 74.21875 \n",
       "z\n",
       "\" id=\"DejaVuSans-30\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(55.280759 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_2\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"94.329778\" xlink:href=\"#m1e3620be05\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 20 -->\n",
       "      <defs>\n",
       "       <path d=\"M 19.1875 8.296875 \n",
       "L 53.609375 8.296875 \n",
       "L 53.609375 0 \n",
       "L 7.328125 0 \n",
       "L 7.328125 8.296875 \n",
       "Q 12.9375 14.109375 22.625 23.890625 \n",
       "Q 32.328125 33.6875 34.8125 36.53125 \n",
       "Q 39.546875 41.84375 41.421875 45.53125 \n",
       "Q 43.3125 49.21875 43.3125 52.78125 \n",
       "Q 43.3125 58.59375 39.234375 62.25 \n",
       "Q 35.15625 65.921875 28.609375 65.921875 \n",
       "Q 23.96875 65.921875 18.8125 64.3125 \n",
       "Q 13.671875 62.703125 7.8125 59.421875 \n",
       "L 7.8125 69.390625 \n",
       "Q 13.765625 71.78125 18.9375 73 \n",
       "Q 24.125 74.21875 28.421875 74.21875 \n",
       "Q 39.75 74.21875 46.484375 68.546875 \n",
       "Q 53.21875 62.890625 53.21875 53.421875 \n",
       "Q 53.21875 48.921875 51.53125 44.890625 \n",
       "Q 49.859375 40.875 45.40625 35.40625 \n",
       "Q 44.1875 33.984375 37.640625 27.21875 \n",
       "Q 31.109375 20.453125 19.1875 8.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-32\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(87.967278 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"130.197546\" xlink:href=\"#m1e3620be05\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 40 -->\n",
       "      <defs>\n",
       "       <path d=\"M 37.796875 64.3125 \n",
       "L 12.890625 25.390625 \n",
       "L 37.796875 25.390625 \n",
       "z\n",
       "M 35.203125 72.90625 \n",
       "L 47.609375 72.90625 \n",
       "L 47.609375 25.390625 \n",
       "L 58.015625 25.390625 \n",
       "L 58.015625 17.1875 \n",
       "L 47.609375 17.1875 \n",
       "L 47.609375 0 \n",
       "L 37.796875 0 \n",
       "L 37.796875 17.1875 \n",
       "L 4.890625 17.1875 \n",
       "L 4.890625 26.703125 \n",
       "z\n",
       "\" id=\"DejaVuSans-34\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(123.835046 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-34\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"166.065315\" xlink:href=\"#m1e3620be05\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 60 -->\n",
       "      <defs>\n",
       "       <path d=\"M 33.015625 40.375 \n",
       "Q 26.375 40.375 22.484375 35.828125 \n",
       "Q 18.609375 31.296875 18.609375 23.390625 \n",
       "Q 18.609375 15.53125 22.484375 10.953125 \n",
       "Q 26.375 6.390625 33.015625 6.390625 \n",
       "Q 39.65625 6.390625 43.53125 10.953125 \n",
       "Q 47.40625 15.53125 47.40625 23.390625 \n",
       "Q 47.40625 31.296875 43.53125 35.828125 \n",
       "Q 39.65625 40.375 33.015625 40.375 \n",
       "z\n",
       "M 52.59375 71.296875 \n",
       "L 52.59375 62.3125 \n",
       "Q 48.875 64.0625 45.09375 64.984375 \n",
       "Q 41.3125 65.921875 37.59375 65.921875 \n",
       "Q 27.828125 65.921875 22.671875 59.328125 \n",
       "Q 17.53125 52.734375 16.796875 39.40625 \n",
       "Q 19.671875 43.65625 24.015625 45.921875 \n",
       "Q 28.375 48.1875 33.59375 48.1875 \n",
       "Q 44.578125 48.1875 50.953125 41.515625 \n",
       "Q 57.328125 34.859375 57.328125 23.390625 \n",
       "Q 57.328125 12.15625 50.6875 5.359375 \n",
       "Q 44.046875 -1.421875 33.015625 -1.421875 \n",
       "Q 20.359375 -1.421875 13.671875 8.265625 \n",
       "Q 6.984375 17.96875 6.984375 36.375 \n",
       "Q 6.984375 53.65625 15.1875 63.9375 \n",
       "Q 23.390625 74.21875 37.203125 74.21875 \n",
       "Q 40.921875 74.21875 44.703125 73.484375 \n",
       "Q 48.484375 72.75 52.59375 71.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-36\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(159.702815 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-36\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"201.933084\" xlink:href=\"#m1e3620be05\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 80 -->\n",
       "      <defs>\n",
       "       <path d=\"M 31.78125 34.625 \n",
       "Q 24.75 34.625 20.71875 30.859375 \n",
       "Q 16.703125 27.09375 16.703125 20.515625 \n",
       "Q 16.703125 13.921875 20.71875 10.15625 \n",
       "Q 24.75 6.390625 31.78125 6.390625 \n",
       "Q 38.8125 6.390625 42.859375 10.171875 \n",
       "Q 46.921875 13.96875 46.921875 20.515625 \n",
       "Q 46.921875 27.09375 42.890625 30.859375 \n",
       "Q 38.875 34.625 31.78125 34.625 \n",
       "z\n",
       "M 21.921875 38.8125 \n",
       "Q 15.578125 40.375 12.03125 44.71875 \n",
       "Q 8.5 49.078125 8.5 55.328125 \n",
       "Q 8.5 64.0625 14.71875 69.140625 \n",
       "Q 20.953125 74.21875 31.78125 74.21875 \n",
       "Q 42.671875 74.21875 48.875 69.140625 \n",
       "Q 55.078125 64.0625 55.078125 55.328125 \n",
       "Q 55.078125 49.078125 51.53125 44.71875 \n",
       "Q 48 40.375 41.703125 38.8125 \n",
       "Q 48.828125 37.15625 52.796875 32.3125 \n",
       "Q 56.78125 27.484375 56.78125 20.515625 \n",
       "Q 56.78125 9.90625 50.3125 4.234375 \n",
       "Q 43.84375 -1.421875 31.78125 -1.421875 \n",
       "Q 19.734375 -1.421875 13.25 4.234375 \n",
       "Q 6.78125 9.90625 6.78125 20.515625 \n",
       "Q 6.78125 27.484375 10.78125 32.3125 \n",
       "Q 14.796875 37.15625 21.921875 38.8125 \n",
       "z\n",
       "M 18.3125 54.390625 \n",
       "Q 18.3125 48.734375 21.84375 45.5625 \n",
       "Q 25.390625 42.390625 31.78125 42.390625 \n",
       "Q 38.140625 42.390625 41.71875 45.5625 \n",
       "Q 45.3125 48.734375 45.3125 54.390625 \n",
       "Q 45.3125 60.0625 41.71875 63.234375 \n",
       "Q 38.140625 66.40625 31.78125 66.40625 \n",
       "Q 25.390625 66.40625 21.84375 63.234375 \n",
       "Q 18.3125 60.0625 18.3125 54.390625 \n",
       "z\n",
       "\" id=\"DejaVuSans-38\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(195.570584 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-38\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_6\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"237.800852\" xlink:href=\"#m1e3620be05\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 100 -->\n",
       "      <defs>\n",
       "       <path d=\"M 12.40625 8.296875 \n",
       "L 28.515625 8.296875 \n",
       "L 28.515625 63.921875 \n",
       "L 10.984375 60.40625 \n",
       "L 10.984375 69.390625 \n",
       "L 28.421875 72.90625 \n",
       "L 38.28125 72.90625 \n",
       "L 38.28125 8.296875 \n",
       "L 54.390625 8.296875 \n",
       "L 54.390625 0 \n",
       "L 12.40625 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-31\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(228.257102 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_7\">\n",
       "     <!-- epochs -->\n",
       "     <defs>\n",
       "      <path d=\"M 56.203125 29.59375 \n",
       "L 56.203125 25.203125 \n",
       "L 14.890625 25.203125 \n",
       "Q 15.484375 15.921875 20.484375 11.0625 \n",
       "Q 25.484375 6.203125 34.421875 6.203125 \n",
       "Q 39.59375 6.203125 44.453125 7.46875 \n",
       "Q 49.3125 8.734375 54.109375 11.28125 \n",
       "L 54.109375 2.78125 \n",
       "Q 49.265625 0.734375 44.1875 -0.34375 \n",
       "Q 39.109375 -1.421875 33.890625 -1.421875 \n",
       "Q 20.796875 -1.421875 13.15625 6.1875 \n",
       "Q 5.515625 13.8125 5.515625 26.8125 \n",
       "Q 5.515625 40.234375 12.765625 48.109375 \n",
       "Q 20.015625 56 32.328125 56 \n",
       "Q 43.359375 56 49.78125 48.890625 \n",
       "Q 56.203125 41.796875 56.203125 29.59375 \n",
       "z\n",
       "M 47.21875 32.234375 \n",
       "Q 47.125 39.59375 43.09375 43.984375 \n",
       "Q 39.0625 48.390625 32.421875 48.390625 \n",
       "Q 24.90625 48.390625 20.390625 44.140625 \n",
       "Q 15.875 39.890625 15.1875 32.171875 \n",
       "z\n",
       "\" id=\"DejaVuSans-65\"/>\n",
       "      <path d=\"M 18.109375 8.203125 \n",
       "L 18.109375 -20.796875 \n",
       "L 9.078125 -20.796875 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.390625 \n",
       "Q 20.953125 51.265625 25.265625 53.625 \n",
       "Q 29.59375 56 35.59375 56 \n",
       "Q 45.5625 56 51.78125 48.09375 \n",
       "Q 58.015625 40.1875 58.015625 27.296875 \n",
       "Q 58.015625 14.40625 51.78125 6.484375 \n",
       "Q 45.5625 -1.421875 35.59375 -1.421875 \n",
       "Q 29.59375 -1.421875 25.265625 0.953125 \n",
       "Q 20.953125 3.328125 18.109375 8.203125 \n",
       "z\n",
       "M 48.6875 27.296875 \n",
       "Q 48.6875 37.203125 44.609375 42.84375 \n",
       "Q 40.53125 48.484375 33.40625 48.484375 \n",
       "Q 26.265625 48.484375 22.1875 42.84375 \n",
       "Q 18.109375 37.203125 18.109375 27.296875 \n",
       "Q 18.109375 17.390625 22.1875 11.75 \n",
       "Q 26.265625 6.109375 33.40625 6.109375 \n",
       "Q 40.53125 6.109375 44.609375 11.75 \n",
       "Q 48.6875 17.390625 48.6875 27.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-70\"/>\n",
       "      <path d=\"M 30.609375 48.390625 \n",
       "Q 23.390625 48.390625 19.1875 42.75 \n",
       "Q 14.984375 37.109375 14.984375 27.296875 \n",
       "Q 14.984375 17.484375 19.15625 11.84375 \n",
       "Q 23.34375 6.203125 30.609375 6.203125 \n",
       "Q 37.796875 6.203125 41.984375 11.859375 \n",
       "Q 46.1875 17.53125 46.1875 27.296875 \n",
       "Q 46.1875 37.015625 41.984375 42.703125 \n",
       "Q 37.796875 48.390625 30.609375 48.390625 \n",
       "z\n",
       "M 30.609375 56 \n",
       "Q 42.328125 56 49.015625 48.375 \n",
       "Q 55.71875 40.765625 55.71875 27.296875 \n",
       "Q 55.71875 13.875 49.015625 6.21875 \n",
       "Q 42.328125 -1.421875 30.609375 -1.421875 \n",
       "Q 18.84375 -1.421875 12.171875 6.21875 \n",
       "Q 5.515625 13.875 5.515625 27.296875 \n",
       "Q 5.515625 40.765625 12.171875 48.375 \n",
       "Q 18.84375 56 30.609375 56 \n",
       "z\n",
       "\" id=\"DejaVuSans-6f\"/>\n",
       "      <path d=\"M 48.78125 52.59375 \n",
       "L 48.78125 44.1875 \n",
       "Q 44.96875 46.296875 41.140625 47.34375 \n",
       "Q 37.3125 48.390625 33.40625 48.390625 \n",
       "Q 24.65625 48.390625 19.8125 42.84375 \n",
       "Q 14.984375 37.3125 14.984375 27.296875 \n",
       "Q 14.984375 17.28125 19.8125 11.734375 \n",
       "Q 24.65625 6.203125 33.40625 6.203125 \n",
       "Q 37.3125 6.203125 41.140625 7.25 \n",
       "Q 44.96875 8.296875 48.78125 10.40625 \n",
       "L 48.78125 2.09375 \n",
       "Q 45.015625 0.34375 40.984375 -0.53125 \n",
       "Q 36.96875 -1.421875 32.421875 -1.421875 \n",
       "Q 20.0625 -1.421875 12.78125 6.34375 \n",
       "Q 5.515625 14.109375 5.515625 27.296875 \n",
       "Q 5.515625 40.671875 12.859375 48.328125 \n",
       "Q 20.21875 56 33.015625 56 \n",
       "Q 37.15625 56 41.109375 55.140625 \n",
       "Q 45.0625 54.296875 48.78125 52.59375 \n",
       "z\n",
       "\" id=\"DejaVuSans-63\"/>\n",
       "      <path d=\"M 54.890625 33.015625 \n",
       "L 54.890625 0 \n",
       "L 45.90625 0 \n",
       "L 45.90625 32.71875 \n",
       "Q 45.90625 40.484375 42.875 44.328125 \n",
       "Q 39.84375 48.1875 33.796875 48.1875 \n",
       "Q 26.515625 48.1875 22.3125 43.546875 \n",
       "Q 18.109375 38.921875 18.109375 30.90625 \n",
       "L 18.109375 0 \n",
       "L 9.078125 0 \n",
       "L 9.078125 75.984375 \n",
       "L 18.109375 75.984375 \n",
       "L 18.109375 46.1875 \n",
       "Q 21.34375 51.125 25.703125 53.5625 \n",
       "Q 30.078125 56 35.796875 56 \n",
       "Q 45.21875 56 50.046875 50.171875 \n",
       "Q 54.890625 44.34375 54.890625 33.015625 \n",
       "z\n",
       "\" id=\"DejaVuSans-68\"/>\n",
       "      <path d=\"M 44.28125 53.078125 \n",
       "L 44.28125 44.578125 \n",
       "Q 40.484375 46.53125 36.375 47.5 \n",
       "Q 32.28125 48.484375 27.875 48.484375 \n",
       "Q 21.1875 48.484375 17.84375 46.4375 \n",
       "Q 14.5 44.390625 14.5 40.28125 \n",
       "Q 14.5 37.15625 16.890625 35.375 \n",
       "Q 19.28125 33.59375 26.515625 31.984375 \n",
       "L 29.59375 31.296875 \n",
       "Q 39.15625 29.25 43.1875 25.515625 \n",
       "Q 47.21875 21.78125 47.21875 15.09375 \n",
       "Q 47.21875 7.46875 41.1875 3.015625 \n",
       "Q 35.15625 -1.421875 24.609375 -1.421875 \n",
       "Q 20.21875 -1.421875 15.453125 -0.5625 \n",
       "Q 10.6875 0.296875 5.421875 2 \n",
       "L 5.421875 11.28125 \n",
       "Q 10.40625 8.6875 15.234375 7.390625 \n",
       "Q 20.0625 6.109375 24.8125 6.109375 \n",
       "Q 31.15625 6.109375 34.5625 8.28125 \n",
       "Q 37.984375 10.453125 37.984375 14.40625 \n",
       "Q 37.984375 18.0625 35.515625 20.015625 \n",
       "Q 33.0625 21.96875 24.703125 23.78125 \n",
       "L 21.578125 24.515625 \n",
       "Q 13.234375 26.265625 9.515625 29.90625 \n",
       "Q 5.8125 33.546875 5.8125 39.890625 \n",
       "Q 5.8125 47.609375 11.28125 51.796875 \n",
       "Q 16.75 56 26.8125 56 \n",
       "Q 31.78125 56 36.171875 55.265625 \n",
       "Q 40.578125 54.546875 44.28125 53.078125 \n",
       "z\n",
       "\" id=\"DejaVuSans-73\"/>\n",
       "     </defs>\n",
       "     <g transform=\"translate(131.195312 174.876562)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-65\"/>\n",
       "      <use x=\"61.523438\" xlink:href=\"#DejaVuSans-70\"/>\n",
       "      <use x=\"125\" xlink:href=\"#DejaVuSans-6f\"/>\n",
       "      <use x=\"186.181641\" xlink:href=\"#DejaVuSans-63\"/>\n",
       "      <use x=\"241.162109\" xlink:href=\"#DejaVuSans-68\"/>\n",
       "      <use x=\"304.541016\" xlink:href=\"#DejaVuSans-73\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L -3.5 0 \n",
       "\" id=\"m4edd324c16\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"51.378125\" xlink:href=\"#m4edd324c16\" y=\"118.723995\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- $\\mathdefault{10^{-3}}$ -->\n",
       "      <defs>\n",
       "       <path d=\"M 10.59375 35.5 \n",
       "L 73.1875 35.5 \n",
       "L 73.1875 27.203125 \n",
       "L 10.59375 27.203125 \n",
       "z\n",
       "\" id=\"DejaVuSans-2212\"/>\n",
       "       <path d=\"M 40.578125 39.3125 \n",
       "Q 47.65625 37.796875 51.625 33 \n",
       "Q 55.609375 28.21875 55.609375 21.1875 \n",
       "Q 55.609375 10.40625 48.1875 4.484375 \n",
       "Q 40.765625 -1.421875 27.09375 -1.421875 \n",
       "Q 22.515625 -1.421875 17.65625 -0.515625 \n",
       "Q 12.796875 0.390625 7.625 2.203125 \n",
       "L 7.625 11.71875 \n",
       "Q 11.71875 9.328125 16.59375 8.109375 \n",
       "Q 21.484375 6.890625 26.8125 6.890625 \n",
       "Q 36.078125 6.890625 40.9375 10.546875 \n",
       "Q 45.796875 14.203125 45.796875 21.1875 \n",
       "Q 45.796875 27.640625 41.28125 31.265625 \n",
       "Q 36.765625 34.90625 28.71875 34.90625 \n",
       "L 20.21875 34.90625 \n",
       "L 20.21875 43.015625 \n",
       "L 29.109375 43.015625 \n",
       "Q 36.375 43.015625 40.234375 45.921875 \n",
       "Q 44.09375 48.828125 44.09375 54.296875 \n",
       "Q 44.09375 59.90625 40.109375 62.90625 \n",
       "Q 36.140625 65.921875 28.71875 65.921875 \n",
       "Q 24.65625 65.921875 20.015625 65.03125 \n",
       "Q 15.375 64.15625 9.8125 62.3125 \n",
       "L 9.8125 71.09375 \n",
       "Q 15.4375 72.65625 20.34375 73.4375 \n",
       "Q 25.25 74.21875 29.59375 74.21875 \n",
       "Q 40.828125 74.21875 47.359375 69.109375 \n",
       "Q 53.90625 64.015625 53.90625 55.328125 \n",
       "Q 53.90625 49.265625 50.4375 45.09375 \n",
       "Q 46.96875 40.921875 40.578125 39.3125 \n",
       "z\n",
       "\" id=\"DejaVuSans-33\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(20.878125 122.523214)scale(0.1 -0.1)\">\n",
       "       <use transform=\"translate(0 0.765625)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use transform=\"translate(63.623047 0.765625)\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use transform=\"translate(128.203125 39.046875)scale(0.7)\" xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use transform=\"translate(186.855469 39.046875)scale(0.7)\" xlink:href=\"#DejaVuSans-33\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_8\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"51.378125\" xlink:href=\"#m4edd324c16\" y=\"75.976718\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- $\\mathdefault{10^{-1}}$ -->\n",
       "      <g transform=\"translate(20.878125 79.775937)scale(0.1 -0.1)\">\n",
       "       <use transform=\"translate(0 0.684375)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use transform=\"translate(63.623047 0.684375)\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use transform=\"translate(128.203125 38.965625)scale(0.7)\" xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use transform=\"translate(186.855469 38.965625)scale(0.7)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"51.378125\" xlink:href=\"#m4edd324c16\" y=\"33.229441\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- $\\mathdefault{10^{1}}$ -->\n",
       "      <g transform=\"translate(26.778125 37.02866)scale(0.1 -0.1)\">\n",
       "       <use transform=\"translate(0 0.684375)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use transform=\"translate(63.623047 0.684375)\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use transform=\"translate(128.203125 38.965625)scale(0.7)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_11\">\n",
       "     <!-- loss -->\n",
       "     <defs>\n",
       "      <path d=\"M 9.421875 75.984375 \n",
       "L 18.40625 75.984375 \n",
       "L 18.40625 0 \n",
       "L 9.421875 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-6c\"/>\n",
       "     </defs>\n",
       "     <g transform=\"translate(14.798437 88.307812)rotate(-90)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-6c\"/>\n",
       "      <use x=\"27.783203\" xlink:href=\"#DejaVuSans-6f\"/>\n",
       "      <use x=\"88.964844\" xlink:href=\"#DejaVuSans-73\"/>\n",
       "      <use x=\"141.064453\" xlink:href=\"#DejaVuSans-73\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_10\">\n",
       "    <path clip-path=\"url(#pef43000d95)\" d=\"M 60.255398 22.312136 \n",
       "L 62.048786 25.052795 \n",
       "L 63.842175 29.812031 \n",
       "L 65.635563 33.803115 \n",
       "L 67.428951 34.186561 \n",
       "L 69.22234 38.003111 \n",
       "L 71.015728 38.527491 \n",
       "L 72.809117 41.802507 \n",
       "L 74.602505 42.231284 \n",
       "L 76.395894 46.424487 \n",
       "L 78.189282 47.79742 \n",
       "L 79.98267 50.887748 \n",
       "L 81.776059 51.559274 \n",
       "L 83.569447 54.602315 \n",
       "L 85.362836 57.081936 \n",
       "L 87.156224 58.87341 \n",
       "L 88.949613 61.244072 \n",
       "L 90.743001 62.736151 \n",
       "L 92.536389 64.515078 \n",
       "L 94.329778 66.240003 \n",
       "L 96.123166 68.955238 \n",
       "L 97.916555 70.920648 \n",
       "L 99.709943 72.943502 \n",
       "L 101.503332 74.083096 \n",
       "L 103.29672 76.478543 \n",
       "L 105.090108 78.209511 \n",
       "L 106.883497 80.460438 \n",
       "L 108.676885 81.676456 \n",
       "L 110.470274 84.618283 \n",
       "L 112.263662 86.336865 \n",
       "L 114.057051 87.319717 \n",
       "L 115.850439 90.127376 \n",
       "L 117.643827 92.140947 \n",
       "L 119.437216 94.081225 \n",
       "L 121.230604 94.554782 \n",
       "L 123.023993 97.427263 \n",
       "L 124.817381 99.131806 \n",
       "L 126.61077 100.790721 \n",
       "L 128.404158 102.890474 \n",
       "L 130.197546 102.666252 \n",
       "L 131.990935 106.362691 \n",
       "L 133.784323 108.083384 \n",
       "L 135.577712 107.878539 \n",
       "L 137.3711 109.242643 \n",
       "L 139.164489 113.140847 \n",
       "L 140.957877 114.950527 \n",
       "L 142.751265 116.484746 \n",
       "L 144.544654 117.475334 \n",
       "L 146.338042 119.493651 \n",
       "L 148.131431 120.971276 \n",
       "L 149.924819 122.545753 \n",
       "L 151.718208 123.987345 \n",
       "L 153.511596 121.037666 \n",
       "L 155.304985 126.262189 \n",
       "L 157.098373 127.318437 \n",
       "L 158.891761 129.174839 \n",
       "L 160.68515 130.208497 \n",
       "L 162.478538 130.265239 \n",
       "L 164.271927 132.309835 \n",
       "L 166.065315 133.177147 \n",
       "L 167.858704 131.564497 \n",
       "L 169.652092 134.482878 \n",
       "L 171.44548 134.500159 \n",
       "L 173.238869 135.804985 \n",
       "L 175.032257 136.390451 \n",
       "L 176.825646 136.783806 \n",
       "L 178.619034 136.912876 \n",
       "L 180.412423 137.615707 \n",
       "L 182.205811 137.854276 \n",
       "L 183.999199 137.95188 \n",
       "L 185.792588 137.611061 \n",
       "L 187.585976 138.731662 \n",
       "L 189.379365 138.684228 \n",
       "L 191.172753 136.745141 \n",
       "L 192.966142 138.870716 \n",
       "L 194.75953 139.060945 \n",
       "L 196.552918 139.057141 \n",
       "L 198.346307 139.450506 \n",
       "L 200.139695 139.564464 \n",
       "L 201.933084 139.348307 \n",
       "L 203.726472 139.696139 \n",
       "L 205.519861 139.510829 \n",
       "L 207.313249 139.774684 \n",
       "L 209.106637 139.575802 \n",
       "L 210.900026 139.804924 \n",
       "L 212.693414 138.91555 \n",
       "L 214.486803 139.828895 \n",
       "L 216.280191 139.834305 \n",
       "L 218.07358 139.716163 \n",
       "L 219.866968 139.878441 \n",
       "L 221.660356 139.65679 \n",
       "L 223.453745 139.915291 \n",
       "L 225.247133 139.797097 \n",
       "L 227.040522 139.931601 \n",
       "L 228.83391 139.86952 \n",
       "L 230.627299 139.649371 \n",
       "L 232.420687 139.959432 \n",
       "L 234.214075 139.706699 \n",
       "L 236.007464 139.965708 \n",
       "L 237.800852 139.936012 \n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-linecap:square;stroke-width:1.5;\"/>\n",
       "   </g>\n",
       "   <g id=\"line2d_11\">\n",
       "    <path clip-path=\"url(#pef43000d95)\" d=\"M 60.255398 16.877273 \n",
       "L 62.048786 20.651275 \n",
       "L 63.842175 31.035251 \n",
       "L 65.635563 30.403708 \n",
       "L 67.428951 35.15694 \n",
       "L 69.22234 37.009892 \n",
       "L 71.015728 34.949356 \n",
       "L 72.809117 38.793168 \n",
       "L 74.602505 38.906963 \n",
       "L 76.395894 43.611266 \n",
       "L 78.189282 47.576069 \n",
       "L 79.98267 49.172526 \n",
       "L 81.776059 47.882206 \n",
       "L 83.569447 51.487593 \n",
       "L 85.362836 54.005547 \n",
       "L 87.156224 55.27651 \n",
       "L 88.949613 58.945507 \n",
       "L 90.743001 59.031797 \n",
       "L 92.536389 60.608055 \n",
       "L 94.329778 65.493628 \n",
       "L 96.123166 67.24439 \n",
       "L 97.916555 67.092102 \n",
       "L 99.709943 70.732874 \n",
       "L 101.503332 70.08517 \n",
       "L 103.29672 72.629706 \n",
       "L 105.090108 76.798096 \n",
       "L 106.883497 76.36901 \n",
       "L 108.676885 80.458737 \n",
       "L 110.470274 81.858807 \n",
       "L 112.263662 84.099175 \n",
       "L 114.057051 83.521529 \n",
       "L 115.850439 86.585054 \n",
       "L 117.643827 88.766828 \n",
       "L 119.437216 90.956176 \n",
       "L 121.230604 93.535991 \n",
       "L 123.023993 95.078925 \n",
       "L 124.817381 95.050845 \n",
       "L 126.61077 98.459721 \n",
       "L 128.404158 100.131248 \n",
       "L 130.197546 102.233234 \n",
       "L 131.990935 103.790244 \n",
       "L 133.784323 105.571767 \n",
       "L 135.577712 107.350955 \n",
       "L 137.3711 105.202252 \n",
       "L 139.164489 110.605108 \n",
       "L 140.957877 111.544777 \n",
       "L 142.751265 113.289127 \n",
       "L 144.544654 115.236159 \n",
       "L 146.338042 116.307465 \n",
       "L 148.131431 117.198897 \n",
       "L 149.924819 119.387671 \n",
       "L 151.718208 121.384027 \n",
       "L 153.511596 122.170035 \n",
       "L 155.304985 125.080269 \n",
       "L 157.098373 126.204299 \n",
       "L 158.891761 127.137956 \n",
       "L 160.68515 128.718781 \n",
       "L 162.478538 129.956568 \n",
       "L 164.271927 130.363831 \n",
       "L 166.065315 131.440482 \n",
       "L 167.858704 132.000234 \n",
       "L 169.652092 131.99527 \n",
       "L 171.44548 133.636996 \n",
       "L 173.238869 134.001828 \n",
       "L 175.032257 135.47443 \n",
       "L 176.825646 136.166257 \n",
       "L 178.619034 137.091694 \n",
       "L 180.412423 137.491843 \n",
       "L 182.205811 137.376591 \n",
       "L 183.999199 137.403712 \n",
       "L 185.792588 138.010529 \n",
       "L 187.585976 138.437343 \n",
       "L 189.379365 138.243152 \n",
       "L 191.172753 137.80249 \n",
       "L 192.966142 139.059005 \n",
       "L 194.75953 139.017259 \n",
       "L 196.552918 138.476029 \n",
       "L 198.346307 139.390448 \n",
       "L 200.139695 139.569125 \n",
       "L 201.933084 139.231194 \n",
       "L 203.726472 139.7436 \n",
       "L 205.519861 139.938598 \n",
       "L 207.313249 139.991554 \n",
       "L 209.106637 139.61803 \n",
       "L 210.900026 140.0777 \n",
       "L 212.693414 139.062648 \n",
       "L 214.486803 140.369795 \n",
       "L 216.280191 140.315004 \n",
       "L 218.07358 140.327843 \n",
       "L 219.866968 140.227193 \n",
       "L 221.660356 139.939962 \n",
       "L 223.453745 140.213877 \n",
       "L 225.247133 140.25614 \n",
       "L 227.040522 140.266206 \n",
       "L 228.83391 140.157749 \n",
       "L 230.627299 139.90186 \n",
       "L 232.420687 140.422727 \n",
       "L 234.214075 140.063174 \n",
       "L 236.007464 140.261479 \n",
       "L 237.800852 140.294398 \n",
       "\" style=\"fill:none;stroke:#ff7f0e;stroke-dasharray:1.5,2.475;stroke-dashoffset:0;stroke-width:1.5;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 51.378125 146.6 \n",
       "L 51.378125 10.7 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 246.678125 146.6 \n",
       "L 246.678125 10.7 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 51.378125 146.6 \n",
       "L 246.678125 146.6 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 51.378125 10.7 \n",
       "L 246.678125 10.7 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"legend_1\">\n",
       "    <g id=\"patch_7\">\n",
       "     <path d=\"M 184.403125 48.05625 \n",
       "L 239.678125 48.05625 \n",
       "Q 241.678125 48.05625 241.678125 46.05625 \n",
       "L 241.678125 17.7 \n",
       "Q 241.678125 15.7 239.678125 15.7 \n",
       "L 184.403125 15.7 \n",
       "Q 182.403125 15.7 182.403125 17.7 \n",
       "L 182.403125 46.05625 \n",
       "Q 182.403125 48.05625 184.403125 48.05625 \n",
       "z\n",
       "\" style=\"fill:#ffffff;opacity:0.8;stroke:#cccccc;stroke-linejoin:miter;\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_12\">\n",
       "     <path d=\"M 186.403125 23.798437 \n",
       "L 206.403125 23.798437 \n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-linecap:square;stroke-width:1.5;\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_13\"/>\n",
       "    <g id=\"text_12\">\n",
       "     <!-- train -->\n",
       "     <defs>\n",
       "      <path d=\"M 18.3125 70.21875 \n",
       "L 18.3125 54.6875 \n",
       "L 36.8125 54.6875 \n",
       "L 36.8125 47.703125 \n",
       "L 18.3125 47.703125 \n",
       "L 18.3125 18.015625 \n",
       "Q 18.3125 11.328125 20.140625 9.421875 \n",
       "Q 21.96875 7.515625 27.59375 7.515625 \n",
       "L 36.8125 7.515625 \n",
       "L 36.8125 0 \n",
       "L 27.59375 0 \n",
       "Q 17.1875 0 13.234375 3.875 \n",
       "Q 9.28125 7.765625 9.28125 18.015625 \n",
       "L 9.28125 47.703125 \n",
       "L 2.6875 47.703125 \n",
       "L 2.6875 54.6875 \n",
       "L 9.28125 54.6875 \n",
       "L 9.28125 70.21875 \n",
       "z\n",
       "\" id=\"DejaVuSans-74\"/>\n",
       "      <path d=\"M 41.109375 46.296875 \n",
       "Q 39.59375 47.171875 37.8125 47.578125 \n",
       "Q 36.03125 48 33.890625 48 \n",
       "Q 26.265625 48 22.1875 43.046875 \n",
       "Q 18.109375 38.09375 18.109375 28.8125 \n",
       "L 18.109375 0 \n",
       "L 9.078125 0 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.1875 \n",
       "Q 20.953125 51.171875 25.484375 53.578125 \n",
       "Q 30.03125 56 36.53125 56 \n",
       "Q 37.453125 56 38.578125 55.875 \n",
       "Q 39.703125 55.765625 41.0625 55.515625 \n",
       "z\n",
       "\" id=\"DejaVuSans-72\"/>\n",
       "      <path d=\"M 34.28125 27.484375 \n",
       "Q 23.390625 27.484375 19.1875 25 \n",
       "Q 14.984375 22.515625 14.984375 16.5 \n",
       "Q 14.984375 11.71875 18.140625 8.90625 \n",
       "Q 21.296875 6.109375 26.703125 6.109375 \n",
       "Q 34.1875 6.109375 38.703125 11.40625 \n",
       "Q 43.21875 16.703125 43.21875 25.484375 \n",
       "L 43.21875 27.484375 \n",
       "z\n",
       "M 52.203125 31.203125 \n",
       "L 52.203125 0 \n",
       "L 43.21875 0 \n",
       "L 43.21875 8.296875 \n",
       "Q 40.140625 3.328125 35.546875 0.953125 \n",
       "Q 30.953125 -1.421875 24.3125 -1.421875 \n",
       "Q 15.921875 -1.421875 10.953125 3.296875 \n",
       "Q 6 8.015625 6 15.921875 \n",
       "Q 6 25.140625 12.171875 29.828125 \n",
       "Q 18.359375 34.515625 30.609375 34.515625 \n",
       "L 43.21875 34.515625 \n",
       "L 43.21875 35.40625 \n",
       "Q 43.21875 41.609375 39.140625 45 \n",
       "Q 35.0625 48.390625 27.6875 48.390625 \n",
       "Q 23 48.390625 18.546875 47.265625 \n",
       "Q 14.109375 46.140625 10.015625 43.890625 \n",
       "L 10.015625 52.203125 \n",
       "Q 14.9375 54.109375 19.578125 55.046875 \n",
       "Q 24.21875 56 28.609375 56 \n",
       "Q 40.484375 56 46.34375 49.84375 \n",
       "Q 52.203125 43.703125 52.203125 31.203125 \n",
       "z\n",
       "\" id=\"DejaVuSans-61\"/>\n",
       "      <path d=\"M 9.421875 54.6875 \n",
       "L 18.40625 54.6875 \n",
       "L 18.40625 0 \n",
       "L 9.421875 0 \n",
       "z\n",
       "M 9.421875 75.984375 \n",
       "L 18.40625 75.984375 \n",
       "L 18.40625 64.59375 \n",
       "L 9.421875 64.59375 \n",
       "z\n",
       "\" id=\"DejaVuSans-69\"/>\n",
       "      <path d=\"M 54.890625 33.015625 \n",
       "L 54.890625 0 \n",
       "L 45.90625 0 \n",
       "L 45.90625 32.71875 \n",
       "Q 45.90625 40.484375 42.875 44.328125 \n",
       "Q 39.84375 48.1875 33.796875 48.1875 \n",
       "Q 26.515625 48.1875 22.3125 43.546875 \n",
       "Q 18.109375 38.921875 18.109375 30.90625 \n",
       "L 18.109375 0 \n",
       "L 9.078125 0 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.1875 \n",
       "Q 21.34375 51.125 25.703125 53.5625 \n",
       "Q 30.078125 56 35.796875 56 \n",
       "Q 45.21875 56 50.046875 50.171875 \n",
       "Q 54.890625 44.34375 54.890625 33.015625 \n",
       "z\n",
       "\" id=\"DejaVuSans-6e\"/>\n",
       "     </defs>\n",
       "     <g transform=\"translate(214.403125 27.298437)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-74\"/>\n",
       "      <use x=\"39.208984\" xlink:href=\"#DejaVuSans-72\"/>\n",
       "      <use x=\"80.322266\" xlink:href=\"#DejaVuSans-61\"/>\n",
       "      <use x=\"141.601562\" xlink:href=\"#DejaVuSans-69\"/>\n",
       "      <use x=\"169.384766\" xlink:href=\"#DejaVuSans-6e\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"line2d_14\">\n",
       "     <path d=\"M 186.403125 38.476562 \n",
       "L 206.403125 38.476562 \n",
       "\" style=\"fill:none;stroke:#ff7f0e;stroke-dasharray:1.5,2.475;stroke-dashoffset:0;stroke-width:1.5;\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_15\"/>\n",
       "    <g id=\"text_13\">\n",
       "     <!-- test -->\n",
       "     <g transform=\"translate(214.403125 41.976562)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-74\"/>\n",
       "      <use x=\"39.208984\" xlink:href=\"#DejaVuSans-65\"/>\n",
       "      <use x=\"100.732422\" xlink:href=\"#DejaVuSans-73\"/>\n",
       "      <use x=\"152.832031\" xlink:href=\"#DejaVuSans-74\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"pef43000d95\">\n",
       "   <rect height=\"135.9\" width=\"195.3\" x=\"51.378125\" y=\"10.7\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10ef4a860>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fit_and_plot(poly_features[:n_train, :], poly_features[n_train:, :], labels[:n_train], labels[n_train:])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.11.4.4 线性函数拟合(欠拟合)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "final epoch: train loss 249.35157775878906 test loss 168.37705993652344\n",
      "weight: tensor([[19.4123]]) \n",
      "bias: tensor([0.5805])\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Created with matplotlib (http://matplotlib.org/) -->\n",
       "<svg height=\"184pt\" version=\"1.1\" viewBox=\"0 0 268 184\" width=\"268pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       " <defs>\n",
       "  <style type=\"text/css\">\n",
       "*{stroke-linecap:butt;stroke-linejoin:round;}\n",
       "  </style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 184.15625 \n",
       "L 268.478125 184.15625 \n",
       "L 268.478125 -0 \n",
       "L 0 -0 \n",
       "z\n",
       "\" style=\"fill:none;\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 62.478125 146.6 \n",
       "L 257.778125 146.6 \n",
       "L 257.778125 10.7 \n",
       "L 62.478125 10.7 \n",
       "z\n",
       "\" style=\"fill:#ffffff;\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" id=\"mb51125e6a9\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"69.562009\" xlink:href=\"#mb51125e6a9\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 0 -->\n",
       "      <defs>\n",
       "       <path d=\"M 31.78125 66.40625 \n",
       "Q 24.171875 66.40625 20.328125 58.90625 \n",
       "Q 16.5 51.421875 16.5 36.375 \n",
       "Q 16.5 21.390625 20.328125 13.890625 \n",
       "Q 24.171875 6.390625 31.78125 6.390625 \n",
       "Q 39.453125 6.390625 43.28125 13.890625 \n",
       "Q 47.125 21.390625 47.125 36.375 \n",
       "Q 47.125 51.421875 43.28125 58.90625 \n",
       "Q 39.453125 66.40625 31.78125 66.40625 \n",
       "z\n",
       "M 31.78125 74.21875 \n",
       "Q 44.046875 74.21875 50.515625 64.515625 \n",
       "Q 56.984375 54.828125 56.984375 36.375 \n",
       "Q 56.984375 17.96875 50.515625 8.265625 \n",
       "Q 44.046875 -1.421875 31.78125 -1.421875 \n",
       "Q 19.53125 -1.421875 13.0625 8.265625 \n",
       "Q 6.59375 17.96875 6.59375 36.375 \n",
       "Q 6.59375 54.828125 13.0625 64.515625 \n",
       "Q 19.53125 74.21875 31.78125 74.21875 \n",
       "z\n",
       "\" id=\"DejaVuSans-30\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(66.380759 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_2\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"105.429778\" xlink:href=\"#mb51125e6a9\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 20 -->\n",
       "      <defs>\n",
       "       <path d=\"M 19.1875 8.296875 \n",
       "L 53.609375 8.296875 \n",
       "L 53.609375 0 \n",
       "L 7.328125 0 \n",
       "L 7.328125 8.296875 \n",
       "Q 12.9375 14.109375 22.625 23.890625 \n",
       "Q 32.328125 33.6875 34.8125 36.53125 \n",
       "Q 39.546875 41.84375 41.421875 45.53125 \n",
       "Q 43.3125 49.21875 43.3125 52.78125 \n",
       "Q 43.3125 58.59375 39.234375 62.25 \n",
       "Q 35.15625 65.921875 28.609375 65.921875 \n",
       "Q 23.96875 65.921875 18.8125 64.3125 \n",
       "Q 13.671875 62.703125 7.8125 59.421875 \n",
       "L 7.8125 69.390625 \n",
       "Q 13.765625 71.78125 18.9375 73 \n",
       "Q 24.125 74.21875 28.421875 74.21875 \n",
       "Q 39.75 74.21875 46.484375 68.546875 \n",
       "Q 53.21875 62.890625 53.21875 53.421875 \n",
       "Q 53.21875 48.921875 51.53125 44.890625 \n",
       "Q 49.859375 40.875 45.40625 35.40625 \n",
       "Q 44.1875 33.984375 37.640625 27.21875 \n",
       "Q 31.109375 20.453125 19.1875 8.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-32\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(99.067278 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"141.297546\" xlink:href=\"#mb51125e6a9\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 40 -->\n",
       "      <defs>\n",
       "       <path d=\"M 37.796875 64.3125 \n",
       "L 12.890625 25.390625 \n",
       "L 37.796875 25.390625 \n",
       "z\n",
       "M 35.203125 72.90625 \n",
       "L 47.609375 72.90625 \n",
       "L 47.609375 25.390625 \n",
       "L 58.015625 25.390625 \n",
       "L 58.015625 17.1875 \n",
       "L 47.609375 17.1875 \n",
       "L 47.609375 0 \n",
       "L 37.796875 0 \n",
       "L 37.796875 17.1875 \n",
       "L 4.890625 17.1875 \n",
       "L 4.890625 26.703125 \n",
       "z\n",
       "\" id=\"DejaVuSans-34\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(134.935046 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-34\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"177.165315\" xlink:href=\"#mb51125e6a9\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 60 -->\n",
       "      <defs>\n",
       "       <path d=\"M 33.015625 40.375 \n",
       "Q 26.375 40.375 22.484375 35.828125 \n",
       "Q 18.609375 31.296875 18.609375 23.390625 \n",
       "Q 18.609375 15.53125 22.484375 10.953125 \n",
       "Q 26.375 6.390625 33.015625 6.390625 \n",
       "Q 39.65625 6.390625 43.53125 10.953125 \n",
       "Q 47.40625 15.53125 47.40625 23.390625 \n",
       "Q 47.40625 31.296875 43.53125 35.828125 \n",
       "Q 39.65625 40.375 33.015625 40.375 \n",
       "z\n",
       "M 52.59375 71.296875 \n",
       "L 52.59375 62.3125 \n",
       "Q 48.875 64.0625 45.09375 64.984375 \n",
       "Q 41.3125 65.921875 37.59375 65.921875 \n",
       "Q 27.828125 65.921875 22.671875 59.328125 \n",
       "Q 17.53125 52.734375 16.796875 39.40625 \n",
       "Q 19.671875 43.65625 24.015625 45.921875 \n",
       "Q 28.375 48.1875 33.59375 48.1875 \n",
       "Q 44.578125 48.1875 50.953125 41.515625 \n",
       "Q 57.328125 34.859375 57.328125 23.390625 \n",
       "Q 57.328125 12.15625 50.6875 5.359375 \n",
       "Q 44.046875 -1.421875 33.015625 -1.421875 \n",
       "Q 20.359375 -1.421875 13.671875 8.265625 \n",
       "Q 6.984375 17.96875 6.984375 36.375 \n",
       "Q 6.984375 53.65625 15.1875 63.9375 \n",
       "Q 23.390625 74.21875 37.203125 74.21875 \n",
       "Q 40.921875 74.21875 44.703125 73.484375 \n",
       "Q 48.484375 72.75 52.59375 71.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-36\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(170.802815 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-36\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"213.033084\" xlink:href=\"#mb51125e6a9\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 80 -->\n",
       "      <defs>\n",
       "       <path d=\"M 31.78125 34.625 \n",
       "Q 24.75 34.625 20.71875 30.859375 \n",
       "Q 16.703125 27.09375 16.703125 20.515625 \n",
       "Q 16.703125 13.921875 20.71875 10.15625 \n",
       "Q 24.75 6.390625 31.78125 6.390625 \n",
       "Q 38.8125 6.390625 42.859375 10.171875 \n",
       "Q 46.921875 13.96875 46.921875 20.515625 \n",
       "Q 46.921875 27.09375 42.890625 30.859375 \n",
       "Q 38.875 34.625 31.78125 34.625 \n",
       "z\n",
       "M 21.921875 38.8125 \n",
       "Q 15.578125 40.375 12.03125 44.71875 \n",
       "Q 8.5 49.078125 8.5 55.328125 \n",
       "Q 8.5 64.0625 14.71875 69.140625 \n",
       "Q 20.953125 74.21875 31.78125 74.21875 \n",
       "Q 42.671875 74.21875 48.875 69.140625 \n",
       "Q 55.078125 64.0625 55.078125 55.328125 \n",
       "Q 55.078125 49.078125 51.53125 44.71875 \n",
       "Q 48 40.375 41.703125 38.8125 \n",
       "Q 48.828125 37.15625 52.796875 32.3125 \n",
       "Q 56.78125 27.484375 56.78125 20.515625 \n",
       "Q 56.78125 9.90625 50.3125 4.234375 \n",
       "Q 43.84375 -1.421875 31.78125 -1.421875 \n",
       "Q 19.734375 -1.421875 13.25 4.234375 \n",
       "Q 6.78125 9.90625 6.78125 20.515625 \n",
       "Q 6.78125 27.484375 10.78125 32.3125 \n",
       "Q 14.796875 37.15625 21.921875 38.8125 \n",
       "z\n",
       "M 18.3125 54.390625 \n",
       "Q 18.3125 48.734375 21.84375 45.5625 \n",
       "Q 25.390625 42.390625 31.78125 42.390625 \n",
       "Q 38.140625 42.390625 41.71875 45.5625 \n",
       "Q 45.3125 48.734375 45.3125 54.390625 \n",
       "Q 45.3125 60.0625 41.71875 63.234375 \n",
       "Q 38.140625 66.40625 31.78125 66.40625 \n",
       "Q 25.390625 66.40625 21.84375 63.234375 \n",
       "Q 18.3125 60.0625 18.3125 54.390625 \n",
       "z\n",
       "\" id=\"DejaVuSans-38\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(206.670584 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-38\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_6\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"248.900852\" xlink:href=\"#mb51125e6a9\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 100 -->\n",
       "      <defs>\n",
       "       <path d=\"M 12.40625 8.296875 \n",
       "L 28.515625 8.296875 \n",
       "L 28.515625 63.921875 \n",
       "L 10.984375 60.40625 \n",
       "L 10.984375 69.390625 \n",
       "L 28.421875 72.90625 \n",
       "L 38.28125 72.90625 \n",
       "L 38.28125 8.296875 \n",
       "L 54.390625 8.296875 \n",
       "L 54.390625 0 \n",
       "L 12.40625 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-31\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(239.357102 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_7\">\n",
       "     <!-- epochs -->\n",
       "     <defs>\n",
       "      <path d=\"M 56.203125 29.59375 \n",
       "L 56.203125 25.203125 \n",
       "L 14.890625 25.203125 \n",
       "Q 15.484375 15.921875 20.484375 11.0625 \n",
       "Q 25.484375 6.203125 34.421875 6.203125 \n",
       "Q 39.59375 6.203125 44.453125 7.46875 \n",
       "Q 49.3125 8.734375 54.109375 11.28125 \n",
       "L 54.109375 2.78125 \n",
       "Q 49.265625 0.734375 44.1875 -0.34375 \n",
       "Q 39.109375 -1.421875 33.890625 -1.421875 \n",
       "Q 20.796875 -1.421875 13.15625 6.1875 \n",
       "Q 5.515625 13.8125 5.515625 26.8125 \n",
       "Q 5.515625 40.234375 12.765625 48.109375 \n",
       "Q 20.015625 56 32.328125 56 \n",
       "Q 43.359375 56 49.78125 48.890625 \n",
       "Q 56.203125 41.796875 56.203125 29.59375 \n",
       "z\n",
       "M 47.21875 32.234375 \n",
       "Q 47.125 39.59375 43.09375 43.984375 \n",
       "Q 39.0625 48.390625 32.421875 48.390625 \n",
       "Q 24.90625 48.390625 20.390625 44.140625 \n",
       "Q 15.875 39.890625 15.1875 32.171875 \n",
       "z\n",
       "\" id=\"DejaVuSans-65\"/>\n",
       "      <path d=\"M 18.109375 8.203125 \n",
       "L 18.109375 -20.796875 \n",
       "L 9.078125 -20.796875 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.390625 \n",
       "Q 20.953125 51.265625 25.265625 53.625 \n",
       "Q 29.59375 56 35.59375 56 \n",
       "Q 45.5625 56 51.78125 48.09375 \n",
       "Q 58.015625 40.1875 58.015625 27.296875 \n",
       "Q 58.015625 14.40625 51.78125 6.484375 \n",
       "Q 45.5625 -1.421875 35.59375 -1.421875 \n",
       "Q 29.59375 -1.421875 25.265625 0.953125 \n",
       "Q 20.953125 3.328125 18.109375 8.203125 \n",
       "z\n",
       "M 48.6875 27.296875 \n",
       "Q 48.6875 37.203125 44.609375 42.84375 \n",
       "Q 40.53125 48.484375 33.40625 48.484375 \n",
       "Q 26.265625 48.484375 22.1875 42.84375 \n",
       "Q 18.109375 37.203125 18.109375 27.296875 \n",
       "Q 18.109375 17.390625 22.1875 11.75 \n",
       "Q 26.265625 6.109375 33.40625 6.109375 \n",
       "Q 40.53125 6.109375 44.609375 11.75 \n",
       "Q 48.6875 17.390625 48.6875 27.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-70\"/>\n",
       "      <path d=\"M 30.609375 48.390625 \n",
       "Q 23.390625 48.390625 19.1875 42.75 \n",
       "Q 14.984375 37.109375 14.984375 27.296875 \n",
       "Q 14.984375 17.484375 19.15625 11.84375 \n",
       "Q 23.34375 6.203125 30.609375 6.203125 \n",
       "Q 37.796875 6.203125 41.984375 11.859375 \n",
       "Q 46.1875 17.53125 46.1875 27.296875 \n",
       "Q 46.1875 37.015625 41.984375 42.703125 \n",
       "Q 37.796875 48.390625 30.609375 48.390625 \n",
       "z\n",
       "M 30.609375 56 \n",
       "Q 42.328125 56 49.015625 48.375 \n",
       "Q 55.71875 40.765625 55.71875 27.296875 \n",
       "Q 55.71875 13.875 49.015625 6.21875 \n",
       "Q 42.328125 -1.421875 30.609375 -1.421875 \n",
       "Q 18.84375 -1.421875 12.171875 6.21875 \n",
       "Q 5.515625 13.875 5.515625 27.296875 \n",
       "Q 5.515625 40.765625 12.171875 48.375 \n",
       "Q 18.84375 56 30.609375 56 \n",
       "z\n",
       "\" id=\"DejaVuSans-6f\"/>\n",
       "      <path d=\"M 48.78125 52.59375 \n",
       "L 48.78125 44.1875 \n",
       "Q 44.96875 46.296875 41.140625 47.34375 \n",
       "Q 37.3125 48.390625 33.40625 48.390625 \n",
       "Q 24.65625 48.390625 19.8125 42.84375 \n",
       "Q 14.984375 37.3125 14.984375 27.296875 \n",
       "Q 14.984375 17.28125 19.8125 11.734375 \n",
       "Q 24.65625 6.203125 33.40625 6.203125 \n",
       "Q 37.3125 6.203125 41.140625 7.25 \n",
       "Q 44.96875 8.296875 48.78125 10.40625 \n",
       "L 48.78125 2.09375 \n",
       "Q 45.015625 0.34375 40.984375 -0.53125 \n",
       "Q 36.96875 -1.421875 32.421875 -1.421875 \n",
       "Q 20.0625 -1.421875 12.78125 6.34375 \n",
       "Q 5.515625 14.109375 5.515625 27.296875 \n",
       "Q 5.515625 40.671875 12.859375 48.328125 \n",
       "Q 20.21875 56 33.015625 56 \n",
       "Q 37.15625 56 41.109375 55.140625 \n",
       "Q 45.0625 54.296875 48.78125 52.59375 \n",
       "z\n",
       "\" id=\"DejaVuSans-63\"/>\n",
       "      <path d=\"M 54.890625 33.015625 \n",
       "L 54.890625 0 \n",
       "L 45.90625 0 \n",
       "L 45.90625 32.71875 \n",
       "Q 45.90625 40.484375 42.875 44.328125 \n",
       "Q 39.84375 48.1875 33.796875 48.1875 \n",
       "Q 26.515625 48.1875 22.3125 43.546875 \n",
       "Q 18.109375 38.921875 18.109375 30.90625 \n",
       "L 18.109375 0 \n",
       "L 9.078125 0 \n",
       "L 9.078125 75.984375 \n",
       "L 18.109375 75.984375 \n",
       "L 18.109375 46.1875 \n",
       "Q 21.34375 51.125 25.703125 53.5625 \n",
       "Q 30.078125 56 35.796875 56 \n",
       "Q 45.21875 56 50.046875 50.171875 \n",
       "Q 54.890625 44.34375 54.890625 33.015625 \n",
       "z\n",
       "\" id=\"DejaVuSans-68\"/>\n",
       "      <path d=\"M 44.28125 53.078125 \n",
       "L 44.28125 44.578125 \n",
       "Q 40.484375 46.53125 36.375 47.5 \n",
       "Q 32.28125 48.484375 27.875 48.484375 \n",
       "Q 21.1875 48.484375 17.84375 46.4375 \n",
       "Q 14.5 44.390625 14.5 40.28125 \n",
       "Q 14.5 37.15625 16.890625 35.375 \n",
       "Q 19.28125 33.59375 26.515625 31.984375 \n",
       "L 29.59375 31.296875 \n",
       "Q 39.15625 29.25 43.1875 25.515625 \n",
       "Q 47.21875 21.78125 47.21875 15.09375 \n",
       "Q 47.21875 7.46875 41.1875 3.015625 \n",
       "Q 35.15625 -1.421875 24.609375 -1.421875 \n",
       "Q 20.21875 -1.421875 15.453125 -0.5625 \n",
       "Q 10.6875 0.296875 5.421875 2 \n",
       "L 5.421875 11.28125 \n",
       "Q 10.40625 8.6875 15.234375 7.390625 \n",
       "Q 20.0625 6.109375 24.8125 6.109375 \n",
       "Q 31.15625 6.109375 34.5625 8.28125 \n",
       "Q 37.984375 10.453125 37.984375 14.40625 \n",
       "Q 37.984375 18.0625 35.515625 20.015625 \n",
       "Q 33.0625 21.96875 24.703125 23.78125 \n",
       "L 21.578125 24.515625 \n",
       "Q 13.234375 26.265625 9.515625 29.90625 \n",
       "Q 5.8125 33.546875 5.8125 39.890625 \n",
       "Q 5.8125 47.609375 11.28125 51.796875 \n",
       "Q 16.75 56 26.8125 56 \n",
       "Q 31.78125 56 36.171875 55.265625 \n",
       "Q 40.578125 54.546875 44.28125 53.078125 \n",
       "z\n",
       "\" id=\"DejaVuSans-73\"/>\n",
       "     </defs>\n",
       "     <g transform=\"translate(142.295313 174.876562)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-65\"/>\n",
       "      <use x=\"61.523438\" xlink:href=\"#DejaVuSans-70\"/>\n",
       "      <use x=\"125\" xlink:href=\"#DejaVuSans-6f\"/>\n",
       "      <use x=\"186.181641\" xlink:href=\"#DejaVuSans-63\"/>\n",
       "      <use x=\"241.162109\" xlink:href=\"#DejaVuSans-68\"/>\n",
       "      <use x=\"304.541016\" xlink:href=\"#DejaVuSans-73\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L -2 0 \n",
       "\" id=\"m1a7a58466b\" style=\"stroke:#000000;stroke-width:0.6;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"62.478125\" xlink:href=\"#m1a7a58466b\" y=\"119.740842\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- $\\mathdefault{2\\times10^{2}}$ -->\n",
       "      <defs>\n",
       "       <path d=\"M 70.125 53.71875 \n",
       "L 47.796875 31.296875 \n",
       "L 70.125 8.984375 \n",
       "L 64.3125 3.078125 \n",
       "L 41.890625 25.484375 \n",
       "L 19.484375 3.078125 \n",
       "L 13.71875 8.984375 \n",
       "L 35.984375 31.296875 \n",
       "L 13.71875 53.71875 \n",
       "L 19.484375 59.625 \n",
       "L 41.890625 37.203125 \n",
       "L 64.3125 59.625 \n",
       "z\n",
       "\" id=\"DejaVuSans-d7\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(20.878125 123.540061)scale(0.1 -0.1)\">\n",
       "       <use transform=\"translate(0 0.765625)\" xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use transform=\"translate(83.105469 0.765625)\" xlink:href=\"#DejaVuSans-d7\"/>\n",
       "       <use transform=\"translate(186.376953 0.765625)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use transform=\"translate(250 0.765625)\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use transform=\"translate(314.580078 39.046875)scale(0.7)\" xlink:href=\"#DejaVuSans-32\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_8\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"62.478125\" xlink:href=\"#m1a7a58466b\" y=\"73.640319\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- $\\mathdefault{3\\times10^{2}}$ -->\n",
       "      <defs>\n",
       "       <path d=\"M 40.578125 39.3125 \n",
       "Q 47.65625 37.796875 51.625 33 \n",
       "Q 55.609375 28.21875 55.609375 21.1875 \n",
       "Q 55.609375 10.40625 48.1875 4.484375 \n",
       "Q 40.765625 -1.421875 27.09375 -1.421875 \n",
       "Q 22.515625 -1.421875 17.65625 -0.515625 \n",
       "Q 12.796875 0.390625 7.625 2.203125 \n",
       "L 7.625 11.71875 \n",
       "Q 11.71875 9.328125 16.59375 8.109375 \n",
       "Q 21.484375 6.890625 26.8125 6.890625 \n",
       "Q 36.078125 6.890625 40.9375 10.546875 \n",
       "Q 45.796875 14.203125 45.796875 21.1875 \n",
       "Q 45.796875 27.640625 41.28125 31.265625 \n",
       "Q 36.765625 34.90625 28.71875 34.90625 \n",
       "L 20.21875 34.90625 \n",
       "L 20.21875 43.015625 \n",
       "L 29.109375 43.015625 \n",
       "Q 36.375 43.015625 40.234375 45.921875 \n",
       "Q 44.09375 48.828125 44.09375 54.296875 \n",
       "Q 44.09375 59.90625 40.109375 62.90625 \n",
       "Q 36.140625 65.921875 28.71875 65.921875 \n",
       "Q 24.65625 65.921875 20.015625 65.03125 \n",
       "Q 15.375 64.15625 9.8125 62.3125 \n",
       "L 9.8125 71.09375 \n",
       "Q 15.4375 72.65625 20.34375 73.4375 \n",
       "Q 25.25 74.21875 29.59375 74.21875 \n",
       "Q 40.828125 74.21875 47.359375 69.109375 \n",
       "Q 53.90625 64.015625 53.90625 55.328125 \n",
       "Q 53.90625 49.265625 50.4375 45.09375 \n",
       "Q 46.96875 40.921875 40.578125 39.3125 \n",
       "z\n",
       "\" id=\"DejaVuSans-33\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(20.878125 77.439537)scale(0.1 -0.1)\">\n",
       "       <use transform=\"translate(0 0.765625)\" xlink:href=\"#DejaVuSans-33\"/>\n",
       "       <use transform=\"translate(83.105469 0.765625)\" xlink:href=\"#DejaVuSans-d7\"/>\n",
       "       <use transform=\"translate(186.376953 0.765625)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use transform=\"translate(250 0.765625)\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use transform=\"translate(314.580078 39.046875)scale(0.7)\" xlink:href=\"#DejaVuSans-32\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"62.478125\" xlink:href=\"#m1a7a58466b\" y=\"40.931477\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- $\\mathdefault{4\\times10^{2}}$ -->\n",
       "      <g transform=\"translate(20.878125 44.730695)scale(0.1 -0.1)\">\n",
       "       <use transform=\"translate(0 0.765625)\" xlink:href=\"#DejaVuSans-34\"/>\n",
       "       <use transform=\"translate(83.105469 0.765625)\" xlink:href=\"#DejaVuSans-d7\"/>\n",
       "       <use transform=\"translate(186.376953 0.765625)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use transform=\"translate(250 0.765625)\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use transform=\"translate(314.580078 39.046875)scale(0.7)\" xlink:href=\"#DejaVuSans-32\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_10\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"62.478125\" xlink:href=\"#m1a7a58466b\" y=\"15.560528\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_11\">\n",
       "     <!-- loss -->\n",
       "     <defs>\n",
       "      <path d=\"M 9.421875 75.984375 \n",
       "L 18.40625 75.984375 \n",
       "L 18.40625 0 \n",
       "L 9.421875 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-6c\"/>\n",
       "     </defs>\n",
       "     <g transform=\"translate(14.798437 88.307812)rotate(-90)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-6c\"/>\n",
       "      <use x=\"27.783203\" xlink:href=\"#DejaVuSans-6f\"/>\n",
       "      <use x=\"88.964844\" xlink:href=\"#DejaVuSans-73\"/>\n",
       "      <use x=\"141.064453\" xlink:href=\"#DejaVuSans-73\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_11\">\n",
       "    <path clip-path=\"url(#pc01b1bcd3a)\" d=\"M 71.355398 16.877273 \n",
       "L 73.148786 39.425717 \n",
       "L 74.942175 56.18553 \n",
       "L 76.735563 68.721268 \n",
       "L 78.528951 76.999241 \n",
       "L 80.32234 82.884102 \n",
       "L 82.115728 86.544993 \n",
       "L 83.909117 89.200563 \n",
       "L 85.702505 91.092034 \n",
       "L 87.495894 92.339324 \n",
       "L 89.289282 93.196465 \n",
       "L 91.08267 93.680418 \n",
       "L 92.876059 94.02729 \n",
       "L 94.669447 94.283875 \n",
       "L 96.462836 94.406429 \n",
       "L 98.256224 94.489733 \n",
       "L 100.049613 94.528566 \n",
       "L 101.843001 94.569824 \n",
       "L 103.636389 94.616605 \n",
       "L 105.429778 94.635878 \n",
       "L 107.223166 94.644692 \n",
       "L 109.016555 94.656664 \n",
       "L 110.809943 94.659586 \n",
       "L 112.603332 94.663288 \n",
       "L 114.39672 94.66479 \n",
       "L 116.190108 94.666022 \n",
       "L 117.983497 94.668756 \n",
       "L 119.776885 94.668861 \n",
       "L 121.570274 94.670941 \n",
       "L 123.363662 94.67083 \n",
       "L 125.157051 94.671484 \n",
       "L 126.950439 94.671136 \n",
       "L 128.743827 94.671929 \n",
       "L 130.537216 94.671957 \n",
       "L 132.330604 94.671609 \n",
       "L 134.123993 94.671943 \n",
       "L 135.917381 94.669786 \n",
       "L 137.71077 94.666175 \n",
       "L 139.504158 94.671505 \n",
       "L 141.297546 94.670148 \n",
       "L 143.090935 94.668033 \n",
       "L 144.884323 94.665695 \n",
       "L 146.677712 94.671484 \n",
       "L 148.4711 94.670851 \n",
       "L 150.264489 94.670739 \n",
       "L 152.057877 94.671936 \n",
       "L 153.851265 94.671428 \n",
       "L 155.644654 94.666579 \n",
       "L 157.438042 94.671957 \n",
       "L 159.231431 94.671922 \n",
       "L 161.024819 94.671192 \n",
       "L 162.818208 94.67186 \n",
       "L 164.611596 94.670183 \n",
       "L 166.404985 94.665194 \n",
       "L 168.198373 94.671783 \n",
       "L 169.991761 94.671206 \n",
       "L 171.78515 94.670899 \n",
       "L 173.578538 94.671748 \n",
       "L 175.371927 94.6714 \n",
       "L 177.165315 94.671936 \n",
       "L 178.958704 94.671825 \n",
       "L 180.752092 94.671894 \n",
       "L 182.54548 94.671776 \n",
       "L 184.338869 94.67051 \n",
       "L 186.132257 94.66941 \n",
       "L 187.925646 94.66637 \n",
       "L 189.719034 94.669654 \n",
       "L 191.512423 94.66758 \n",
       "L 193.305811 94.668005 \n",
       "L 195.099199 94.66511 \n",
       "L 196.892588 94.667546 \n",
       "L 198.685976 94.659433 \n",
       "L 200.479365 94.66486 \n",
       "L 202.272753 94.659134 \n",
       "L 204.066142 94.651433 \n",
       "L 205.85953 94.664136 \n",
       "L 207.652918 94.656567 \n",
       "L 209.446307 94.661319 \n",
       "L 211.239695 94.670976 \n",
       "L 213.033084 94.671073 \n",
       "L 214.826472 94.670308 \n",
       "L 216.619861 94.670391 \n",
       "L 218.413249 94.671324 \n",
       "L 220.206637 94.670656 \n",
       "L 222.000026 94.668179 \n",
       "L 223.793414 94.670329 \n",
       "L 225.586803 94.671073 \n",
       "L 227.380191 94.671004 \n",
       "L 229.17358 94.671567 \n",
       "L 230.966968 94.667177 \n",
       "L 232.760356 94.671679 \n",
       "L 234.553745 94.67124 \n",
       "L 236.347133 94.670642 \n",
       "L 238.140522 94.671672 \n",
       "L 239.93391 94.671867 \n",
       "L 241.727299 94.67156 \n",
       "L 243.520687 94.670621 \n",
       "L 245.314075 94.670906 \n",
       "L 247.107464 94.671505 \n",
       "L 248.900852 94.665173 \n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-linecap:square;stroke-width:1.5;\"/>\n",
       "   </g>\n",
       "   <g id=\"line2d_12\">\n",
       "    <path clip-path=\"url(#pc01b1bcd3a)\" d=\"M 71.355398 51.325572 \n",
       "L 73.148786 77.807887 \n",
       "L 74.942175 97.912136 \n",
       "L 76.735563 113.069915 \n",
       "L 78.528951 123.060442 \n",
       "L 80.32234 129.951252 \n",
       "L 82.115728 134.112912 \n",
       "L 83.909117 136.930235 \n",
       "L 85.702505 138.686782 \n",
       "L 87.495894 139.633735 \n",
       "L 89.289282 140.147786 \n",
       "L 91.08267 140.399454 \n",
       "L 92.876059 140.422727 \n",
       "L 94.669447 140.311085 \n",
       "L 96.462836 140.26492 \n",
       "L 98.256224 140.173987 \n",
       "L 100.049613 140.189292 \n",
       "L 101.843001 140.110767 \n",
       "L 103.636389 139.865307 \n",
       "L 105.429778 139.792654 \n",
       "L 107.223166 139.818754 \n",
       "L 109.016555 139.663167 \n",
       "L 110.809943 139.669514 \n",
       "L 112.603332 139.537854 \n",
       "L 114.39672 139.487947 \n",
       "L 116.190108 139.447222 \n",
       "L 117.983497 139.638509 \n",
       "L 119.776885 139.442239 \n",
       "L 121.570274 139.499836 \n",
       "L 123.363662 139.474769 \n",
       "L 125.157051 139.589962 \n",
       "L 126.950439 139.470446 \n",
       "L 128.743827 139.527716 \n",
       "L 130.537216 139.535262 \n",
       "L 132.330604 139.473448 \n",
       "L 134.123993 139.535386 \n",
       "L 135.917381 139.649463 \n",
       "L 137.71077 139.732262 \n",
       "L 139.504158 139.584013 \n",
       "L 141.297546 139.42292 \n",
       "L 143.090935 139.351189 \n",
       "L 144.884323 139.309369 \n",
       "L 146.677712 139.465369 \n",
       "L 148.4711 139.437174 \n",
       "L 150.264489 139.428799 \n",
       "L 152.057877 139.510766 \n",
       "L 153.851265 139.577114 \n",
       "L 155.644654 139.714372 \n",
       "L 157.438042 139.520944 \n",
       "L 159.231431 139.54665 \n",
       "L 161.024819 139.606562 \n",
       "L 162.818208 139.512335 \n",
       "L 164.611596 139.424116 \n",
       "L 166.404985 139.303115 \n",
       "L 168.198373 139.499929 \n",
       "L 169.991761 139.462779 \n",
       "L 171.78515 139.449491 \n",
       "L 173.578538 139.542851 \n",
       "L 175.371927 139.466257 \n",
       "L 177.165315 139.512861 \n",
       "L 178.958704 139.505533 \n",
       "L 180.752092 139.538628 \n",
       "L 182.54548 139.52049 \n",
       "L 184.338869 139.454072 \n",
       "L 186.132257 139.404336 \n",
       "L 187.925646 139.328937 \n",
       "L 189.719034 139.404985 \n",
       "L 191.512423 139.365754 \n",
       "L 193.305811 139.377599 \n",
       "L 195.099199 139.327072 \n",
       "L 196.892588 139.35627 \n",
       "L 198.685976 139.219753 \n",
       "L 200.479365 139.284499 \n",
       "L 202.272753 139.20326 \n",
       "L 204.066142 139.110786 \n",
       "L 205.85953 139.270737 \n",
       "L 207.652918 139.16273 \n",
       "L 209.446307 139.222852 \n",
       "L 211.239695 139.439062 \n",
       "L 213.033084 139.538112 \n",
       "L 214.826472 139.579685 \n",
       "L 216.619861 139.416474 \n",
       "L 218.413249 139.54823 \n",
       "L 220.206637 139.589601 \n",
       "L 222.000026 139.652935 \n",
       "L 223.793414 139.60056 \n",
       "L 225.586803 139.582825 \n",
       "L 227.380191 139.564442 \n",
       "L 229.17358 139.478989 \n",
       "L 230.966968 139.325402 \n",
       "L 232.760356 139.505409 \n",
       "L 234.553745 139.449502 \n",
       "L 236.347133 139.421857 \n",
       "L 238.140522 139.483829 \n",
       "L 239.93391 139.542634 \n",
       "L 241.727299 139.468413 \n",
       "L 243.520687 139.429273 \n",
       "L 245.314075 139.613205 \n",
       "L 247.107464 139.479671 \n",
       "L 248.900852 139.309554 \n",
       "\" style=\"fill:none;stroke:#ff7f0e;stroke-dasharray:1.5,2.475;stroke-dashoffset:0;stroke-width:1.5;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 62.478125 146.6 \n",
       "L 62.478125 10.7 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 257.778125 146.6 \n",
       "L 257.778125 10.7 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 62.478125 146.6 \n",
       "L 257.778125 146.6 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 62.478125 10.7 \n",
       "L 257.778125 10.7 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"legend_1\">\n",
       "    <g id=\"patch_7\">\n",
       "     <path d=\"M 195.503125 48.05625 \n",
       "L 250.778125 48.05625 \n",
       "Q 252.778125 48.05625 252.778125 46.05625 \n",
       "L 252.778125 17.7 \n",
       "Q 252.778125 15.7 250.778125 15.7 \n",
       "L 195.503125 15.7 \n",
       "Q 193.503125 15.7 193.503125 17.7 \n",
       "L 193.503125 46.05625 \n",
       "Q 193.503125 48.05625 195.503125 48.05625 \n",
       "z\n",
       "\" style=\"fill:#ffffff;opacity:0.8;stroke:#cccccc;stroke-linejoin:miter;\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_13\">\n",
       "     <path d=\"M 197.503125 23.798437 \n",
       "L 217.503125 23.798437 \n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-linecap:square;stroke-width:1.5;\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_14\"/>\n",
       "    <g id=\"text_12\">\n",
       "     <!-- train -->\n",
       "     <defs>\n",
       "      <path d=\"M 18.3125 70.21875 \n",
       "L 18.3125 54.6875 \n",
       "L 36.8125 54.6875 \n",
       "L 36.8125 47.703125 \n",
       "L 18.3125 47.703125 \n",
       "L 18.3125 18.015625 \n",
       "Q 18.3125 11.328125 20.140625 9.421875 \n",
       "Q 21.96875 7.515625 27.59375 7.515625 \n",
       "L 36.8125 7.515625 \n",
       "L 36.8125 0 \n",
       "L 27.59375 0 \n",
       "Q 17.1875 0 13.234375 3.875 \n",
       "Q 9.28125 7.765625 9.28125 18.015625 \n",
       "L 9.28125 47.703125 \n",
       "L 2.6875 47.703125 \n",
       "L 2.6875 54.6875 \n",
       "L 9.28125 54.6875 \n",
       "L 9.28125 70.21875 \n",
       "z\n",
       "\" id=\"DejaVuSans-74\"/>\n",
       "      <path d=\"M 41.109375 46.296875 \n",
       "Q 39.59375 47.171875 37.8125 47.578125 \n",
       "Q 36.03125 48 33.890625 48 \n",
       "Q 26.265625 48 22.1875 43.046875 \n",
       "Q 18.109375 38.09375 18.109375 28.8125 \n",
       "L 18.109375 0 \n",
       "L 9.078125 0 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.1875 \n",
       "Q 20.953125 51.171875 25.484375 53.578125 \n",
       "Q 30.03125 56 36.53125 56 \n",
       "Q 37.453125 56 38.578125 55.875 \n",
       "Q 39.703125 55.765625 41.0625 55.515625 \n",
       "z\n",
       "\" id=\"DejaVuSans-72\"/>\n",
       "      <path d=\"M 34.28125 27.484375 \n",
       "Q 23.390625 27.484375 19.1875 25 \n",
       "Q 14.984375 22.515625 14.984375 16.5 \n",
       "Q 14.984375 11.71875 18.140625 8.90625 \n",
       "Q 21.296875 6.109375 26.703125 6.109375 \n",
       "Q 34.1875 6.109375 38.703125 11.40625 \n",
       "Q 43.21875 16.703125 43.21875 25.484375 \n",
       "L 43.21875 27.484375 \n",
       "z\n",
       "M 52.203125 31.203125 \n",
       "L 52.203125 0 \n",
       "L 43.21875 0 \n",
       "L 43.21875 8.296875 \n",
       "Q 40.140625 3.328125 35.546875 0.953125 \n",
       "Q 30.953125 -1.421875 24.3125 -1.421875 \n",
       "Q 15.921875 -1.421875 10.953125 3.296875 \n",
       "Q 6 8.015625 6 15.921875 \n",
       "Q 6 25.140625 12.171875 29.828125 \n",
       "Q 18.359375 34.515625 30.609375 34.515625 \n",
       "L 43.21875 34.515625 \n",
       "L 43.21875 35.40625 \n",
       "Q 43.21875 41.609375 39.140625 45 \n",
       "Q 35.0625 48.390625 27.6875 48.390625 \n",
       "Q 23 48.390625 18.546875 47.265625 \n",
       "Q 14.109375 46.140625 10.015625 43.890625 \n",
       "L 10.015625 52.203125 \n",
       "Q 14.9375 54.109375 19.578125 55.046875 \n",
       "Q 24.21875 56 28.609375 56 \n",
       "Q 40.484375 56 46.34375 49.84375 \n",
       "Q 52.203125 43.703125 52.203125 31.203125 \n",
       "z\n",
       "\" id=\"DejaVuSans-61\"/>\n",
       "      <path d=\"M 9.421875 54.6875 \n",
       "L 18.40625 54.6875 \n",
       "L 18.40625 0 \n",
       "L 9.421875 0 \n",
       "z\n",
       "M 9.421875 75.984375 \n",
       "L 18.40625 75.984375 \n",
       "L 18.40625 64.59375 \n",
       "L 9.421875 64.59375 \n",
       "z\n",
       "\" id=\"DejaVuSans-69\"/>\n",
       "      <path d=\"M 54.890625 33.015625 \n",
       "L 54.890625 0 \n",
       "L 45.90625 0 \n",
       "L 45.90625 32.71875 \n",
       "Q 45.90625 40.484375 42.875 44.328125 \n",
       "Q 39.84375 48.1875 33.796875 48.1875 \n",
       "Q 26.515625 48.1875 22.3125 43.546875 \n",
       "Q 18.109375 38.921875 18.109375 30.90625 \n",
       "L 18.109375 0 \n",
       "L 9.078125 0 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.1875 \n",
       "Q 21.34375 51.125 25.703125 53.5625 \n",
       "Q 30.078125 56 35.796875 56 \n",
       "Q 45.21875 56 50.046875 50.171875 \n",
       "Q 54.890625 44.34375 54.890625 33.015625 \n",
       "z\n",
       "\" id=\"DejaVuSans-6e\"/>\n",
       "     </defs>\n",
       "     <g transform=\"translate(225.503125 27.298437)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-74\"/>\n",
       "      <use x=\"39.208984\" xlink:href=\"#DejaVuSans-72\"/>\n",
       "      <use x=\"80.322266\" xlink:href=\"#DejaVuSans-61\"/>\n",
       "      <use x=\"141.601562\" xlink:href=\"#DejaVuSans-69\"/>\n",
       "      <use x=\"169.384766\" xlink:href=\"#DejaVuSans-6e\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"line2d_15\">\n",
       "     <path d=\"M 197.503125 38.476562 \n",
       "L 217.503125 38.476562 \n",
       "\" style=\"fill:none;stroke:#ff7f0e;stroke-dasharray:1.5,2.475;stroke-dashoffset:0;stroke-width:1.5;\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_16\"/>\n",
       "    <g id=\"text_13\">\n",
       "     <!-- test -->\n",
       "     <g transform=\"translate(225.503125 41.976562)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-74\"/>\n",
       "      <use x=\"39.208984\" xlink:href=\"#DejaVuSans-65\"/>\n",
       "      <use x=\"100.732422\" xlink:href=\"#DejaVuSans-73\"/>\n",
       "      <use x=\"152.832031\" xlink:href=\"#DejaVuSans-74\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"pc01b1bcd3a\">\n",
       "   <rect height=\"135.9\" width=\"195.3\" x=\"62.478125\" y=\"10.7\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10f07a5c0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fit_and_plot(features[:n_train, :], features[n_train:, :], labels[:n_train], labels[n_train:])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.11.4.5 训练样本不足(过拟合)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "final epoch: train loss 1.198514699935913 test loss 166.037109375\n",
      "weight: tensor([[1.4741, 2.1198, 2.5674]]) \n",
      "bias: tensor([3.1207])\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Created with matplotlib (http://matplotlib.org/) -->\n",
       "<svg height=\"184pt\" version=\"1.1\" viewBox=\"0 0 251 184\" width=\"251pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       " <defs>\n",
       "  <style type=\"text/css\">\n",
       "*{stroke-linecap:butt;stroke-linejoin:round;}\n",
       "  </style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 184.15625 \n",
       "L 251.478125 184.15625 \n",
       "L 251.478125 -0 \n",
       "L 0 -0 \n",
       "z\n",
       "\" style=\"fill:none;\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 45.478125 146.6 \n",
       "L 240.778125 146.6 \n",
       "L 240.778125 10.7 \n",
       "L 45.478125 10.7 \n",
       "z\n",
       "\" style=\"fill:#ffffff;\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" id=\"m37b25e9422\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"52.562009\" xlink:href=\"#m37b25e9422\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 0 -->\n",
       "      <defs>\n",
       "       <path d=\"M 31.78125 66.40625 \n",
       "Q 24.171875 66.40625 20.328125 58.90625 \n",
       "Q 16.5 51.421875 16.5 36.375 \n",
       "Q 16.5 21.390625 20.328125 13.890625 \n",
       "Q 24.171875 6.390625 31.78125 6.390625 \n",
       "Q 39.453125 6.390625 43.28125 13.890625 \n",
       "Q 47.125 21.390625 47.125 36.375 \n",
       "Q 47.125 51.421875 43.28125 58.90625 \n",
       "Q 39.453125 66.40625 31.78125 66.40625 \n",
       "z\n",
       "M 31.78125 74.21875 \n",
       "Q 44.046875 74.21875 50.515625 64.515625 \n",
       "Q 56.984375 54.828125 56.984375 36.375 \n",
       "Q 56.984375 17.96875 50.515625 8.265625 \n",
       "Q 44.046875 -1.421875 31.78125 -1.421875 \n",
       "Q 19.53125 -1.421875 13.0625 8.265625 \n",
       "Q 6.59375 17.96875 6.59375 36.375 \n",
       "Q 6.59375 54.828125 13.0625 64.515625 \n",
       "Q 19.53125 74.21875 31.78125 74.21875 \n",
       "z\n",
       "\" id=\"DejaVuSans-30\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(49.380759 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_2\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"88.429778\" xlink:href=\"#m37b25e9422\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 20 -->\n",
       "      <defs>\n",
       "       <path d=\"M 19.1875 8.296875 \n",
       "L 53.609375 8.296875 \n",
       "L 53.609375 0 \n",
       "L 7.328125 0 \n",
       "L 7.328125 8.296875 \n",
       "Q 12.9375 14.109375 22.625 23.890625 \n",
       "Q 32.328125 33.6875 34.8125 36.53125 \n",
       "Q 39.546875 41.84375 41.421875 45.53125 \n",
       "Q 43.3125 49.21875 43.3125 52.78125 \n",
       "Q 43.3125 58.59375 39.234375 62.25 \n",
       "Q 35.15625 65.921875 28.609375 65.921875 \n",
       "Q 23.96875 65.921875 18.8125 64.3125 \n",
       "Q 13.671875 62.703125 7.8125 59.421875 \n",
       "L 7.8125 69.390625 \n",
       "Q 13.765625 71.78125 18.9375 73 \n",
       "Q 24.125 74.21875 28.421875 74.21875 \n",
       "Q 39.75 74.21875 46.484375 68.546875 \n",
       "Q 53.21875 62.890625 53.21875 53.421875 \n",
       "Q 53.21875 48.921875 51.53125 44.890625 \n",
       "Q 49.859375 40.875 45.40625 35.40625 \n",
       "Q 44.1875 33.984375 37.640625 27.21875 \n",
       "Q 31.109375 20.453125 19.1875 8.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-32\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(82.067278 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"124.297546\" xlink:href=\"#m37b25e9422\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 40 -->\n",
       "      <defs>\n",
       "       <path d=\"M 37.796875 64.3125 \n",
       "L 12.890625 25.390625 \n",
       "L 37.796875 25.390625 \n",
       "z\n",
       "M 35.203125 72.90625 \n",
       "L 47.609375 72.90625 \n",
       "L 47.609375 25.390625 \n",
       "L 58.015625 25.390625 \n",
       "L 58.015625 17.1875 \n",
       "L 47.609375 17.1875 \n",
       "L 47.609375 0 \n",
       "L 37.796875 0 \n",
       "L 37.796875 17.1875 \n",
       "L 4.890625 17.1875 \n",
       "L 4.890625 26.703125 \n",
       "z\n",
       "\" id=\"DejaVuSans-34\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(117.935046 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-34\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"160.165315\" xlink:href=\"#m37b25e9422\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 60 -->\n",
       "      <defs>\n",
       "       <path d=\"M 33.015625 40.375 \n",
       "Q 26.375 40.375 22.484375 35.828125 \n",
       "Q 18.609375 31.296875 18.609375 23.390625 \n",
       "Q 18.609375 15.53125 22.484375 10.953125 \n",
       "Q 26.375 6.390625 33.015625 6.390625 \n",
       "Q 39.65625 6.390625 43.53125 10.953125 \n",
       "Q 47.40625 15.53125 47.40625 23.390625 \n",
       "Q 47.40625 31.296875 43.53125 35.828125 \n",
       "Q 39.65625 40.375 33.015625 40.375 \n",
       "z\n",
       "M 52.59375 71.296875 \n",
       "L 52.59375 62.3125 \n",
       "Q 48.875 64.0625 45.09375 64.984375 \n",
       "Q 41.3125 65.921875 37.59375 65.921875 \n",
       "Q 27.828125 65.921875 22.671875 59.328125 \n",
       "Q 17.53125 52.734375 16.796875 39.40625 \n",
       "Q 19.671875 43.65625 24.015625 45.921875 \n",
       "Q 28.375 48.1875 33.59375 48.1875 \n",
       "Q 44.578125 48.1875 50.953125 41.515625 \n",
       "Q 57.328125 34.859375 57.328125 23.390625 \n",
       "Q 57.328125 12.15625 50.6875 5.359375 \n",
       "Q 44.046875 -1.421875 33.015625 -1.421875 \n",
       "Q 20.359375 -1.421875 13.671875 8.265625 \n",
       "Q 6.984375 17.96875 6.984375 36.375 \n",
       "Q 6.984375 53.65625 15.1875 63.9375 \n",
       "Q 23.390625 74.21875 37.203125 74.21875 \n",
       "Q 40.921875 74.21875 44.703125 73.484375 \n",
       "Q 48.484375 72.75 52.59375 71.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-36\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(153.802815 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-36\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"196.033084\" xlink:href=\"#m37b25e9422\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 80 -->\n",
       "      <defs>\n",
       "       <path d=\"M 31.78125 34.625 \n",
       "Q 24.75 34.625 20.71875 30.859375 \n",
       "Q 16.703125 27.09375 16.703125 20.515625 \n",
       "Q 16.703125 13.921875 20.71875 10.15625 \n",
       "Q 24.75 6.390625 31.78125 6.390625 \n",
       "Q 38.8125 6.390625 42.859375 10.171875 \n",
       "Q 46.921875 13.96875 46.921875 20.515625 \n",
       "Q 46.921875 27.09375 42.890625 30.859375 \n",
       "Q 38.875 34.625 31.78125 34.625 \n",
       "z\n",
       "M 21.921875 38.8125 \n",
       "Q 15.578125 40.375 12.03125 44.71875 \n",
       "Q 8.5 49.078125 8.5 55.328125 \n",
       "Q 8.5 64.0625 14.71875 69.140625 \n",
       "Q 20.953125 74.21875 31.78125 74.21875 \n",
       "Q 42.671875 74.21875 48.875 69.140625 \n",
       "Q 55.078125 64.0625 55.078125 55.328125 \n",
       "Q 55.078125 49.078125 51.53125 44.71875 \n",
       "Q 48 40.375 41.703125 38.8125 \n",
       "Q 48.828125 37.15625 52.796875 32.3125 \n",
       "Q 56.78125 27.484375 56.78125 20.515625 \n",
       "Q 56.78125 9.90625 50.3125 4.234375 \n",
       "Q 43.84375 -1.421875 31.78125 -1.421875 \n",
       "Q 19.734375 -1.421875 13.25 4.234375 \n",
       "Q 6.78125 9.90625 6.78125 20.515625 \n",
       "Q 6.78125 27.484375 10.78125 32.3125 \n",
       "Q 14.796875 37.15625 21.921875 38.8125 \n",
       "z\n",
       "M 18.3125 54.390625 \n",
       "Q 18.3125 48.734375 21.84375 45.5625 \n",
       "Q 25.390625 42.390625 31.78125 42.390625 \n",
       "Q 38.140625 42.390625 41.71875 45.5625 \n",
       "Q 45.3125 48.734375 45.3125 54.390625 \n",
       "Q 45.3125 60.0625 41.71875 63.234375 \n",
       "Q 38.140625 66.40625 31.78125 66.40625 \n",
       "Q 25.390625 66.40625 21.84375 63.234375 \n",
       "Q 18.3125 60.0625 18.3125 54.390625 \n",
       "z\n",
       "\" id=\"DejaVuSans-38\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(189.670584 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-38\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_6\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"231.900852\" xlink:href=\"#m37b25e9422\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 100 -->\n",
       "      <defs>\n",
       "       <path d=\"M 12.40625 8.296875 \n",
       "L 28.515625 8.296875 \n",
       "L 28.515625 63.921875 \n",
       "L 10.984375 60.40625 \n",
       "L 10.984375 69.390625 \n",
       "L 28.421875 72.90625 \n",
       "L 38.28125 72.90625 \n",
       "L 38.28125 8.296875 \n",
       "L 54.390625 8.296875 \n",
       "L 54.390625 0 \n",
       "L 12.40625 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-31\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(222.357102 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_7\">\n",
       "     <!-- epochs -->\n",
       "     <defs>\n",
       "      <path d=\"M 56.203125 29.59375 \n",
       "L 56.203125 25.203125 \n",
       "L 14.890625 25.203125 \n",
       "Q 15.484375 15.921875 20.484375 11.0625 \n",
       "Q 25.484375 6.203125 34.421875 6.203125 \n",
       "Q 39.59375 6.203125 44.453125 7.46875 \n",
       "Q 49.3125 8.734375 54.109375 11.28125 \n",
       "L 54.109375 2.78125 \n",
       "Q 49.265625 0.734375 44.1875 -0.34375 \n",
       "Q 39.109375 -1.421875 33.890625 -1.421875 \n",
       "Q 20.796875 -1.421875 13.15625 6.1875 \n",
       "Q 5.515625 13.8125 5.515625 26.8125 \n",
       "Q 5.515625 40.234375 12.765625 48.109375 \n",
       "Q 20.015625 56 32.328125 56 \n",
       "Q 43.359375 56 49.78125 48.890625 \n",
       "Q 56.203125 41.796875 56.203125 29.59375 \n",
       "z\n",
       "M 47.21875 32.234375 \n",
       "Q 47.125 39.59375 43.09375 43.984375 \n",
       "Q 39.0625 48.390625 32.421875 48.390625 \n",
       "Q 24.90625 48.390625 20.390625 44.140625 \n",
       "Q 15.875 39.890625 15.1875 32.171875 \n",
       "z\n",
       "\" id=\"DejaVuSans-65\"/>\n",
       "      <path d=\"M 18.109375 8.203125 \n",
       "L 18.109375 -20.796875 \n",
       "L 9.078125 -20.796875 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.390625 \n",
       "Q 20.953125 51.265625 25.265625 53.625 \n",
       "Q 29.59375 56 35.59375 56 \n",
       "Q 45.5625 56 51.78125 48.09375 \n",
       "Q 58.015625 40.1875 58.015625 27.296875 \n",
       "Q 58.015625 14.40625 51.78125 6.484375 \n",
       "Q 45.5625 -1.421875 35.59375 -1.421875 \n",
       "Q 29.59375 -1.421875 25.265625 0.953125 \n",
       "Q 20.953125 3.328125 18.109375 8.203125 \n",
       "z\n",
       "M 48.6875 27.296875 \n",
       "Q 48.6875 37.203125 44.609375 42.84375 \n",
       "Q 40.53125 48.484375 33.40625 48.484375 \n",
       "Q 26.265625 48.484375 22.1875 42.84375 \n",
       "Q 18.109375 37.203125 18.109375 27.296875 \n",
       "Q 18.109375 17.390625 22.1875 11.75 \n",
       "Q 26.265625 6.109375 33.40625 6.109375 \n",
       "Q 40.53125 6.109375 44.609375 11.75 \n",
       "Q 48.6875 17.390625 48.6875 27.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-70\"/>\n",
       "      <path d=\"M 30.609375 48.390625 \n",
       "Q 23.390625 48.390625 19.1875 42.75 \n",
       "Q 14.984375 37.109375 14.984375 27.296875 \n",
       "Q 14.984375 17.484375 19.15625 11.84375 \n",
       "Q 23.34375 6.203125 30.609375 6.203125 \n",
       "Q 37.796875 6.203125 41.984375 11.859375 \n",
       "Q 46.1875 17.53125 46.1875 27.296875 \n",
       "Q 46.1875 37.015625 41.984375 42.703125 \n",
       "Q 37.796875 48.390625 30.609375 48.390625 \n",
       "z\n",
       "M 30.609375 56 \n",
       "Q 42.328125 56 49.015625 48.375 \n",
       "Q 55.71875 40.765625 55.71875 27.296875 \n",
       "Q 55.71875 13.875 49.015625 6.21875 \n",
       "Q 42.328125 -1.421875 30.609375 -1.421875 \n",
       "Q 18.84375 -1.421875 12.171875 6.21875 \n",
       "Q 5.515625 13.875 5.515625 27.296875 \n",
       "Q 5.515625 40.765625 12.171875 48.375 \n",
       "Q 18.84375 56 30.609375 56 \n",
       "z\n",
       "\" id=\"DejaVuSans-6f\"/>\n",
       "      <path d=\"M 48.78125 52.59375 \n",
       "L 48.78125 44.1875 \n",
       "Q 44.96875 46.296875 41.140625 47.34375 \n",
       "Q 37.3125 48.390625 33.40625 48.390625 \n",
       "Q 24.65625 48.390625 19.8125 42.84375 \n",
       "Q 14.984375 37.3125 14.984375 27.296875 \n",
       "Q 14.984375 17.28125 19.8125 11.734375 \n",
       "Q 24.65625 6.203125 33.40625 6.203125 \n",
       "Q 37.3125 6.203125 41.140625 7.25 \n",
       "Q 44.96875 8.296875 48.78125 10.40625 \n",
       "L 48.78125 2.09375 \n",
       "Q 45.015625 0.34375 40.984375 -0.53125 \n",
       "Q 36.96875 -1.421875 32.421875 -1.421875 \n",
       "Q 20.0625 -1.421875 12.78125 6.34375 \n",
       "Q 5.515625 14.109375 5.515625 27.296875 \n",
       "Q 5.515625 40.671875 12.859375 48.328125 \n",
       "Q 20.21875 56 33.015625 56 \n",
       "Q 37.15625 56 41.109375 55.140625 \n",
       "Q 45.0625 54.296875 48.78125 52.59375 \n",
       "z\n",
       "\" id=\"DejaVuSans-63\"/>\n",
       "      <path d=\"M 54.890625 33.015625 \n",
       "L 54.890625 0 \n",
       "L 45.90625 0 \n",
       "L 45.90625 32.71875 \n",
       "Q 45.90625 40.484375 42.875 44.328125 \n",
       "Q 39.84375 48.1875 33.796875 48.1875 \n",
       "Q 26.515625 48.1875 22.3125 43.546875 \n",
       "Q 18.109375 38.921875 18.109375 30.90625 \n",
       "L 18.109375 0 \n",
       "L 9.078125 0 \n",
       "L 9.078125 75.984375 \n",
       "L 18.109375 75.984375 \n",
       "L 18.109375 46.1875 \n",
       "Q 21.34375 51.125 25.703125 53.5625 \n",
       "Q 30.078125 56 35.796875 56 \n",
       "Q 45.21875 56 50.046875 50.171875 \n",
       "Q 54.890625 44.34375 54.890625 33.015625 \n",
       "z\n",
       "\" id=\"DejaVuSans-68\"/>\n",
       "      <path d=\"M 44.28125 53.078125 \n",
       "L 44.28125 44.578125 \n",
       "Q 40.484375 46.53125 36.375 47.5 \n",
       "Q 32.28125 48.484375 27.875 48.484375 \n",
       "Q 21.1875 48.484375 17.84375 46.4375 \n",
       "Q 14.5 44.390625 14.5 40.28125 \n",
       "Q 14.5 37.15625 16.890625 35.375 \n",
       "Q 19.28125 33.59375 26.515625 31.984375 \n",
       "L 29.59375 31.296875 \n",
       "Q 39.15625 29.25 43.1875 25.515625 \n",
       "Q 47.21875 21.78125 47.21875 15.09375 \n",
       "Q 47.21875 7.46875 41.1875 3.015625 \n",
       "Q 35.15625 -1.421875 24.609375 -1.421875 \n",
       "Q 20.21875 -1.421875 15.453125 -0.5625 \n",
       "Q 10.6875 0.296875 5.421875 2 \n",
       "L 5.421875 11.28125 \n",
       "Q 10.40625 8.6875 15.234375 7.390625 \n",
       "Q 20.0625 6.109375 24.8125 6.109375 \n",
       "Q 31.15625 6.109375 34.5625 8.28125 \n",
       "Q 37.984375 10.453125 37.984375 14.40625 \n",
       "Q 37.984375 18.0625 35.515625 20.015625 \n",
       "Q 33.0625 21.96875 24.703125 23.78125 \n",
       "L 21.578125 24.515625 \n",
       "Q 13.234375 26.265625 9.515625 29.90625 \n",
       "Q 5.8125 33.546875 5.8125 39.890625 \n",
       "Q 5.8125 47.609375 11.28125 51.796875 \n",
       "Q 16.75 56 26.8125 56 \n",
       "Q 31.78125 56 36.171875 55.265625 \n",
       "Q 40.578125 54.546875 44.28125 53.078125 \n",
       "z\n",
       "\" id=\"DejaVuSans-73\"/>\n",
       "     </defs>\n",
       "     <g transform=\"translate(125.295312 174.876562)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-65\"/>\n",
       "      <use x=\"61.523438\" xlink:href=\"#DejaVuSans-70\"/>\n",
       "      <use x=\"125\" xlink:href=\"#DejaVuSans-6f\"/>\n",
       "      <use x=\"186.181641\" xlink:href=\"#DejaVuSans-63\"/>\n",
       "      <use x=\"241.162109\" xlink:href=\"#DejaVuSans-68\"/>\n",
       "      <use x=\"304.541016\" xlink:href=\"#DejaVuSans-73\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L -3.5 0 \n",
       "\" id=\"m03e15b528e\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"45.478125\" xlink:href=\"#m03e15b528e\" y=\"144.290642\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- $\\mathdefault{10^{0}}$ -->\n",
       "      <g transform=\"translate(20.878125 148.089861)scale(0.1 -0.1)\">\n",
       "       <use transform=\"translate(0 0.765625)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use transform=\"translate(63.623047 0.765625)\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use transform=\"translate(128.203125 39.046875)scale(0.7)\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_8\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"45.478125\" xlink:href=\"#m03e15b528e\" y=\"95.107661\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- $\\mathdefault{10^{1}}$ -->\n",
       "      <g transform=\"translate(20.878125 98.90688)scale(0.1 -0.1)\">\n",
       "       <use transform=\"translate(0 0.684375)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use transform=\"translate(63.623047 0.684375)\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use transform=\"translate(128.203125 38.965625)scale(0.7)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"45.478125\" xlink:href=\"#m03e15b528e\" y=\"45.92468\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- $\\mathdefault{10^{2}}$ -->\n",
       "      <g transform=\"translate(20.878125 49.723899)scale(0.1 -0.1)\">\n",
       "       <use transform=\"translate(0 0.765625)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use transform=\"translate(63.623047 0.765625)\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use transform=\"translate(128.203125 39.046875)scale(0.7)\" xlink:href=\"#DejaVuSans-32\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_10\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L -2 0 \n",
       "\" id=\"me8918339d9\" style=\"stroke:#000000;stroke-width:0.6;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"146.541132\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"129.48509\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"line2d_12\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"120.824397\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_7\">\n",
       "     <g id=\"line2d_13\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"114.679537\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_8\">\n",
       "     <g id=\"line2d_14\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"109.913214\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_9\">\n",
       "     <g id=\"line2d_15\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"106.018844\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_10\">\n",
       "     <g id=\"line2d_16\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"102.726201\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_11\">\n",
       "     <g id=\"line2d_17\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"99.873985\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_12\">\n",
       "     <g id=\"line2d_18\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"97.358151\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_13\">\n",
       "     <g id=\"line2d_19\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"80.302109\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_14\">\n",
       "     <g id=\"line2d_20\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"71.641415\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_15\">\n",
       "     <g id=\"line2d_21\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"65.496556\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_16\">\n",
       "     <g id=\"line2d_22\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"60.730233\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_17\">\n",
       "     <g id=\"line2d_23\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"56.835863\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_18\">\n",
       "     <g id=\"line2d_24\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"53.54322\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_19\">\n",
       "     <g id=\"line2d_25\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"50.691003\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_20\">\n",
       "     <g id=\"line2d_26\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"48.17517\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_21\">\n",
       "     <g id=\"line2d_27\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"31.119127\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_22\">\n",
       "     <g id=\"line2d_28\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"22.458434\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_23\">\n",
       "     <g id=\"line2d_29\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"16.313575\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_24\">\n",
       "     <g id=\"line2d_30\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"45.478125\" xlink:href=\"#me8918339d9\" y=\"11.547251\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_11\">\n",
       "     <!-- loss -->\n",
       "     <defs>\n",
       "      <path d=\"M 9.421875 75.984375 \n",
       "L 18.40625 75.984375 \n",
       "L 18.40625 0 \n",
       "L 9.421875 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-6c\"/>\n",
       "     </defs>\n",
       "     <g transform=\"translate(14.798437 88.307812)rotate(-90)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-6c\"/>\n",
       "      <use x=\"27.783203\" xlink:href=\"#DejaVuSans-6f\"/>\n",
       "      <use x=\"88.964844\" xlink:href=\"#DejaVuSans-73\"/>\n",
       "      <use x=\"141.064453\" xlink:href=\"#DejaVuSans-73\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_31\">\n",
       "    <path clip-path=\"url(#p6a15dfe41d)\" d=\"M 54.355398 36.844026 \n",
       "L 56.148786 50.776667 \n",
       "L 57.942175 63.777981 \n",
       "L 59.735563 75.273889 \n",
       "L 61.528951 84.65815 \n",
       "L 63.32234 91.596112 \n",
       "L 65.115728 96.253212 \n",
       "L 66.909117 99.177028 \n",
       "L 68.702505 100.979327 \n",
       "L 70.495894 102.130515 \n",
       "L 72.289282 102.927509 \n",
       "L 74.08267 103.538675 \n",
       "L 75.876059 104.054207 \n",
       "L 77.669447 104.521007 \n",
       "L 79.462836 104.9631 \n",
       "L 81.256224 105.392702 \n",
       "L 83.049613 105.815994 \n",
       "L 84.843001 106.236104 \n",
       "L 86.636389 106.654612 \n",
       "L 88.429778 107.072302 \n",
       "L 90.223166 107.489588 \n",
       "L 92.016555 107.90667 \n",
       "L 93.809943 108.323646 \n",
       "L 95.603332 108.74057 \n",
       "L 97.39672 109.157465 \n",
       "L 99.190108 109.574351 \n",
       "L 100.983497 109.991228 \n",
       "L 102.776885 110.408102 \n",
       "L 104.570274 110.824975 \n",
       "L 106.363662 111.241842 \n",
       "L 108.157051 111.658716 \n",
       "L 109.950439 112.075587 \n",
       "L 111.743827 112.492457 \n",
       "L 113.537216 112.909329 \n",
       "L 115.330604 113.326202 \n",
       "L 117.123993 113.743065 \n",
       "L 118.917381 114.159935 \n",
       "L 120.71077 114.57681 \n",
       "L 122.504158 114.993679 \n",
       "L 124.297546 115.410551 \n",
       "L 126.090935 115.827419 \n",
       "L 127.884323 116.244291 \n",
       "L 129.677712 116.66116 \n",
       "L 131.4711 117.078031 \n",
       "L 133.264489 117.494898 \n",
       "L 135.057877 117.911772 \n",
       "L 136.851265 118.328641 \n",
       "L 138.644654 118.745507 \n",
       "L 140.438042 119.162383 \n",
       "L 142.231431 119.579251 \n",
       "L 144.024819 119.996115 \n",
       "L 145.818208 120.412988 \n",
       "L 147.611596 120.829857 \n",
       "L 149.404985 121.246728 \n",
       "L 151.198373 121.663598 \n",
       "L 152.991761 122.080465 \n",
       "L 154.78515 122.497334 \n",
       "L 156.578538 122.914208 \n",
       "L 158.371927 123.331074 \n",
       "L 160.165315 123.747949 \n",
       "L 161.958704 124.164818 \n",
       "L 163.752092 124.581687 \n",
       "L 165.54548 124.998559 \n",
       "L 167.338869 125.415425 \n",
       "L 169.132257 125.832296 \n",
       "L 170.925646 126.249169 \n",
       "L 172.719034 126.666033 \n",
       "L 174.512423 127.082903 \n",
       "L 176.305811 127.499771 \n",
       "L 178.099199 127.916639 \n",
       "L 179.892588 128.33351 \n",
       "L 181.685976 128.750383 \n",
       "L 183.479365 129.167251 \n",
       "L 185.272753 129.584122 \n",
       "L 187.066142 130.000987 \n",
       "L 188.85953 130.417861 \n",
       "L 190.652918 130.834729 \n",
       "L 192.446307 131.251602 \n",
       "L 194.239695 131.668466 \n",
       "L 196.033084 132.085337 \n",
       "L 197.826472 132.502213 \n",
       "L 199.619861 132.919081 \n",
       "L 201.413249 133.335955 \n",
       "L 203.206637 133.752826 \n",
       "L 205.000026 134.169693 \n",
       "L 206.793414 134.586561 \n",
       "L 208.586803 135.003429 \n",
       "L 210.380191 135.420297 \n",
       "L 212.17358 135.837166 \n",
       "L 213.966968 136.25404 \n",
       "L 215.760356 136.670911 \n",
       "L 217.553745 137.08778 \n",
       "L 219.347133 137.504652 \n",
       "L 221.140522 137.921523 \n",
       "L 222.93391 138.33839 \n",
       "L 224.727299 138.755263 \n",
       "L 226.520687 139.17213 \n",
       "L 228.314075 139.588995 \n",
       "L 230.107464 140.005866 \n",
       "L 231.900852 140.422727 \n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-linecap:square;stroke-width:1.5;\"/>\n",
       "   </g>\n",
       "   <g id=\"line2d_32\">\n",
       "    <path clip-path=\"url(#p6a15dfe41d)\" d=\"M 54.355398 16.877273 \n",
       "L 56.148786 23.606472 \n",
       "L 57.942175 28.659 \n",
       "L 59.735563 32.28844 \n",
       "L 61.528951 34.814678 \n",
       "L 63.32234 36.538142 \n",
       "L 65.115728 37.699149 \n",
       "L 66.909117 38.473342 \n",
       "L 68.702505 38.983145 \n",
       "L 70.495894 39.312142 \n",
       "L 72.289282 39.51706 \n",
       "L 74.08267 39.636482 \n",
       "L 75.876059 39.696767 \n",
       "L 77.669447 39.716055 \n",
       "L 79.462836 39.706879 \n",
       "L 81.256224 39.677943 \n",
       "L 83.049613 39.635311 \n",
       "L 84.843001 39.583222 \n",
       "L 86.636389 39.524648 \n",
       "L 88.429778 39.461665 \n",
       "L 90.223166 39.395736 \n",
       "L 92.016555 39.327884 \n",
       "L 93.809943 39.258835 \n",
       "L 95.603332 39.189093 \n",
       "L 97.39672 39.119016 \n",
       "L 99.190108 39.048859 \n",
       "L 100.983497 38.978793 \n",
       "L 102.776885 38.908947 \n",
       "L 104.570274 38.839403 \n",
       "L 106.363662 38.770229 \n",
       "L 108.157051 38.701464 \n",
       "L 109.950439 38.633143 \n",
       "L 111.743827 38.565282 \n",
       "L 113.537216 38.497898 \n",
       "L 115.330604 38.431004 \n",
       "L 117.123993 38.364607 \n",
       "L 118.917381 38.298705 \n",
       "L 120.71077 38.233306 \n",
       "L 122.504158 38.168417 \n",
       "L 124.297546 38.10403 \n",
       "L 126.090935 38.040154 \n",
       "L 127.884323 37.976781 \n",
       "L 129.677712 37.913911 \n",
       "L 131.4711 37.851548 \n",
       "L 133.264489 37.789686 \n",
       "L 135.057877 37.728325 \n",
       "L 136.851265 37.667468 \n",
       "L 138.644654 37.607108 \n",
       "L 140.438042 37.547244 \n",
       "L 142.231431 37.487879 \n",
       "L 144.024819 37.429002 \n",
       "L 145.818208 37.37062 \n",
       "L 147.611596 37.312723 \n",
       "L 149.404985 37.255312 \n",
       "L 151.198373 37.198392 \n",
       "L 152.991761 37.141946 \n",
       "L 154.78515 37.085984 \n",
       "L 156.578538 37.030503 \n",
       "L 158.371927 36.975494 \n",
       "L 160.165315 36.920957 \n",
       "L 161.958704 36.86689 \n",
       "L 163.752092 36.813287 \n",
       "L 165.54548 36.760154 \n",
       "L 167.338869 36.707478 \n",
       "L 169.132257 36.655261 \n",
       "L 170.925646 36.603501 \n",
       "L 172.719034 36.552201 \n",
       "L 174.512423 36.501346 \n",
       "L 176.305811 36.450935 \n",
       "L 178.099199 36.400977 \n",
       "L 179.892588 36.351457 \n",
       "L 181.685976 36.302377 \n",
       "L 183.479365 36.253732 \n",
       "L 185.272753 36.205521 \n",
       "L 187.066142 36.157744 \n",
       "L 188.85953 36.110391 \n",
       "L 190.652918 36.063464 \n",
       "L 192.446307 36.016956 \n",
       "L 194.239695 35.970867 \n",
       "L 196.033084 35.925196 \n",
       "L 197.826472 35.879929 \n",
       "L 199.619861 35.835079 \n",
       "L 201.413249 35.790631 \n",
       "L 203.206637 35.746592 \n",
       "L 205.000026 35.702952 \n",
       "L 206.793414 35.659709 \n",
       "L 208.586803 35.616858 \n",
       "L 210.380191 35.574397 \n",
       "L 212.17358 35.532328 \n",
       "L 213.966968 35.490643 \n",
       "L 215.760356 35.449342 \n",
       "L 217.553745 35.40842 \n",
       "L 219.347133 35.367873 \n",
       "L 221.140522 35.327701 \n",
       "L 222.93391 35.287899 \n",
       "L 224.727299 35.248463 \n",
       "L 226.520687 35.209392 \n",
       "L 228.314075 35.17068 \n",
       "L 230.107464 35.132329 \n",
       "L 231.900852 35.094333 \n",
       "\" style=\"fill:none;stroke:#ff7f0e;stroke-dasharray:1.5,2.475;stroke-dashoffset:0;stroke-width:1.5;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 45.478125 146.6 \n",
       "L 45.478125 10.7 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 240.778125 146.6 \n",
       "L 240.778125 10.7 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 45.478125 146.6 \n",
       "L 240.778125 146.6 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 45.478125 10.7 \n",
       "L 240.778125 10.7 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"legend_1\">\n",
       "    <g id=\"patch_7\">\n",
       "     <path d=\"M 178.503125 94.828125 \n",
       "L 233.778125 94.828125 \n",
       "Q 235.778125 94.828125 235.778125 92.828125 \n",
       "L 235.778125 64.471875 \n",
       "Q 235.778125 62.471875 233.778125 62.471875 \n",
       "L 178.503125 62.471875 \n",
       "Q 176.503125 62.471875 176.503125 64.471875 \n",
       "L 176.503125 92.828125 \n",
       "Q 176.503125 94.828125 178.503125 94.828125 \n",
       "z\n",
       "\" style=\"fill:#ffffff;opacity:0.8;stroke:#cccccc;stroke-linejoin:miter;\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_33\">\n",
       "     <path d=\"M 180.503125 70.570312 \n",
       "L 200.503125 70.570312 \n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-linecap:square;stroke-width:1.5;\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_34\"/>\n",
       "    <g id=\"text_12\">\n",
       "     <!-- train -->\n",
       "     <defs>\n",
       "      <path d=\"M 18.3125 70.21875 \n",
       "L 18.3125 54.6875 \n",
       "L 36.8125 54.6875 \n",
       "L 36.8125 47.703125 \n",
       "L 18.3125 47.703125 \n",
       "L 18.3125 18.015625 \n",
       "Q 18.3125 11.328125 20.140625 9.421875 \n",
       "Q 21.96875 7.515625 27.59375 7.515625 \n",
       "L 36.8125 7.515625 \n",
       "L 36.8125 0 \n",
       "L 27.59375 0 \n",
       "Q 17.1875 0 13.234375 3.875 \n",
       "Q 9.28125 7.765625 9.28125 18.015625 \n",
       "L 9.28125 47.703125 \n",
       "L 2.6875 47.703125 \n",
       "L 2.6875 54.6875 \n",
       "L 9.28125 54.6875 \n",
       "L 9.28125 70.21875 \n",
       "z\n",
       "\" id=\"DejaVuSans-74\"/>\n",
       "      <path d=\"M 41.109375 46.296875 \n",
       "Q 39.59375 47.171875 37.8125 47.578125 \n",
       "Q 36.03125 48 33.890625 48 \n",
       "Q 26.265625 48 22.1875 43.046875 \n",
       "Q 18.109375 38.09375 18.109375 28.8125 \n",
       "L 18.109375 0 \n",
       "L 9.078125 0 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.1875 \n",
       "Q 20.953125 51.171875 25.484375 53.578125 \n",
       "Q 30.03125 56 36.53125 56 \n",
       "Q 37.453125 56 38.578125 55.875 \n",
       "Q 39.703125 55.765625 41.0625 55.515625 \n",
       "z\n",
       "\" id=\"DejaVuSans-72\"/>\n",
       "      <path d=\"M 34.28125 27.484375 \n",
       "Q 23.390625 27.484375 19.1875 25 \n",
       "Q 14.984375 22.515625 14.984375 16.5 \n",
       "Q 14.984375 11.71875 18.140625 8.90625 \n",
       "Q 21.296875 6.109375 26.703125 6.109375 \n",
       "Q 34.1875 6.109375 38.703125 11.40625 \n",
       "Q 43.21875 16.703125 43.21875 25.484375 \n",
       "L 43.21875 27.484375 \n",
       "z\n",
       "M 52.203125 31.203125 \n",
       "L 52.203125 0 \n",
       "L 43.21875 0 \n",
       "L 43.21875 8.296875 \n",
       "Q 40.140625 3.328125 35.546875 0.953125 \n",
       "Q 30.953125 -1.421875 24.3125 -1.421875 \n",
       "Q 15.921875 -1.421875 10.953125 3.296875 \n",
       "Q 6 8.015625 6 15.921875 \n",
       "Q 6 25.140625 12.171875 29.828125 \n",
       "Q 18.359375 34.515625 30.609375 34.515625 \n",
       "L 43.21875 34.515625 \n",
       "L 43.21875 35.40625 \n",
       "Q 43.21875 41.609375 39.140625 45 \n",
       "Q 35.0625 48.390625 27.6875 48.390625 \n",
       "Q 23 48.390625 18.546875 47.265625 \n",
       "Q 14.109375 46.140625 10.015625 43.890625 \n",
       "L 10.015625 52.203125 \n",
       "Q 14.9375 54.109375 19.578125 55.046875 \n",
       "Q 24.21875 56 28.609375 56 \n",
       "Q 40.484375 56 46.34375 49.84375 \n",
       "Q 52.203125 43.703125 52.203125 31.203125 \n",
       "z\n",
       "\" id=\"DejaVuSans-61\"/>\n",
       "      <path d=\"M 9.421875 54.6875 \n",
       "L 18.40625 54.6875 \n",
       "L 18.40625 0 \n",
       "L 9.421875 0 \n",
       "z\n",
       "M 9.421875 75.984375 \n",
       "L 18.40625 75.984375 \n",
       "L 18.40625 64.59375 \n",
       "L 9.421875 64.59375 \n",
       "z\n",
       "\" id=\"DejaVuSans-69\"/>\n",
       "      <path d=\"M 54.890625 33.015625 \n",
       "L 54.890625 0 \n",
       "L 45.90625 0 \n",
       "L 45.90625 32.71875 \n",
       "Q 45.90625 40.484375 42.875 44.328125 \n",
       "Q 39.84375 48.1875 33.796875 48.1875 \n",
       "Q 26.515625 48.1875 22.3125 43.546875 \n",
       "Q 18.109375 38.921875 18.109375 30.90625 \n",
       "L 18.109375 0 \n",
       "L 9.078125 0 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.1875 \n",
       "Q 21.34375 51.125 25.703125 53.5625 \n",
       "Q 30.078125 56 35.796875 56 \n",
       "Q 45.21875 56 50.046875 50.171875 \n",
       "Q 54.890625 44.34375 54.890625 33.015625 \n",
       "z\n",
       "\" id=\"DejaVuSans-6e\"/>\n",
       "     </defs>\n",
       "     <g transform=\"translate(208.503125 74.070312)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-74\"/>\n",
       "      <use x=\"39.208984\" xlink:href=\"#DejaVuSans-72\"/>\n",
       "      <use x=\"80.322266\" xlink:href=\"#DejaVuSans-61\"/>\n",
       "      <use x=\"141.601562\" xlink:href=\"#DejaVuSans-69\"/>\n",
       "      <use x=\"169.384766\" xlink:href=\"#DejaVuSans-6e\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"line2d_35\">\n",
       "     <path d=\"M 180.503125 85.248437 \n",
       "L 200.503125 85.248437 \n",
       "\" style=\"fill:none;stroke:#ff7f0e;stroke-dasharray:1.5,2.475;stroke-dashoffset:0;stroke-width:1.5;\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_36\"/>\n",
       "    <g id=\"text_13\">\n",
       "     <!-- test -->\n",
       "     <g transform=\"translate(208.503125 88.748437)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-74\"/>\n",
       "      <use x=\"39.208984\" xlink:href=\"#DejaVuSans-65\"/>\n",
       "      <use x=\"100.732422\" xlink:href=\"#DejaVuSans-73\"/>\n",
       "      <use x=\"152.832031\" xlink:href=\"#DejaVuSans-74\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p6a15dfe41d\">\n",
       "   <rect height=\"135.9\" width=\"195.3\" x=\"45.478125\" y=\"10.7\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10f138710>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fit_and_plot(poly_features[0:2, :], poly_features[n_train:, :], labels[0:2], labels[n_train:])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}


================================================
FILE: code/chapter03_DL-basics/3.12_weight-decay.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3.12 权重衰减"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.4.1\n"
     ]
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "import torch\n",
    "import torch.nn as nn\n",
    "import numpy as np\n",
    "import sys\n",
    "sys.path.append(\"..\") \n",
    "import d2lzh_pytorch as d2l\n",
    "\n",
    "print(torch.__version__)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3.12.2 高维线性回归实验"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "n_train, n_test, num_inputs = 20, 100, 200\n",
    "true_w, true_b = torch.ones(num_inputs, 1) * 0.01, 0.05\n",
    "\n",
    "features = torch.randn((n_train + n_test, num_inputs))\n",
    "labels = torch.matmul(features, true_w) + true_b\n",
    "labels += torch.tensor(np.random.normal(0, 0.01, size=labels.size()), dtype=torch.float)\n",
    "train_features, test_features = features[:n_train, :], features[n_train:, :]\n",
    "train_labels, test_labels = labels[:n_train], labels[n_train:]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3.12.3 从零开始实现\n",
    "### 3.12.3.1 初始化模型参数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def init_params():\n",
    "    w = torch.randn((num_inputs, 1), requires_grad=True)\n",
    "    b = torch.zeros(1, requires_grad=True)\n",
    "    return [w, b]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.12.3.2 定义$L_2$范数惩罚项"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def l2_penalty(w):\n",
    "    return (w**2).sum() / 2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.12.3.3 定义训练和测试"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "batch_size, num_epochs, lr = 1, 100, 0.003\n",
    "net, loss = d2l.linreg, d2l.squared_loss\n",
    "\n",
    "dataset = torch.utils.data.TensorDataset(train_features, train_labels)\n",
    "train_iter = torch.utils.data.DataLoader(dataset, batch_size, shuffle=True)\n",
    "\n",
    "def fit_and_plot(lambd):\n",
    "    w, b = init_params()\n",
    "    train_ls, test_ls = [], []\n",
    "    for _ in range(num_epochs):\n",
    "        for X, y in train_iter:\n",
    "            # 添加了L2范数惩罚项\n",
    "            l = loss(net(X, w, b), y) + lambd * l2_penalty(w)\n",
    "            l = l.sum()\n",
    "            \n",
    "            if w.grad is not None:\n",
    "                w.grad.data.zero_()\n",
    "                b.grad.data.zero_()\n",
    "            l.backward()\n",
    "            d2l.sgd([w, b], lr, batch_size)\n",
    "        train_ls.append(loss(net(train_features, w, b), train_labels).mean().item())\n",
    "        test_ls.append(loss(net(test_features, w, b), test_labels).mean().item())\n",
    "    d2l.semilogy(range(1, num_epochs + 1), train_ls, 'epochs', 'loss',\n",
    "                 range(1, num_epochs + 1), test_ls, ['train', 'test'])\n",
    "    print('L2 norm of w:', w.norm().item())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.12.3.4 观察过拟合"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "L2 norm of w: 15.114808082580566\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Created with matplotlib (http://matplotlib.org/) -->\n",
       "<svg height=\"184pt\" version=\"1.1\" viewBox=\"0 0 261 184\" width=\"261pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       " <defs>\n",
       "  <style type=\"text/css\">\n",
       "*{stroke-linecap:butt;stroke-linejoin:round;}\n",
       "  </style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 184.15625 \n",
       "L 261.778125 184.15625 \n",
       "L 261.778125 -0 \n",
       "L 0 -0 \n",
       "z\n",
       "\" style=\"fill:none;\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 55.778125 146.6 \n",
       "L 251.078125 146.6 \n",
       "L 251.078125 10.7 \n",
       "L 55.778125 10.7 \n",
       "z\n",
       "\" style=\"fill:#ffffff;\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" id=\"mbb79af4f3a\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"62.862009\" xlink:href=\"#mbb79af4f3a\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 0 -->\n",
       "      <defs>\n",
       "       <path d=\"M 31.78125 66.40625 \n",
       "Q 24.171875 66.40625 20.328125 58.90625 \n",
       "Q 16.5 51.421875 16.5 36.375 \n",
       "Q 16.5 21.390625 20.328125 13.890625 \n",
       "Q 24.171875 6.390625 31.78125 6.390625 \n",
       "Q 39.453125 6.390625 43.28125 13.890625 \n",
       "Q 47.125 21.390625 47.125 36.375 \n",
       "Q 47.125 51.421875 43.28125 58.90625 \n",
       "Q 39.453125 66.40625 31.78125 66.40625 \n",
       "z\n",
       "M 31.78125 74.21875 \n",
       "Q 44.046875 74.21875 50.515625 64.515625 \n",
       "Q 56.984375 54.828125 56.984375 36.375 \n",
       "Q 56.984375 17.96875 50.515625 8.265625 \n",
       "Q 44.046875 -1.421875 31.78125 -1.421875 \n",
       "Q 19.53125 -1.421875 13.0625 8.265625 \n",
       "Q 6.59375 17.96875 6.59375 36.375 \n",
       "Q 6.59375 54.828125 13.0625 64.515625 \n",
       "Q 19.53125 74.21875 31.78125 74.21875 \n",
       "z\n",
       "\" id=\"DejaVuSans-30\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(59.680759 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_2\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"98.729778\" xlink:href=\"#mbb79af4f3a\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 20 -->\n",
       "      <defs>\n",
       "       <path d=\"M 19.1875 8.296875 \n",
       "L 53.609375 8.296875 \n",
       "L 53.609375 0 \n",
       "L 7.328125 0 \n",
       "L 7.328125 8.296875 \n",
       "Q 12.9375 14.109375 22.625 23.890625 \n",
       "Q 32.328125 33.6875 34.8125 36.53125 \n",
       "Q 39.546875 41.84375 41.421875 45.53125 \n",
       "Q 43.3125 49.21875 43.3125 52.78125 \n",
       "Q 43.3125 58.59375 39.234375 62.25 \n",
       "Q 35.15625 65.921875 28.609375 65.921875 \n",
       "Q 23.96875 65.921875 18.8125 64.3125 \n",
       "Q 13.671875 62.703125 7.8125 59.421875 \n",
       "L 7.8125 69.390625 \n",
       "Q 13.765625 71.78125 18.9375 73 \n",
       "Q 24.125 74.21875 28.421875 74.21875 \n",
       "Q 39.75 74.21875 46.484375 68.546875 \n",
       "Q 53.21875 62.890625 53.21875 53.421875 \n",
       "Q 53.21875 48.921875 51.53125 44.890625 \n",
       "Q 49.859375 40.875 45.40625 35.40625 \n",
       "Q 44.1875 33.984375 37.640625 27.21875 \n",
       "Q 31.109375 20.453125 19.1875 8.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-32\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(92.367278 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"134.597546\" xlink:href=\"#mbb79af4f3a\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 40 -->\n",
       "      <defs>\n",
       "       <path d=\"M 37.796875 64.3125 \n",
       "L 12.890625 25.390625 \n",
       "L 37.796875 25.390625 \n",
       "z\n",
       "M 35.203125 72.90625 \n",
       "L 47.609375 72.90625 \n",
       "L 47.609375 25.390625 \n",
       "L 58.015625 25.390625 \n",
       "L 58.015625 17.1875 \n",
       "L 47.609375 17.1875 \n",
       "L 47.609375 0 \n",
       "L 37.796875 0 \n",
       "L 37.796875 17.1875 \n",
       "L 4.890625 17.1875 \n",
       "L 4.890625 26.703125 \n",
       "z\n",
       "\" id=\"DejaVuSans-34\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(128.235046 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-34\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"170.465315\" xlink:href=\"#mbb79af4f3a\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 60 -->\n",
       "      <defs>\n",
       "       <path d=\"M 33.015625 40.375 \n",
       "Q 26.375 40.375 22.484375 35.828125 \n",
       "Q 18.609375 31.296875 18.609375 23.390625 \n",
       "Q 18.609375 15.53125 22.484375 10.953125 \n",
       "Q 26.375 6.390625 33.015625 6.390625 \n",
       "Q 39.65625 6.390625 43.53125 10.953125 \n",
       "Q 47.40625 15.53125 47.40625 23.390625 \n",
       "Q 47.40625 31.296875 43.53125 35.828125 \n",
       "Q 39.65625 40.375 33.015625 40.375 \n",
       "z\n",
       "M 52.59375 71.296875 \n",
       "L 52.59375 62.3125 \n",
       "Q 48.875 64.0625 45.09375 64.984375 \n",
       "Q 41.3125 65.921875 37.59375 65.921875 \n",
       "Q 27.828125 65.921875 22.671875 59.328125 \n",
       "Q 17.53125 52.734375 16.796875 39.40625 \n",
       "Q 19.671875 43.65625 24.015625 45.921875 \n",
       "Q 28.375 48.1875 33.59375 48.1875 \n",
       "Q 44.578125 48.1875 50.953125 41.515625 \n",
       "Q 57.328125 34.859375 57.328125 23.390625 \n",
       "Q 57.328125 12.15625 50.6875 5.359375 \n",
       "Q 44.046875 -1.421875 33.015625 -1.421875 \n",
       "Q 20.359375 -1.421875 13.671875 8.265625 \n",
       "Q 6.984375 17.96875 6.984375 36.375 \n",
       "Q 6.984375 53.65625 15.1875 63.9375 \n",
       "Q 23.390625 74.21875 37.203125 74.21875 \n",
       "Q 40.921875 74.21875 44.703125 73.484375 \n",
       "Q 48.484375 72.75 52.59375 71.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-36\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(164.102815 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-36\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"206.333084\" xlink:href=\"#mbb79af4f3a\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 80 -->\n",
       "      <defs>\n",
       "       <path d=\"M 31.78125 34.625 \n",
       "Q 24.75 34.625 20.71875 30.859375 \n",
       "Q 16.703125 27.09375 16.703125 20.515625 \n",
       "Q 16.703125 13.921875 20.71875 10.15625 \n",
       "Q 24.75 6.390625 31.78125 6.390625 \n",
       "Q 38.8125 6.390625 42.859375 10.171875 \n",
       "Q 46.921875 13.96875 46.921875 20.515625 \n",
       "Q 46.921875 27.09375 42.890625 30.859375 \n",
       "Q 38.875 34.625 31.78125 34.625 \n",
       "z\n",
       "M 21.921875 38.8125 \n",
       "Q 15.578125 40.375 12.03125 44.71875 \n",
       "Q 8.5 49.078125 8.5 55.328125 \n",
       "Q 8.5 64.0625 14.71875 69.140625 \n",
       "Q 20.953125 74.21875 31.78125 74.21875 \n",
       "Q 42.671875 74.21875 48.875 69.140625 \n",
       "Q 55.078125 64.0625 55.078125 55.328125 \n",
       "Q 55.078125 49.078125 51.53125 44.71875 \n",
       "Q 48 40.375 41.703125 38.8125 \n",
       "Q 48.828125 37.15625 52.796875 32.3125 \n",
       "Q 56.78125 27.484375 56.78125 20.515625 \n",
       "Q 56.78125 9.90625 50.3125 4.234375 \n",
       "Q 43.84375 -1.421875 31.78125 -1.421875 \n",
       "Q 19.734375 -1.421875 13.25 4.234375 \n",
       "Q 6.78125 9.90625 6.78125 20.515625 \n",
       "Q 6.78125 27.484375 10.78125 32.3125 \n",
       "Q 14.796875 37.15625 21.921875 38.8125 \n",
       "z\n",
       "M 18.3125 54.390625 \n",
       "Q 18.3125 48.734375 21.84375 45.5625 \n",
       "Q 25.390625 42.390625 31.78125 42.390625 \n",
       "Q 38.140625 42.390625 41.71875 45.5625 \n",
       "Q 45.3125 48.734375 45.3125 54.390625 \n",
       "Q 45.3125 60.0625 41.71875 63.234375 \n",
       "Q 38.140625 66.40625 31.78125 66.40625 \n",
       "Q 25.390625 66.40625 21.84375 63.234375 \n",
       "Q 18.3125 60.0625 18.3125 54.390625 \n",
       "z\n",
       "\" id=\"DejaVuSans-38\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(199.970584 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-38\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_6\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"242.200852\" xlink:href=\"#mbb79af4f3a\" y=\"146.6\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 100 -->\n",
       "      <defs>\n",
       "       <path d=\"M 12.40625 8.296875 \n",
       "L 28.515625 8.296875 \n",
       "L 28.515625 63.921875 \n",
       "L 10.984375 60.40625 \n",
       "L 10.984375 69.390625 \n",
       "L 28.421875 72.90625 \n",
       "L 38.28125 72.90625 \n",
       "L 38.28125 8.296875 \n",
       "L 54.390625 8.296875 \n",
       "L 54.390625 0 \n",
       "L 12.40625 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-31\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(232.657102 161.198437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_7\">\n",
       "     <!-- epochs -->\n",
       "     <defs>\n",
       "      <path d=\"M 56.203125 29.59375 \n",
       "L 56.203125 25.203125 \n",
       "L 14.890625 25.203125 \n",
       "Q 15.484375 15.921875 20.484375 11.0625 \n",
       "Q 25.484375 6.203125 34.421875 6.203125 \n",
       "Q 39.59375 6.203125 44.453125 7.46875 \n",
       "Q 49.3125 8.734375 54.109375 11.28125 \n",
       "L 54.109375 2.78125 \n",
       "Q 49.265625 0.734375 44.1875 -0.34375 \n",
       "Q 39.109375 -1.421875 33.890625 -1.421875 \n",
       "Q 20.796875 -1.421875 13.15625 6.1875 \n",
       "Q 5.515625 13.8125 5.515625 26.8125 \n",
       "Q 5.515625 40.234375 12.765625 48.109375 \n",
       "Q 20.015625 56 32.328125 56 \n",
       "Q 43.359375 56 49.78125 48.890625 \n",
       "Q 56.203125 41.796875 56.203125 29.59375 \n",
       "z\n",
       "M 47.21875 32.234375 \n",
       "Q 47.125 39.59375 43.09375 43.984375 \n",
       "Q 39.0625 48.390625 32.421875 48.390625 \n",
       "Q 24.90625 48.390625 20.390625 44.140625 \n",
       "Q 15.875 39.890625 15.1875 32.171875 \n",
       "z\n",
       "\" id=\"DejaVuSans-65\"/>\n",
       "      <path d=\"M 18.109375 8.203125 \n",
       "L 18.109375 -20.796875 \n",
       "L 9.078125 -20.796875 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.390625 \n",
       "Q 20.953125 51.265625 25.265625 53.625 \n",
       "Q 29.59375 56 35.59375 56 \n",
       "Q 45.5625 56 51.78125 48.09375 \n",
       "Q 58.015625 40.1875 58.015625 27.296875 \n",
       "Q 58.015625 14.40625 51.78125 6.484375 \n",
       "Q 45.5625 -1.421875 35.59375 -1.421875 \n",
       "Q 29.59375 -1.421875 25.265625 0.953125 \n",
       "Q 20.953125 3.328125 18.109375 8.203125 \n",
       "z\n",
       "M 48.6875 27.296875 \n",
       "Q 48.6875 37.203125 44.609375 42.84375 \n",
       "Q 40.53125 48.484375 33.40625 48.484375 \n",
       "Q 26.265625 48.484375 22.1875 42.84375 \n",
       "Q 18.109375 37.203125 18.109375 27.296875 \n",
       "Q 18.109375 17.390625 22.1875 11.75 \n",
       "Q 26.265625 6.109375 33.40625 6.109375 \n",
       "Q 40.53125 6.109375 44.609375 11.75 \n",
       "Q 48.6875 17.390625 48.6875 27.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-70\"/>\n",
       "      <path d=\"M 30.609375 48.390625 \n",
       "Q 23.390625 48.390625 19.1875 42.75 \n",
       "Q 14.984375 37.109375 14.984375 27.296875 \n",
       "Q 14.984375 17.484375 19.15625 11.84375 \n",
       "Q 23.34375 6.203125 30.609375 6.203125 \n",
       "Q 37.796875 6.203125 41.984375 11.859375 \n",
       "Q 46.1875 17.53125 46.1875 27.296875 \n",
       "Q 46.1875 37.015625 41.984375 42.703125 \n",
       "Q 37.796875 48.390625 30.609375 48.390625 \n",
       "z\n",
       "M 30.609375 56 \n",
       "Q 42.328125 56 49.015625 48.375 \n",
       "Q 55.71875 40.765625 55.71875 27.296875 \n",
       "Q 55.71875 13.875 49.015625 6.21875 \n",
       "Q 42.328125 -1.421875 30.609375 -1.421875 \n",
       "Q 18.84375 -1.421875 12.171875 6.21875 \n",
       "Q 5.515625 13.875 5.515625 27.296875 \n",
       "Q 5.515625 40.765625 12.171875 48.375 \n",
       "Q 18.84375 56 30.609375 56 \n",
       "z\n",
       "\" id=\"DejaVuSans-6f\"/>\n",
       "      <path d=\"M 48.78125 52.59375 \n",
       "L 48.78125 44.1875 \n",
       "Q 44.96875 46.296875 41.140625 47.34375 \n",
       "Q 37.3125 48.390625 33.40625 48.390625 \n",
       "Q 24.65625 48.390625 19.8125 42.84375 \n",
       "Q 14.984375 37.3125 14.984375 27.296875 \n",
       "Q 14.984375 17.28125 19.8125 11.734375 \n",
       "Q 24.65625 6.203125 33.40625 6.203125 \n",
       "Q 37.3125 6.203125 41.140625 7.25 \n",
       "Q 44.96875 8.296875 48.78125 10.40625 \n",
       "L 48.78125 2.09375 \n",
       "Q 45.015625 0.34375 40.984375 -0.53125 \n",
       "Q 36.96875 -1.421875 32.421875 -1.421875 \n",
       "Q 20.0625 -1.421875 12.78125 6.34375 \n",
       "Q 5.515625 14.109375 5.515625 27.296875 \n",
       "Q 5.515625 40.671875 12.859375 48.328125 \n",
       "Q 20.21875 56 33.015625 56 \n",
       "Q 37.15625 56 41.109375 55.140625 \n",
       "Q 45.0625 54.296875 48.78125 52.59375 \n",
       "z\n",
       "\" id=\"DejaVuSans-63\"/>\n",
       "      <path d=\"M 54.890625 33.015625 \n",
       "L 54.890625 0 \n",
       "L 45.90625 0 \n",
       "L 45.90625 32.71875 \n",
       "Q 45.90625 40.484375 42.875 44.328125 \n",
       "Q 39.84375 48.1875 33.796875 48.1875 \n",
       "Q 26.515625 48.1875 22.3125 43.546875 \n",
       "Q 18.109375 38.921875 18.109375 30.90625 \n",
       "L 18.109375 0 \n",
       "L 9.078125 0 \n",
       "L 9.078125 75.984375 \n",
       "L 18.109375 75.984375 \n",
       "L 18.109375 46.1875 \n",
       "Q 21.34375 51.125 25.703125 53.5625 \n",
       "Q 30.078125 56 35.796875 56 \n",
       "Q 45.21875 56 50.046875 50.171875 \n",
       "Q 54.890625 44.34375 54.890625 33.015625 \n",
       "z\n",
       "\" id=\"DejaVuSans-68\"/>\n",
       "      <path d=\"M 44.28125 53.078125 \n",
       "L 44.28125 44.578125 \n",
       "Q 40.484375 46.53125 36.375 47.5 \n",
       "Q 32.28125 48.484375 27.875 48.484375 \n",
       "Q 21.1875 48.484375 17.84375 46.4375 \n",
       "Q 14.5 44.390625 14.5 40.28125 \n",
       "Q 14.5 37.15625 16.890625 35.375 \n",
       "Q 19.28125 33.59375 26.515625 31.984375 \n",
       "L 29.59375 31.296875 \n",
       "Q 39.15625 29.25 43.1875 25.515625 \n",
       "Q 47.21875 21.78125 47.21875 15.09375 \n",
       "Q 47.21875 7.46875 41.1875 3.015625 \n",
       "Q 35.15625 -1.421875 24.609375 -1.421875 \n",
       "Q 20.21875 -1.421875 15.453125 -0.5625 \n",
       "Q 10.6875 0.296875 5.421875 2 \n",
       "L 5.421875 11.28125 \n",
       "Q 10.40625 8.6875 15.234375 7.390625 \n",
       "Q 20.0625 6.109375 24.8125 6.109375 \n",
       "Q 31.15625 6.109375 34.5625 8.28125 \n",
       "Q 37.984375 10.453125 37.984375 14.40625 \n",
       "Q 37.984375 18.0625 35.515625 20.015625 \n",
       "Q 33.0625 21.96875 24.703125 23.78125 \n",
       "L 21.578125 24.515625 \n",
       "Q 13.234375 26.265625 9.515625 29.90625 \n",
       "Q 5.8125 33.546875 5.8125 39.890625 \n",
       "Q 5.8125 47.609375 11.28125 51.796875 \n",
       "Q 16.75 56 26.8125 56 \n",
       "Q 31.78125 56 36.171875 55.265625 \n",
       "Q 40.578125 54.546875 44.28125 53.078125 \n",
       "z\n",
       "\" id=\"DejaVuSans-73\"/>\n",
       "     </defs>\n",
       "     <g transform=\"translate(135.595313 174.876562)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-65\"/>\n",
       "      <use x=\"61.523438\" xlink:href=\"#DejaVuSans-70\"/>\n",
       "      <use x=\"125\" xlink:href=\"#DejaVuSans-6f\"/>\n",
       "      <use x=\"186.181641\" xlink:href=\"#DejaVuSans-63\"/>\n",
       "      <use x=\"241.162109\" xlink:href=\"#DejaVuSans-68\"/>\n",
       "      <use x=\"304.541016\" xlink:href=\"#DejaVuSans-73\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L -3.5 0 \n",
       "\" id=\"m2346caac6f\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"55.778125\" xlink:href=\"#m2346caac6f\" y=\"127.858957\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- $\\mathdefault{10^{-10}}$ -->\n",
       "      <defs>\n",
       "       <path d=\"M 10.59375 35.5 \n",
       "L 73.1875 35.5 \n",
       "L 73.1875 27.203125 \n",
       "L 10.59375 27.203125 \n",
       "z\n",
       "\" id=\"DejaVuSans-2212\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(20.878125 131.658176)scale(0.1 -0.1)\">\n",
       "       <use transform=\"translate(0 0.765625)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use transform=\"translate(63.623047 0.765625)\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use transform=\"translate(128.203125 39.046875)scale(0.7)\" xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use transform=\"translate(186.855469 39.046875)scale(0.7)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use transform=\"translate(231.391602 39.046875)scale(0.7)\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_8\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"55.778125\" xlink:href=\"#m2346caac6f\" y=\"100.156125\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- $\\mathdefault{10^{-7}}$ -->\n",
       "      <defs>\n",
       "       <path d=\"M 8.203125 72.90625 \n",
       "L 55.078125 72.90625 \n",
       "L 55.078125 68.703125 \n",
       "L 28.609375 0 \n",
       "L 18.3125 0 \n",
       "L 43.21875 64.59375 \n",
       "L 8.203125 64.59375 \n",
       "z\n",
       "\" id=\"DejaVuSans-37\"/>\n",
       "      </defs>\n",
       "      <g transform=\"translate(25.278125 103.955343)scale(0.1 -0.1)\">\n",
       "       <use transform=\"translate(0 0.684375)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use transform=\"translate(63.623047 0.684375)\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use transform=\"translate(128.203125 38.965625)scale(0.7)\" xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use transform=\"translate(186.855469 38.965625)scale(0.7)\" xlink:href=\"#DejaVuSans-37\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"55.778125\" xlink:href=\"#m2346caac6f\" y=\"72.453292\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- $\\mathdefault{10^{-4}}$ -->\n",
       "      <g transform=\"translate(25.278125 76.252511)scale(0.1 -0.1)\">\n",
       "       <use transform=\"translate(0 0.684375)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use transform=\"translate(63.623047 0.684375)\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use transform=\"translate(128.203125 38.965625)scale(0.7)\" xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use transform=\"translate(186.855469 38.965625)scale(0.7)\" xlink:href=\"#DejaVuSans-34\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_10\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"55.778125\" xlink:href=\"#m2346caac6f\" y=\"44.750459\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_11\">\n",
       "      <!-- $\\mathdefault{10^{-1}}$ -->\n",
       "      <g transform=\"translate(25.278125 48.549678)scale(0.1 -0.1)\">\n",
       "       <use transform=\"translate(0 0.684375)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use transform=\"translate(63.623047 0.684375)\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use transform=\"translate(128.203125 38.965625)scale(0.7)\" xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use transform=\"translate(186.855469 38.965625)scale(0.7)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"55.778125\" xlink:href=\"#m2346caac6f\" y=\"17.047627\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_12\">\n",
       "      <!-- $\\mathdefault{10^{2}}$ -->\n",
       "      <g transform=\"translate(31.178125 20.846845)scale(0.1 -0.1)\">\n",
       "       <use transform=\"translate(0 0.765625)\" xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use transform=\"translate(63.623047 0.765625)\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use transform=\"translate(128.203125 39.046875)scale(0.7)\" xlink:href=\"#DejaVuSans-32\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_13\">\n",
       "     <!-- loss -->\n",
       "     <defs>\n",
       "      <path d=\"M 9.421875 75.984375 \n",
       "L 18.40625 75.984375 \n",
       "L 18.40625 0 \n",
       "L 9.421875 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-6c\"/>\n",
       "     </defs>\n",
       "     <g transform=\"translate(14.798438 88.307812)rotate(-90)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-6c\"/>\n",
       "      <use x=\"27.783203\" xlink:href=\"#DejaVuSans-6f\"/>\n",
       "      <use x=\"88.964844\" xlink:href=\"#DejaVuSans-73\"/>\n",
       "      <use x=\"141.064453\" xlink:href=\"#DejaVuSans-73\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_12\">\n",
       "    <path clip-path=\"url(#pe6633feb0c)\" d=\"M 64.655398 25.676905 \n",
       "L 66.448786 32.250879 \n",
       "L 68.242175 38.208314 \n",
       "L 70.035563 43.855952 \n",
       "L 71.828951 49.183303 \n",
       "L 73.62234 54.333796 \n",
       "L 75.415728 59.201378 \n",
       "L 77.209117 63.896445 \n",
       "L 79.002505 68.461491 \n",
       "L 80.795894 72.992783 \n",
       "L 82.589282 77.292051 \n",
       "L 84.38267 81.414601 \n",
       "L 86.176059 85.589448 \n",
       "L 87.969447 89.730202 \n",
       "L 89.762836 93.768431 \n",
       "L 91.556224 97.733049 \n",
       "L 93.349613 101.74818 \n",
       "L 95.143001 105.693619 \n",
       "L 96.936389 109.61336 \n",
       "L 98.729778 113.403062 \n",
       "L 100.523166 117.282278 \n",
       "L 102.316555 121.188622 \n",
       "L 104.109943 125.074093 \n",
       "L 105.903332 128.623976 \n",
       "L 107.69672 131.427169 \n",
       "L 109.490108 133.528104 \n",
       "L 111.283497 134.575453 \n",
       "L 113.076885 135.756293 \n",
       "L 114.870274 136.185023 \n",
       "L 116.663662 136.721682 \n",
       "L 118.457051 136.7063 \n",
       "L 120.250439 137.743026 \n",
       "L 122.043827 138.423548 \n",
       "L 123.837216 138.51885 \n",
       "L 125.630604 138.531757 \n",
       "L 127.423993 138.819325 \n",
       "L 129.217381 139.434828 \n",
       "L 131.01077 139.499337 \n",
       "L 132.804158 139.564087 \n",
       "L 134.597546 139.181532 \n",
       "L 136.390935 139.079506 \n",
       "L 138.184323 139.708798 \n",
       "L 139.977712 140.422727 \n",
       "L 141.7711 139.80378 \n",
       "L 143.564489 139.520729 \n",
       "L 145.357877 139.883719 \n",
       "L 147.151265 139.832735 \n",
       "L 148.944654 139.232588 \n",
       "L 150.738042 138.926945 \n",
       "L 152.531431 138.862033 \n",
       "L 154.324819 138.780279 \n",
       "L 156.118208 138.870258 \n",
       "L 157.911596 139.465239 
Download .txt
gitextract_ttpkw08n/

├── .github/
│   └── ISSUE_TEMPLATE/
│       └── bug_report.md
├── .gitignore
├── Dockerfile
├── LICENSE
├── code/
│   ├── chapter02_prerequisite/
│   │   ├── 2.2_tensor.ipynb
│   │   └── 2.3_autograd.ipynb
│   ├── chapter03_DL-basics/
│   │   ├── 3.10_mlp-pytorch.ipynb
│   │   ├── 3.11_underfit-overfit.ipynb
│   │   ├── 3.12_weight-decay.ipynb
│   │   ├── 3.13_dropout.ipynb
│   │   ├── 3.16_kaggle-house-price.ipynb
│   │   ├── 3.1_linear-regression.ipynb
│   │   ├── 3.2_linear-regression-scratch.ipynb
│   │   ├── 3.3_linear-regression-pytorch.ipynb
│   │   ├── 3.5_fashion-mnist.ipynb
│   │   ├── 3.6_softmax-regression-scratch.ipynb
│   │   ├── 3.7_softmax-regression-pytorch.ipynb
│   │   ├── 3.8_mlp.ipynb
│   │   ├── 3.9_mlp-scratch.ipynb
│   │   └── submission.csv
│   ├── chapter04_DL_computation/
│   │   ├── 4.1_model-construction.ipynb
│   │   ├── 4.2_parameters.ipynb
│   │   ├── 4.4_custom-layer.ipynb
│   │   ├── 4.5_read-write.ipynb
│   │   └── 4.6_use-gpu.ipynb
│   ├── chapter05_CNN/
│   │   ├── 5.10_batch-norm.ipynb
│   │   ├── 5.11_resnet.ipynb
│   │   ├── 5.12_densenet.ipynb
│   │   ├── 5.1_conv-layer.ipynb
│   │   ├── 5.2_padding-and-strides.ipynb
│   │   ├── 5.3_channels.ipynb
│   │   ├── 5.4_pooling.ipynb
│   │   ├── 5.5_lenet.ipynb
│   │   ├── 5.6_alexnet.ipynb
│   │   ├── 5.7_vgg.ipynb
│   │   ├── 5.8_nin.ipynb
│   │   └── 5.9_googlenet.ipynb
│   ├── chapter06_RNN/
│   │   ├── 6.2_rnn.ipynb
│   │   ├── 6.3_lang-model-dataset.ipynb
│   │   ├── 6.4_rnn-scratch.ipynb
│   │   ├── 6.5_rnn-pytorch.ipynb
│   │   ├── 6.7_gru.ipynb
│   │   └── 6.8_lstm.ipynb
│   ├── chapter07_optimization/
│   │   ├── 7.1_optimization-intro.ipynb
│   │   ├── 7.2_gd-sgd.ipynb
│   │   ├── 7.3_minibatch-sgd.ipynb
│   │   ├── 7.4_momentum.ipynb
│   │   ├── 7.5_adagrad.ipynb
│   │   ├── 7.6_rmsprop.ipynb
│   │   ├── 7.7_adadelta.ipynb
│   │   └── 7.8_adam.ipynb
│   ├── chapter08_computational-performance/
│   │   ├── 8.1_hybridize.ipynb
│   │   ├── 8.3_auto-parallelism.ipynb
│   │   ├── 8.4_model.pt
│   │   └── 8.4_multiple-gpus.ipynb
│   ├── chapter09_computer-vision/
│   │   ├── 9.11_neural-style.ipynb
│   │   ├── 9.1_image-augmentation.ipynb
│   │   ├── 9.2_fine-tuning.ipynb
│   │   ├── 9.3_bounding-box.ipynb
│   │   ├── 9.4_anchor.ipynb
│   │   ├── 9.5_multiscale-object-detection.ipynb
│   │   ├── 9.6.0_prepare_pikachu.ipynb
│   │   ├── 9.6_object-detection-dataset.ipynb
│   │   ├── 9.8_rcnn.ipynb
│   │   └── 9.9_semantic-segmentation-and-dataset.ipynb
│   ├── chapter10_natural-language-processing/
│   │   ├── 10.12_machine-translation.ipynb
│   │   ├── 10.3_word2vec-pytorch.ipynb
│   │   ├── 10.6_similarity-analogy.ipynb
│   │   ├── 10.7_sentiment-analysis-rnn.ipynb
│   │   └── 10.8_sentiment-analysis-cnn.ipynb
│   └── d2lzh_pytorch/
│       ├── __init__.py
│       └── utils.py
├── data/
│   ├── fr-en-small.txt
│   ├── kaggle_house/
│   │   ├── data_description.txt
│   │   ├── sample_submission.csv
│   │   ├── test.csv
│   │   └── train.csv
│   └── ptb/
│       ├── README
│       ├── ptb.test.txt
│       ├── ptb.train.txt
│       └── ptb.valid.txt
└── docs/
    ├── .nojekyll
    ├── README.md
    ├── _sidebar.md
    ├── chapter01_DL-intro/
    │   └── deep-learning-intro.md
    ├── chapter02_prerequisite/
    │   ├── 2.1_install.md
    │   ├── 2.2_tensor.md
    │   └── 2.3_autograd.md
    ├── chapter03_DL-basics/
    │   ├── 3.10_mlp-pytorch.md
    │   ├── 3.11_underfit-overfit.md
    │   ├── 3.12_weight-decay.md
    │   ├── 3.13_dropout.md
    │   ├── 3.14_backprop.md
    │   ├── 3.15_numerical-stability-and-init.md
    │   ├── 3.16_kaggle-house-price.md
    │   ├── 3.1_linear-regression.md
    │   ├── 3.2_linear-regression-scratch.md
    │   ├── 3.3_linear-regression-pytorch.md
    │   ├── 3.4_softmax-regression.md
    │   ├── 3.5_fashion-mnist.md
    │   ├── 3.6_softmax-regression-scratch.md
    │   ├── 3.7_softmax-regression-pytorch.md
    │   ├── 3.8_mlp.md
    │   └── 3.9_mlp-scratch.md
    ├── chapter04_DL_computation/
    │   ├── 4.1_model-construction.md
    │   ├── 4.2_parameters.md
    │   ├── 4.3_deferred-init.md
    │   ├── 4.4_custom-layer.md
    │   ├── 4.5_read-write.md
    │   └── 4.6_use-gpu.md
    ├── chapter05_CNN/
    │   ├── 5.10_batch-norm.md
    │   ├── 5.11_resnet.md
    │   ├── 5.12_densenet.md
    │   ├── 5.1_conv-layer.md
    │   ├── 5.2_padding-and-strides.md
    │   ├── 5.3_channels.md
    │   ├── 5.4_pooling.md
    │   ├── 5.5_lenet.md
    │   ├── 5.6_alexnet.md
    │   ├── 5.7_vgg.md
    │   ├── 5.8_nin.md
    │   └── 5.9_googlenet.md
    ├── chapter06_RNN/
    │   ├── 6.10_bi-rnn.md
    │   ├── 6.1_lang-model.md
    │   ├── 6.2_rnn.md
    │   ├── 6.3_lang-model-dataset.md
    │   ├── 6.4_rnn-scratch.md
    │   ├── 6.5_rnn-pytorch.md
    │   ├── 6.6_bptt.md
    │   ├── 6.7_gru.md
    │   ├── 6.8_lstm.md
    │   └── 6.9_deep-rnn.md
    ├── chapter07_optimization/
    │   ├── 7.1_optimization-intro.md
    │   ├── 7.2_gd-sgd.md
    │   ├── 7.3_minibatch-sgd.md
    │   ├── 7.4_momentum.md
    │   ├── 7.5_adagrad.md
    │   ├── 7.6_rmsprop.md
    │   ├── 7.7_adadelta.md
    │   └── 7.8_adam.md
    ├── chapter08_computational-performance/
    │   ├── 8.1_hybridize.md
    │   ├── 8.2_async-computation.md
    │   ├── 8.3_auto-parallelism.md
    │   └── 8.4_multiple-gpus.md
    ├── chapter09_computer-vision/
    │   ├── 9.11_neural-style.md
    │   ├── 9.1_image-augmentation.md
    │   ├── 9.2_fine-tuning.md
    │   ├── 9.3_bounding-box.md
    │   ├── 9.4_anchor.md
    │   ├── 9.5_multiscale-object-detection.md
    │   ├── 9.6_object-detection-dataset.md
    │   ├── 9.8_rcnn.md
    │   └── 9.9_semantic-segmentation-and-dataset.md
    ├── chapter10_natural-language-processing/
    │   ├── 10.10_beam-search.md
    │   ├── 10.11_attention.md
    │   ├── 10.12_machine-translation.md
    │   ├── 10.1_word2vec.md
    │   ├── 10.2_approx-training.md
    │   ├── 10.3_word2vec-pytorch.md
    │   ├── 10.4_fasttext.md
    │   ├── 10.5_glove.md
    │   ├── 10.6_similarity-analogy.md
    │   ├── 10.7_sentiment-analysis-rnn.md
    │   ├── 10.8_sentiment-analysis-cnn.md
    │   └── 10.9_seq2seq.md
    ├── docsify.js
    ├── index.html
    └── read_guide.md
Download .txt
SYMBOL INDEX (169 symbols across 2 files)

FILE: code/d2lzh_pytorch/utils.py
  function set_figsize (line 42) | def set_figsize(figsize=(3.5, 2.5)):
  function use_svg_display (line 47) | def use_svg_display():
  function data_iter (line 51) | def data_iter(batch_size, features, labels):
  function linreg (line 59) | def linreg(X, w, b):
  function squared_loss (line 62) | def squared_loss(y_hat, y):
  function sgd (line 66) | def sgd(params, lr, batch_size):
  function get_fashion_mnist_labels (line 75) | def get_fashion_mnist_labels(labels):
  function show_fashion_mnist (line 80) | def show_fashion_mnist(images, labels):
  function train_ch3 (line 119) | def train_ch3(net, train_iter, test_iter, loss, num_epochs, batch_size,
  class FlattenLayer (line 152) | class FlattenLayer(torch.nn.Module):
    method __init__ (line 153) | def __init__(self):
    method forward (line 155) | def forward(self, x): # x shape: (batch, *, *, ...)
  function semilogy (line 160) | def semilogy(x_vals, y_vals, x_label, y_label, x2_vals=None, y2_vals=None,
  function corr2d (line 198) | def corr2d(X, K):
  function evaluate_accuracy (line 209) | def evaluate_accuracy(data_iter, net, device=None):
  function train_ch5 (line 229) | def train_ch5(net, train_iter, test_iter, batch_size, optimizer, device,...
  function load_data_fashion_mnist (line 254) | def load_data_fashion_mnist(batch_size, resize=None, root='~/Datasets/Fa...
  class GlobalAvgPool2d (line 276) | class GlobalAvgPool2d(nn.Module):
    method __init__ (line 278) | def __init__(self):
    method forward (line 280) | def forward(self, x):
  class Residual (line 286) | class Residual(nn.Module):
    method __init__ (line 287) | def __init__(self, in_channels, out_channels, use_1x1conv=False, strid...
    method forward (line 298) | def forward(self, X):
  function resnet_block (line 305) | def resnet_block(in_channels, out_channels, num_residuals, first_block=F...
  function resnet18 (line 316) | def resnet18(output=10, in_channels=3):
  function load_data_jay_lyrics (line 333) | def load_data_jay_lyrics():
  function data_iter_random (line 346) | def data_iter_random(corpus_indices, batch_size, num_steps, device=None):
  function data_iter_consecutive (line 367) | def data_iter_consecutive(corpus_indices, batch_size, num_steps, device=...
  function one_hot (line 386) | def one_hot(x, n_class, dtype=torch.float32):
  function to_onehot (line 393) | def to_onehot(X, n_class):
  function predict_rnn (line 397) | def predict_rnn(prefix, num_chars, rnn, params, init_rnn_state,
  function grad_clipping (line 413) | def grad_clipping(params, theta, device):
  function train_and_predict_rnn (line 422) | def train_and_predict_rnn(rnn, get_params, init_rnn_state, num_hiddens,
  class RNNModel (line 480) | class RNNModel(nn.Module):
    method __init__ (line 481) | def __init__(self, rnn_layer, vocab_size):
    method forward (line 489) | def forward(self, inputs, state): # inputs: (batch, seq_len)
  function predict_rnn_pytorch (line 498) | def predict_rnn_pytorch(prefix, num_chars, model, vocab_size, device, id...
  function train_and_predict_rnn_pytorch (line 517) | def train_and_predict_rnn_pytorch(model, num_hiddens, vocab_size, device,
  function train_2d (line 568) | def train_2d(trainer):
  function show_trace_2d (line 577) | def show_trace_2d(f, results):
  function get_data_ch7 (line 588) | def get_data_ch7():
  function train_ch7 (line 594) | def train_ch7(optimizer_fn, states, hyperparams, features, labels,
  function train_pytorch_ch7 (line 633) | def train_pytorch_ch7(optimizer_fn, optimizer_hyperparams, features, lab...
  class Benchmark (line 671) | class Benchmark():
    method __init__ (line 672) | def __init__(self, prefix=None):
    method __enter__ (line 675) | def __enter__(self):
    method __exit__ (line 678) | def __exit__(self, *args):
  function show_images (line 686) | def show_images(imgs, num_rows, num_cols, scale=2):
  function train (line 696) | def train(train_iter, test_iter, net, loss, optimizer, device, num_epochs):
  function bbox_to_rect (line 722) | def bbox_to_rect(bbox, color):
  function MultiBoxPrior (line 733) | def MultiBoxPrior(feature_map, sizes=[0.75, 0.5, 0.25], ratios=[1, 2, 0....
  function show_bboxes (line 769) | def show_bboxes(axes, bboxes, labels=None, colors=None):
  function compute_intersection (line 789) | def compute_intersection(set_1, set_2):
  function compute_jaccard (line 804) | def compute_jaccard(set_1, set_2):
  function assign_anchor (line 826) | def assign_anchor(bb, anchor, jaccard_threshold=0.5):
  function xy_to_cxcy (line 858) | def xy_to_cxcy(xy):
  function MultiBoxTarget (line 870) | def MultiBoxTarget(anchor, label):
  function non_max_suppression (line 938) | def non_max_suppression(bb_info_list, nms_threshold = 0.5):
  function MultiBoxDetection (line 969) | def MultiBoxDetection(cls_prob, loc_pred, anchor, nms_threshold = 0.5):
  class PikachuDetDataset (line 1033) | class PikachuDetDataset(torch.utils.data.Dataset):
    method __init__ (line 1035) | def __init__(self, data_dir, part, image_size=(256, 256)):
    method __len__ (line 1047) | def __len__(self):
    method __getitem__ (line 1050) | def __getitem__(self, index):
  function load_data_pikachu (line 1068) | def load_data_pikachu(batch_size, edge_size=256, data_dir = '../../data/...
  function read_voc_images (line 1084) | def read_voc_images(root="../../data/VOCdevkit/VOC2012",
  function voc_label_indices (line 1101) | def voc_label_indices(colormap, colormap2label):
  function voc_rand_crop (line 1110) | def voc_rand_crop(feature, label, height, width):
  class VOCSegDataset (line 1122) | class VOCSegDataset(torch.utils.data.Dataset):
    method __init__ (line 1123) | def __init__(self, is_train, crop_size, voc_dir, colormap2label, max_n...
    method filter (line 1144) | def filter(self, imgs):
    method __getitem__ (line 1149) | def __getitem__(self, idx):
    method __len__ (line 1156) | def __len__(self):
  function read_imdb (line 1162) | def read_imdb(folder='train', data_root="/S1/CSCL/tangss/Datasets/aclImd...
  function get_tokenized_imdb (line 1173) | def get_tokenized_imdb(data):
  function get_vocab_imdb (line 1181) | def get_vocab_imdb(data):
  function preprocess_imdb (line 1186) | def preprocess_imdb(data, vocab):
  function load_pretrained_embedding (line 1197) | def load_pretrained_embedding(words, pretrained_vocab):
  function predict_sentiment (line 1211) | def predict_sentiment(net, vocab, sentence):

FILE: docs/docsify.js
  function cached (line 5) | function cached(fn) {
  function isPrimitive (line 47) | function isPrimitive(value) {
  function noop (line 54) | function noop() {}
  function isFn (line 59) | function isFn(obj) {
  function config (line 63) | function config () {
  function initLifecycle (line 133) | function initLifecycle(vm) {
  function callHook (line 151) | function callHook(vm, hook, data, next) {
  function getNode (line 209) | function getNode(el, noCache) {
  function find (line 234) | function find(el, node) {
  function findAll (line 244) | function findAll(el, node) {
  function create (line 250) | function create(node, tpl) {
  function appendTo (line 258) | function appendTo(target, el) {
  function before (line 262) | function before(target, el) {
  function on (line 266) | function on(el, type, handler) {
  function off (line 272) | function off(el, type, handler) {
  function toggleClass (line 285) | function toggleClass(el, type, val) {
  function style (line 289) | function style(content) {
  function corner (line 315) | function corner(data) {
  function main (line 338) | function main(config) {
  function cover (line 366) | function cover() {
  function tree (line 387) | function tree(toc, tpl) {
  function helper (line 403) | function helper(className, content) {
  function theme (line 407) | function theme(color) {
  function init (line 417) | function init() {
  function progressbar (line 427) | function progressbar (ref) {
  function get (line 463) | function get(url, hasBar, headers) {
  function replaceVar (line 526) | function replaceVar(block, color) {
  function cssVars (line 533) | function cssVars (color) {
  function tinydate (line 574) | function tinydate (str) {
  function createCommonjsModule (line 605) | function createCommonjsModule(fn, module) {
  function Lexer (line 740) | function Lexer(options) {
  function InlineLexer (line 1226) | function InlineLexer(links, options) {
  function Renderer (line 1499) | function Renderer(options) {
  function TextRenderer (line 1691) | function TextRenderer() {}
  function Parser (line 1716) | function Parser(options) {
  function escape (line 1905) | function escape(html, encode) {
  function unescape (line 1914) | function unescape(html) {
  function edit (line 1928) | function edit(regex, opt) {
  function resolveUrl (line 1944) | function resolveUrl(base, href) {
  function noop (line 1968) | function noop() {}
  function merge (line 1971) | function merge(obj) {
  function splitCells (line 1988) | function splitCells(tableRow, count) {
  function marked (line 2008) | function marked(src, opt, callback) {
  function genTree (line 3043) | function genTree(toc, maxLevel) {
  function lower (line 3068) | function lower(string) {
  function slugify (line 3072) | function slugify(str) {
  function replace (line 3101) | function replace(m, $1) {
  function emojify (line 3105) | function emojify(text) {
  function parseQuery (line 3115) | function parseQuery(query) {
  function stringifyQuery (line 3134) | function stringifyQuery(obj, ignores) {
  function getPath (line 3181) | function getPath() {
  function getAndRemoveConfig (line 3285) | function getAndRemoveConfig(str) {
  function btn (line 3693) | function btn(el) {
  function collapse (line 3713) | function collapse(el) {
  function sticky (line 3731) | function sticky() {
  function getAndActive (line 3753) | function getAndActive(router, el, isParent, autoTitle) {
  function defineProperties (line 3781) | function defineProperties(target, props) { for (var i = 0; i < props.len...
  function _classCallCheck (line 3783) | function _classCallCheck(instance, Constructor) { if (!(instance instanc...
  function Tweezer (line 3786) | function Tweezer() {
  function scrollTo (line 3882) | function scrollTo(el) {
  function highlight (line 3900) | function highlight(path) {
  function getNavKey (line 3952) | function getNavKey(path, id) {
  function scrollActiveSidebar (line 3956) | function scrollActiveSidebar(router) {
  function scrollIntoView (line 4002) | function scrollIntoView(path, id) {
  function scroll2Top (line 4019) | function scroll2Top(offset) {
  function walkFetchEmbed (line 4027) | function walkFetchEmbed(ref, cb) {
  function prerenderEmbed (line 4087) | function prerenderEmbed(ref, done) {
  function executeScript (line 4147) | function executeScript() {
  function formatUpdated (line 4163) | function formatUpdated(html, updated, fn) {
  function renderMain (line 4174) | function renderMain(html) {
  function renderNameLink (line 4199) | function renderNameLink(vm) {
  function renderMixin (line 4217) | function renderMixin(proto) {
  function initRender (line 4351) | function initRender(vm) {
  function getAlias (line 4420) | function getAlias(path, alias, last) {
  function getFileName (line 4431) | function getFileName(path, ext) {
  function replaceHash (line 4498) | function replaceHash(path) {
  function HashHistory (line 4504) | function HashHistory(config) {
  function HTML5History (line 4581) | function HTML5History(config) {
  function routerMixin (line 4651) | function routerMixin(proto) {
  function updateRender (line 4657) | function updateRender(vm) {
  function initRouter (line 4663) | function initRouter(vm) {
  function eventMixin (line 4692) | function eventMixin(proto) {
  function initEvent (line 4702) | function initEvent(vm) {
  function loadNested (line 4714) | function loadNested(path, qs, file, next, vm, first) {
  function fetchMixin (line 4729) | function fetchMixin(proto) {
  function initFetch (line 4954) | function initFetch(vm) {
  function initMixin (line 4973) | function initMixin(proto) {
  function initPlugin (line 4989) | function initPlugin(vm) {
  function initGlobalAPI (line 5016) | function initGlobalAPI () {
  function ready (line 5032) | function ready(callback) {
  function Docsify (line 5042) | function Docsify() {
Copy disabled (too large) Download .json
Condensed preview — 168 files, each showing path, character count, and a content snippet. Download the .json file for the full structured content (13,314K chars).
[
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.md",
    "chars": 192,
    "preview": "---\nname: Bug report\nabout: bug相关issue请按照此模板填写否则会被直接关闭\ntitle: ''\nlabels: ''\nassignees: ''\n\n---\n\n**bug描述**\n描述一下你遇到的bug, 例"
  },
  {
    "path": ".gitignore",
    "chars": 124,
    "preview": "*.DS_Store\n*.pyc\n*checkpoint.ipynb\n.mypy_cache*\n.vscode*\n# 皮卡丘数据集太大了\ndata/pikachu*\n# Pascal VOC2012数据集, 约2G\ndata/VOCdevk"
  },
  {
    "path": "Dockerfile",
    "chars": 103,
    "preview": "FROM node:alpine\nRUN npm i docsify-cli -g\nCOPY . /data\nWORKDIR /data\nCMD [ \"docsify\", \"serve\", \"docs\" ]"
  },
  {
    "path": "LICENSE",
    "chars": 11357,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "code/chapter02_prerequisite/2.2_tensor.ipynb",
    "chars": 14926,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 2.2 数据操作\"\n   ]\n  },\n  {\n   \"cell_"
  },
  {
    "path": "code/chapter02_prerequisite/2.3_autograd.ipynb",
    "chars": 10278,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 1,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"name\":"
  },
  {
    "path": "code/chapter03_DL-basics/3.10_mlp-pytorch.ipynb",
    "chars": 2780,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 3.10 多层感知机的简洁实现\"\n   ]\n  },\n  {\n  "
  },
  {
    "path": "code/chapter03_DL-basics/3.11_underfit-overfit.ipynb",
    "chars": 128399,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 3.11 模型选择、欠拟合和过拟合\\n\",\n    \"## 3.1"
  },
  {
    "path": "code/chapter03_DL-basics/3.12_weight-decay.ipynb",
    "chars": 191377,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 3.12 权重衰减\"\n   ]\n  },\n  {\n   \"cell"
  },
  {
    "path": "code/chapter03_DL-basics/3.13_dropout.ipynb",
    "chars": 7369,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 1,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"name\":"
  },
  {
    "path": "code/chapter03_DL-basics/3.16_kaggle-house-price.ipynb",
    "chars": 85352,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 3.16 实战Kaggle比赛:房价预测\"\n   ]\n  },\n "
  },
  {
    "path": "code/chapter03_DL-basics/3.1_linear-regression.ipynb",
    "chars": 2604,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 3.1 线性回归\"\n   ]\n  },\n  {\n   \"cell_"
  },
  {
    "path": "code/chapter03_DL-basics/3.2_linear-regression-scratch.ipynb",
    "chars": 143956,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 3.2 线性回归的从零开始实现\"\n   ]\n  },\n  {\n  "
  },
  {
    "path": "code/chapter03_DL-basics/3.3_linear-regression-pytorch.ipynb",
    "chars": 9240,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 3.3 线性回归的简洁实现\"\n   ]\n  },\n  {\n   \""
  },
  {
    "path": "code/chapter03_DL-basics/3.5_fashion-mnist.ipynb",
    "chars": 67322,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 3.5 图像分类数据集(Fashion-MNIST)\"\n   ]\n"
  },
  {
    "path": "code/chapter03_DL-basics/3.6_softmax-regression-scratch.ipynb",
    "chars": 71966,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 3.6 softmax回归的从零开始实现\"\n   ]\n  },\n "
  },
  {
    "path": "code/chapter03_DL-basics/3.7_softmax-regression-pytorch.ipynb",
    "chars": 4479,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 3.7 softmax回归的简洁实现\"\n   ]\n  },\n  {"
  },
  {
    "path": "code/chapter03_DL-basics/3.8_mlp.ipynb",
    "chars": 184560,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 3.8 多层感知机\"\n   ]\n  },\n  {\n   \"cell"
  },
  {
    "path": "code/chapter03_DL-basics/3.9_mlp-scratch.ipynb",
    "chars": 3950,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 3.9 多层感知机的从零开始实现\"\n   ]\n  },\n  {\n "
  },
  {
    "path": "code/chapter03_DL-basics/submission.csv",
    "chars": 26851,
    "preview": "Id,SalePrice\n1461,119366.5703125\n1462,154295.078125\n1463,198676.609375\n1464,217123.265625\n1465,177452.078125\n1466,193253"
  },
  {
    "path": "code/chapter04_DL_computation/4.1_model-construction.ipynb",
    "chars": 11462,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 4.1 模型构造\"\n   ]\n  },\n  {\n   \"cell_"
  },
  {
    "path": "code/chapter04_DL_computation/4.2_parameters.ipynb",
    "chars": 8120,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 4.2 模型参数的访问、初始化和共享\"\n   ]\n  },\n  {"
  },
  {
    "path": "code/chapter04_DL_computation/4.4_custom-layer.ipynb",
    "chars": 6415,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 4.4 自定义层\\n\",\n    \"## 4.4.1 不含模型参数"
  },
  {
    "path": "code/chapter04_DL_computation/4.5_read-write.ipynb",
    "chars": 5029,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 4.5 读取和存储\"\n   ]\n  },\n  {\n   \"cell"
  },
  {
    "path": "code/chapter04_DL_computation/4.6_use-gpu.ipynb",
    "chars": 10438,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 4.6 GPU计算\"\n   ]\n  },\n  {\n   \"cell"
  },
  {
    "path": "code/chapter05_CNN/5.10_batch-norm.ipynb",
    "chars": 8336,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 5.10 批量归一化\"\n   ]\n  },\n  {\n   \"cel"
  },
  {
    "path": "code/chapter05_CNN/5.11_resnet.ipynb",
    "chars": 7028,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 5.11 残差网络(ResNet)\"\n   ]\n  },\n  {\n"
  },
  {
    "path": "code/chapter05_CNN/5.12_densenet.ipynb",
    "chars": 7849,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 5.12 稠密连接网络(DenseNet)\"\n   ]\n  },\n"
  },
  {
    "path": "code/chapter05_CNN/5.1_conv-layer.ipynb",
    "chars": 5580,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 5.1 二维卷积层\\n\",\n    \"## 5.1.1 二维互相关"
  },
  {
    "path": "code/chapter05_CNN/5.2_padding-and-strides.ipynb",
    "chars": 3243,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 5.2 填充和步幅\"\n   ]\n  },\n  {\n   \"cell"
  },
  {
    "path": "code/chapter05_CNN/5.3_channels.ipynb",
    "chars": 4365,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 5.3 多输入通道和多输出通道\\n\",\n    \"## 5.3.1"
  },
  {
    "path": "code/chapter05_CNN/5.4_pooling.ipynb",
    "chars": 5624,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 5.4 池化层\"\n   ]\n  },\n  {\n   \"cell_t"
  },
  {
    "path": "code/chapter05_CNN/5.5_lenet.ipynb",
    "chars": 8711,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 5.5 卷积神经网络(LeNet)\"\n   ]\n  },\n  {\n"
  },
  {
    "path": "code/chapter05_CNN/5.6_alexnet.ipynb",
    "chars": 8382,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 5.6 深度卷积神经网络(AlexNet)\"\n   ]\n  },\n"
  },
  {
    "path": "code/chapter05_CNN/5.7_vgg.ipynb",
    "chars": 8008,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 5.7 使用重复元素的网络(VGG)\"\n   ]\n  },\n  {"
  },
  {
    "path": "code/chapter05_CNN/5.8_nin.ipynb",
    "chars": 4750,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 5.8 网络中的网络(NiN)\"\n   ]\n  },\n  {\n  "
  },
  {
    "path": "code/chapter05_CNN/5.9_googlenet.ipynb",
    "chars": 6527,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 5.9 含并行连结的网络(GoogLeNet)\"\n   ]\n  }"
  },
  {
    "path": "code/chapter06_RNN/6.2_rnn.ipynb",
    "chars": 2092,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 6.2 循环神经网络\"\n   ]\n  },\n  {\n   \"cel"
  },
  {
    "path": "code/chapter06_RNN/6.3_lang-model-dataset.ipynb",
    "chars": 7175,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 6.3 语言模型数据集(周杰伦专辑歌词)\"\n   ]\n  },\n "
  },
  {
    "path": "code/chapter06_RNN/6.4_rnn-scratch.ipynb",
    "chars": 14434,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 6.4 循环神经网络的从零开始实现\"\n   ]\n  },\n  {\n"
  },
  {
    "path": "code/chapter06_RNN/6.5_rnn-pytorch.ipynb",
    "chars": 9405,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 6.5 循环神经网络的简洁实现\"\n   ]\n  },\n  {\n  "
  },
  {
    "path": "code/chapter06_RNN/6.7_gru.ipynb",
    "chars": 7291,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 6.7 门控循环单元(GRU)\\n\",\n    \"## 6.7.2"
  },
  {
    "path": "code/chapter06_RNN/6.8_lstm.ipynb",
    "chars": 7591,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 6.8 长短期记忆(LSTM)\\n\",\n    \"## 6.8.2"
  },
  {
    "path": "code/chapter07_optimization/7.1_optimization-intro.ipynb",
    "chars": 113407,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 7.1 优化与深度学习\\n\",\n    \"## 7.1.2 优化在"
  },
  {
    "path": "code/chapter07_optimization/7.2_gd-sgd.ipynb",
    "chars": 136598,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 7.2 梯度下降和随机梯度下降\"\n   ]\n  },\n  {\n  "
  },
  {
    "path": "code/chapter07_optimization/7.3_minibatch-sgd.ipynb",
    "chars": 108725,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 7.3 小批量随机梯度下降\"\n   ]\n  },\n  {\n   \""
  },
  {
    "path": "code/chapter07_optimization/7.4_momentum.ipynb",
    "chars": 204380,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 7.4 动量法\"\n   ]\n  },\n  {\n   \"cell_t"
  },
  {
    "path": "code/chapter07_optimization/7.5_adagrad.ipynb",
    "chars": 106480,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 7.5 AdaGrad算法\"\n   ]\n  },\n  {\n   \""
  },
  {
    "path": "code/chapter07_optimization/7.6_rmsprop.ipynb",
    "chars": 79811,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 7.6 RMSProp算法\"\n   ]\n  },\n  {\n   \""
  },
  {
    "path": "code/chapter07_optimization/7.7_adadelta.ipynb",
    "chars": 56553,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 7.7 AdaDelta算法\"\n   ]\n  },\n  {\n   "
  },
  {
    "path": "code/chapter07_optimization/7.8_adam.ipynb",
    "chars": 54129,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 7.8 Adam算法\"\n   ]\n  },\n  {\n   \"cel"
  },
  {
    "path": "code/chapter08_computational-performance/8.1_hybridize.ipynb",
    "chars": 2305,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 8.1 命令式和符号式混合编程\"\n   ]\n  },\n  {\n  "
  },
  {
    "path": "code/chapter08_computational-performance/8.3_auto-parallelism.ipynb",
    "chars": 4138,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 8.3 自动并行计算\"\n   ]\n  },\n  {\n   \"cel"
  },
  {
    "path": "code/chapter08_computational-performance/8.4_multiple-gpus.ipynb",
    "chars": 7572,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 1,\n   \"metadata\": {\n    \"ExecuteTime\": {\n     \"end_time\""
  },
  {
    "path": "code/chapter09_computer-vision/9.11_neural-style.ipynb",
    "chars": 480077,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 9.11 样式迁移\"\n   ]\n  },\n  {\n   \"cell"
  },
  {
    "path": "code/chapter09_computer-vision/9.1_image-augmentation.ipynb",
    "chars": 1336993,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 9.1 图像增广\"\n   ]\n  },\n  {\n   \"cell_"
  },
  {
    "path": "code/chapter09_computer-vision/9.2_fine-tuning.ipynb",
    "chars": 195104,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 9.2 微调\"\n   ]\n  },\n  {\n   \"cell_ty"
  },
  {
    "path": "code/chapter09_computer-vision/9.3_bounding-box.ipynb",
    "chars": 125828,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 9.3 目标检测和边界框\"\n   ]\n  },\n  {\n   \"c"
  },
  {
    "path": "code/chapter09_computer-vision/9.4_anchor.ipynb",
    "chars": 320472,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 9.4 锚框\"\n   ]\n  },\n  {\n   \"cell_ty"
  },
  {
    "path": "code/chapter09_computer-vision/9.5_multiscale-object-detection.ipynb",
    "chars": 198441,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 9.5 多尺度目标检测\"\n   ]\n  },\n  {\n   \"ce"
  },
  {
    "path": "code/chapter09_computer-vision/9.6.0_prepare_pikachu.ipynb",
    "chars": 5264,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 9.6.0 准备皮卡丘数据集\"\n   ]\n  },\n  {\n   "
  },
  {
    "path": "code/chapter09_computer-vision/9.6_object-detection-dataset.ipynb",
    "chars": 327876,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 9.6 目标检测数据集(皮卡丘)\"\n   ]\n  },\n  {\n "
  },
  {
    "path": "code/chapter09_computer-vision/9.8_rcnn.ipynb",
    "chars": 2376,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 9.8 区域卷积神经网络(R-CNN)系列\"\n   ]\n  },\n"
  },
  {
    "path": "code/chapter09_computer-vision/9.9_semantic-segmentation-and-dataset.ipynb",
    "chars": 224273,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 9.9 语义分割和数据集\"\n   ]\n  },\n  {\n   \"c"
  },
  {
    "path": "code/chapter10_natural-language-processing/10.12_machine-translation.ipynb",
    "chars": 15835,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 10.12 机器翻译\"\n   ]\n  },\n  {\n   \"cel"
  },
  {
    "path": "code/chapter10_natural-language-processing/10.3_word2vec-pytorch.ipynb",
    "chars": 20335,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 10.3 word2vec的实现\"\n   ]\n  },\n  {\n "
  },
  {
    "path": "code/chapter10_natural-language-processing/10.6_similarity-analogy.ipynb",
    "chars": 7201,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 10.6 求近义词和类比词\\n\",\n    \"## 10.6.1 "
  },
  {
    "path": "code/chapter10_natural-language-processing/10.7_sentiment-analysis-rnn.ipynb",
    "chars": 14417,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 10.7 文本情感分类:使用循环神经网络\"\n   ]\n  },\n "
  },
  {
    "path": "code/chapter10_natural-language-processing/10.8_sentiment-analysis-cnn.ipynb",
    "chars": 11195,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# 10.8 文本情感分类:使用卷积神经网络(textCNN)\"\n  "
  },
  {
    "path": "code/d2lzh_pytorch/__init__.py",
    "chars": 22,
    "preview": "from .utils import *\n\n"
  },
  {
    "path": "code/d2lzh_pytorch/utils.py",
    "chars": 46776,
    "preview": "import collections\nimport math\nimport os\nimport random\nimport sys\nimport tarfile\nimport time\nimport json\nimport zipfile\n"
  },
  {
    "path": "data/fr-en-small.txt",
    "chars": 806,
    "preview": "elle est vieille .\tshe is old .\nelle est tranquille .\tshe is quiet .\nelle a tort .\tshe is wrong .\nelle est canadienne .\t"
  },
  {
    "path": "data/kaggle_house/data_description.txt",
    "chars": 13370,
    "preview": "MSSubClass: Identifies the type of dwelling involved in the sale.\t\n\n        20\t1-STORY 1946 & NEWER ALL STYLES\n        3"
  },
  {
    "path": "data/kaggle_house/sample_submission.csv",
    "chars": 31939,
    "preview": "Id,SalePrice\n1461,169277.0524984\n1462,187758.393988768\n1463,183583.683569555\n1464,179317.47751083\n1465,150730.079976501\n"
  },
  {
    "path": "data/kaggle_house/test.csv",
    "chars": 451405,
    "preview": "Id,MSSubClass,MSZoning,LotFrontage,LotArea,Street,Alley,LotShape,LandContour,Utilities,LotConfig,LandSlope,Neighborhood,"
  },
  {
    "path": "data/kaggle_house/train.csv",
    "chars": 460676,
    "preview": "Id,MSSubClass,MSZoning,LotFrontage,LotArea,Street,Alley,LotShape,LandContour,Utilities,LotConfig,LandSlope,Neighborhood,"
  },
  {
    "path": "data/ptb/README",
    "chars": 609,
    "preview": "Data description:\n\nPenn Treebank Corpus\n    - should be free for research purposes\n    - the same processing of data as "
  },
  {
    "path": "data/ptb/ptb.test.txt",
    "chars": 449945,
    "preview": " no it was n't black monday \n but while the new york stock exchange did n't fall apart friday as the dow jones industria"
  },
  {
    "path": "data/ptb/ptb.train.txt",
    "chars": 5101618,
    "preview": " aer banknote berlitz calloway centrust cluett fromstein gitano guterman hydro-quebec ipo kia memotec mlx nahb punts rak"
  },
  {
    "path": "data/ptb/ptb.valid.txt",
    "chars": 399782,
    "preview": " consumers may want to move their telephones a little closer to the tv set \n <unk> <unk> watching abc 's monday night fo"
  },
  {
    "path": "docs/.nojekyll",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "docs/README.md",
    "chars": 8083,
    "preview": "\n<div align=center>\n<img width=\"500\" src=\"img/cover.png\" alt=\"封面\"/>\n</div>\n\n[本项目](https://tangshusen.me/Dive-into-DL-PyT"
  },
  {
    "path": "docs/_sidebar.md",
    "chars": 5620,
    "preview": "* [简介]()\n* [阅读指南](read_guide.md)\n* [1. 深度学习简介](chapter01_DL-intro/deep-learning-intro.md)\n* 2\\. 预备知识\n   * [2.1 环境配置](cha"
  },
  {
    "path": "docs/chapter01_DL-intro/deep-learning-intro.md",
    "chars": 13315,
    "preview": "# 深度学习简介\n你可能已经接触过编程,并开发过一两款程序。同时你可能读过关于深度学习或者机器学习的铺天盖地的报道,尽管很多时候它们被赋予了更广义的名字:人工智能。实际上,或者说幸运的是,大部分程序并不需要深度学习或者是更广义上的人工智能技"
  },
  {
    "path": "docs/chapter02_prerequisite/2.1_install.md",
    "chars": 1849,
    "preview": "# 2.1 环境配置\n本节简单介绍一些必要的软件的安装与配置,由于不同机器软硬件配置不同,所以不详述,遇到问题请善用Google。\n## 2.1.1 Anaconda\nAnaconda是Python的一个开源发行版本,主要面向科学计算。我们"
  },
  {
    "path": "docs/chapter02_prerequisite/2.2_tensor.md",
    "chars": 8889,
    "preview": "# 2.2 数据操作\n在深度学习中,我们通常会频繁地对数据进行操作。作为动手学深度学习的基础,本节将介绍如何对内存中的数据进行操作。\n\n在PyTorch中,`torch.Tensor`是存储和变换数据的主要工具。如果你之前用过NumPy,你"
  },
  {
    "path": "docs/chapter02_prerequisite/2.3_autograd.md",
    "chars": 6338,
    "preview": "# 2.3 自动求梯度\n在深度学习中,我们经常需要对函数求梯度(gradient)。PyTorch提供的[autograd](https://pytorch.org/docs/stable/autograd.html)包能够根据输入和前向传"
  },
  {
    "path": "docs/chapter03_DL-basics/3.10_mlp-pytorch.md",
    "chars": 1467,
    "preview": "# 3.10 多层感知机的简洁实现\n\n下面我们使用PyTorch来实现上一节中的多层感知机。首先导入所需的包或模块。\n\n``` python\nimport torch\nfrom torch import nn\nfrom torch.nn i"
  },
  {
    "path": "docs/chapter03_DL-basics/3.11_underfit-overfit.md",
    "chars": 7606,
    "preview": "# 3.11 模型选择、欠拟合和过拟合\n\n在前几节基于Fashion-MNIST数据集的实验中,我们评价了机器学习模型在训练数据集和测试数据集上的表现。如果你改变过实验中的模型结构或者超参数,你也许发现了:当模型在训练数据集上更准确时,它在"
  },
  {
    "path": "docs/chapter03_DL-basics/3.12_weight-decay.md",
    "chars": 6308,
    "preview": "# 3.12 权重衰减\n\n上一节中我们观察了过拟合现象,即模型的训练误差远小于它在测试集上的误差。虽然增大训练数据集可能会减轻过拟合,但是获取额外的训练数据往往代价高昂。本节介绍应对过拟合问题的常用方法:权重衰减(weight decay)"
  },
  {
    "path": "docs/chapter03_DL-basics/3.13_dropout.md",
    "chars": 5885,
    "preview": "# 3.13 丢弃法\n\n除了前一节介绍的权重衰减以外,深度学习模型常常使用丢弃法(dropout)[1] 来应对过拟合问题。丢弃法有一些不同的变体。本节中提到的丢弃法特指倒置丢弃法(inverted dropout)。\n\n## 3.13.1"
  },
  {
    "path": "docs/chapter03_DL-basics/3.14_backprop.md",
    "chars": 5442,
    "preview": "# 3.14 正向传播、反向传播和计算图\n\n前面几节里我们使用了小批量随机梯度下降的优化算法来训练模型。在实现中,我们只提供了模型的正向传播(forward propagation)的计算,即对输入计算模型输出,然后通过`autograd`"
  },
  {
    "path": "docs/chapter03_DL-basics/3.15_numerical-stability-and-init.md",
    "chars": 1985,
    "preview": "# 3.15 数值稳定性和模型初始化\n\n理解了正向传播与反向传播以后,我们来讨论一下深度学习模型的数值稳定性问题以及模型参数的初始化方法。深度模型有关数值稳定性的典型问题是衰减(vanishing)和爆炸(explosion)。\n\n\n## "
  },
  {
    "path": "docs/chapter03_DL-basics/3.16_kaggle-house-price.md",
    "chars": 8827,
    "preview": "# 3.16 实战Kaggle比赛:房价预测\n\n作为深度学习基础篇章的总结,我们将对本章内容学以致用。下面,让我们动手实战一个Kaggle比赛:房价预测。本节将提供未经调优的数据的预处理、模型的设计和超参数的选择。我们希望读者通过动手操作、"
  },
  {
    "path": "docs/chapter03_DL-basics/3.1_linear-regression.md",
    "chars": 7346,
    "preview": "# 3.1 线性回归\n\n线性回归输出是一个连续值,因此适用于回归问题。回归问题在实际中很常见,如预测房屋价格、气温、销售额等连续值的问题。与回归问题不同,分类问题中模型的最终输出是一个离散值。我们所说的图像分类、垃圾邮件识别、疾病检测等输出"
  },
  {
    "path": "docs/chapter03_DL-basics/3.2_linear-regression-scratch.md",
    "chars": 5843,
    "preview": "# 3.2 线性回归的从零开始实现\n\n在了解了线性回归的背景知识之后,现在我们可以动手实现它了。尽管强大的深度学习框架可以减少大量重复性工作,但若过于依赖它提供的便利,会导致我们很难深入理解深度学习是如何工作的。因此,本节将介绍如何只利用`"
  },
  {
    "path": "docs/chapter03_DL-basics/3.3_linear-regression-pytorch.md",
    "chars": 5877,
    "preview": "# 3.3 线性回归的简洁实现\n\n随着深度学习框架的发展,开发深度学习应用变得越来越便利。实践中,我们通常可以用比上一节更简洁的代码来实现同样的模型。在本节中,我们将介绍如何使用PyTorch更方便地实现线性回归的训练。\n\n## 3.3.1"
  },
  {
    "path": "docs/chapter03_DL-basics/3.4_softmax-regression.md",
    "chars": 5782,
    "preview": "# 3.4 softmax回归\n\n前几节介绍的线性回归模型适用于输出为连续值的情景。在另一类情景中,模型输出可以是一个像图像类别这样的离散值。对于这样的离散值预测问题,我们可以使用诸如softmax回归在内的分类模型。和线性回归不同,sof"
  },
  {
    "path": "docs/chapter03_DL-basics/3.5_fashion-mnist.md",
    "chars": 5033,
    "preview": "# 3.5 图像分类数据集(Fashion-MNIST)\n\n在介绍softmax回归的实现前我们先引入一个多类图像分类数据集。它将在后面的章节中被多次使用,以方便我们观察比较算法之间在模型精度和计算效率上的区别。图像分类数据集中最常用的是手"
  },
  {
    "path": "docs/chapter03_DL-basics/3.6_softmax-regression-scratch.md",
    "chars": 6074,
    "preview": "# 3.6 softmax回归的从零开始实现\n\n这一节我们来动手实现softmax回归。首先导入本节实现所需的包或模块。\n\n``` python\nimport torch\nimport torchvision\nimport numpy as"
  },
  {
    "path": "docs/chapter03_DL-basics/3.7_softmax-regression-pytorch.md",
    "chars": 2645,
    "preview": "# 3.7 softmax回归的简洁实现\n\n我们在3.3节(线性回归的简洁实现)中已经了解了使用Pytorch实现模型的便利。下面,让我们再次使用Pytorch来实现一个softmax回归模型。首先导入所需的包或模块。\n\n``` pytho"
  },
  {
    "path": "docs/chapter03_DL-basics/3.8_mlp.md",
    "chars": 4877,
    "preview": "# 3.8 多层感知机\n\n我们已经介绍了包括线性回归和softmax回归在内的单层神经网络。然而深度学习主要关注多层模型。在本节中,我们将以多层感知机(multilayer perceptron,MLP)为例,介绍多层神经网络的概念。\n\n#"
  },
  {
    "path": "docs/chapter03_DL-basics/3.9_mlp-scratch.md",
    "chars": 2501,
    "preview": "# 3.9 多层感知机的从零开始实现\n\n我们已经从上一节里了解了多层感知机的原理。下面,我们一起来动手实现一个多层感知机。首先导入实现所需的包或模块。\n\n``` python\nimport torch\nimport numpy as np\n"
  },
  {
    "path": "docs/chapter04_DL_computation/4.1_model-construction.md",
    "chars": 8486,
    "preview": "# 4.1 模型构造\n\n让我们回顾一下在3.10节(多层感知机的简洁实现)中含单隐藏层的多层感知机的实现方法。我们首先构造`Sequential`实例,然后依次添加两个全连接层。其中第一层的输出大小为256,即隐藏层单元个数是256;第二层"
  },
  {
    "path": "docs/chapter04_DL_computation/4.2_parameters.md",
    "chars": 5514,
    "preview": "# 4.2 模型参数的访问、初始化和共享\n\n在3.3节(线性回归的简洁实现)中,我们通过`init`模块来初始化模型的参数。我们也介绍了访问模型参数的简单方法。本节将深入讲解如何访问和初始化模型参数,以及如何在多个层之间共享同一份模型参数。"
  },
  {
    "path": "docs/chapter04_DL_computation/4.3_deferred-init.md",
    "chars": 305,
    "preview": "# 4.3 模型参数的延后初始化\n\n由于使用Gluon创建的全连接层的时候不需要指定输入个数。所以当调用`initialize`函数时,由于隐藏层输入个数依然未知,系统也无法得知该层权重参数的形状。只有在当形状已知的输入`X`传进网络做前向"
  },
  {
    "path": "docs/chapter04_DL_computation/4.4_custom-layer.md",
    "chars": 4227,
    "preview": "# 4.4 自定义层\n\n深度学习的一个魅力在于神经网络中各式各样的层,例如全连接层和后面章节中将要介绍的卷积层、池化层与循环层。虽然PyTorch提供了大量常用的层,但有时候我们依然希望自定义层。本节将介绍如何使用`Module`来自定义层"
  },
  {
    "path": "docs/chapter04_DL_computation/4.5_read-write.md",
    "chars": 3166,
    "preview": "# 4.5 读取和存储\n\n到目前为止,我们介绍了如何处理数据以及如何构建、训练和测试深度学习模型。然而在实际中,我们有时需要把训练好的模型部署到很多不同的设备。在这种情况下,我们可以把内存中训练好的模型参数存储在硬盘上供后续读取使用。\n\n\n"
  },
  {
    "path": "docs/chapter04_DL_computation/4.6_use-gpu.md",
    "chars": 4105,
    "preview": "# 4.6 GPU计算\n\n到目前为止,我们一直在使用CPU计算。对复杂的神经网络和大规模的数据来说,使用CPU来计算可能不够高效。在本节中,我们将介绍如何使用单块NVIDIA GPU来计算。所以需要确保已经安装好了PyTorch GPU版本"
  },
  {
    "path": "docs/chapter05_CNN/5.10_batch-norm.md",
    "chars": 8932,
    "preview": "# 5.10 批量归一化\n\n本节我们介绍批量归一化(batch normalization)层,它能让较深的神经网络的训练变得更加容易 [1]。在3.16节(实战Kaggle比赛:预测房价)里,我们对输入数据做了标准化处理:处理后的任意一个"
  },
  {
    "path": "docs/chapter05_CNN/5.11_resnet.md",
    "chars": 6268,
    "preview": "# 5.11 残差网络(ResNet)\n\n让我们先思考一个问题:对神经网络模型添加新的层,充分训练后的模型是否只可能更有效地降低训练误差?理论上,原模型解的空间只是新模型解的空间的子空间。也就是说,如果我们能将新添加的层训练成恒等映射$f("
  },
  {
    "path": "docs/chapter05_CNN/5.12_densenet.md",
    "chars": 6000,
    "preview": "# 5.12 稠密连接网络(DenseNet)\n\nResNet中的跨层连接设计引申出了数个后续工作。本节我们介绍其中的一个:稠密连接网络(DenseNet) [1]。 它与ResNet的主要区别如图5.10所示。\n\n<div align=c"
  },
  {
    "path": "docs/chapter05_CNN/5.1_conv-layer.md",
    "chars": 5167,
    "preview": "# 5.1 二维卷积层\n\n卷积神经网络(convolutional neural network)是含有卷积层(convolutional layer)的神经网络。本章中介绍的卷积神经网络均使用最常见的二维卷积层。它有高和宽两个空间维度,常"
  },
  {
    "path": "docs/chapter05_CNN/5.2_padding-and-strides.md",
    "chars": 3340,
    "preview": "# 5.2 填充和步幅\n\n在上一节的例子里,我们使用高和宽为3的输入与高和宽为2的卷积核得到高和宽为2的输出。一般来说,假设输入形状是$n_h\\times n_w$,卷积核窗口形状是$k_h\\times k_w$,那么输出形状将会是\n\n$$"
  },
  {
    "path": "docs/chapter05_CNN/5.3_channels.md",
    "chars": 3844,
    "preview": "# 5.3 多输入通道和多输出通道\n\n前面两节里我们用到的输入和输出都是二维数组,但真实数据的维度经常更高。例如,彩色图像在高和宽2个维度外还有RGB(红、绿、蓝)3个颜色通道。假设彩色图像的高和宽分别是$h$和$w$(像素),那么它可以表"
  },
  {
    "path": "docs/chapter05_CNN/5.4_pooling.md",
    "chars": 3779,
    "preview": "# 5.4 池化层\n\n回忆一下,在5.1节(二维卷积层)里介绍的图像物体边缘检测应用中,我们构造卷积核从而精确地找到了像素变化的位置。设任意二维数组`X`的`i`行`j`列的元素为`X[i, j]`。如果我们构造的卷积核输出`Y[i, j]"
  },
  {
    "path": "docs/chapter05_CNN/5.5_lenet.md",
    "chars": 6294,
    "preview": "# 5.5 卷积神经网络(LeNet)\n\n在3.9节(多层感知机的从零开始实现)里我们构造了一个含单隐藏层的多层感知机模型来对Fashion-MNIST数据集中的图像进行分类。每张图像高和宽均是28像素。我们将图像中的像素逐行展开,得到长度"
  },
  {
    "path": "docs/chapter05_CNN/5.6_alexnet.md",
    "chars": 7877,
    "preview": "# 5.6 深度卷积神经网络(AlexNet)\n\n在LeNet提出后的将近20年里,神经网络一度被其他机器学习方法超越,如支持向量机。虽然LeNet可以在早期的小数据集上取得好的成绩,但是在更大的真实数据集上的表现并不尽如人意。一方面,神经"
  },
  {
    "path": "docs/chapter05_CNN/5.7_vgg.md",
    "chars": 6482,
    "preview": "# 5.7 使用重复元素的网络(VGG)\n\nAlexNet在LeNet的基础上增加了3个卷积层。但AlexNet作者对它们的卷积窗口、输出通道数和构造顺序均做了大量的调整。虽然AlexNet指明了深度卷积神经网络可以取得出色的结果,但并没有"
  },
  {
    "path": "docs/chapter05_CNN/5.8_nin.md",
    "chars": 4310,
    "preview": "# 5.8 网络中的网络(NiN)\n\n前几节介绍的LeNet、AlexNet和VGG在设计上的共同之处是:先以由卷积层构成的模块充分抽取空间特征,再以由全连接层构成的模块来输出分类结果。其中,AlexNet和VGG对LeNet的改进主要在于"
  },
  {
    "path": "docs/chapter05_CNN/5.9_googlenet.md",
    "chars": 6876,
    "preview": "# 5.9 含并行连结的网络(GoogLeNet)\n\n在2014年的ImageNet图像识别挑战赛中,一个名叫GoogLeNet的网络结构大放异彩 [1]。它虽然在名字上向LeNet致敬,但在网络结构上已经很难看到LeNet的影子。Goog"
  },
  {
    "path": "docs/chapter06_RNN/6.10_bi-rnn.md",
    "chars": 1983,
    "preview": "# 6.10 双向循环神经网络\n\n之前介绍的循环神经网络模型都是假设当前时间步是由前面的较早时间步的序列决定的,因此它们都将信息通过隐藏状态从前往后传递。有时候,当前时间步也可能由后面时间步决定。例如,当我们写下一个句子时,可能会根据句子后"
  },
  {
    "path": "docs/chapter06_RNN/6.1_lang-model.md",
    "chars": 2308,
    "preview": "# 6.1 语言模型\n\n语言模型(language model)是自然语言处理的重要技术。自然语言处理中最常见的数据是文本数据。我们可以把一段自然语言文本看作一段离散的时间序列。假设一段长度为$T$的文本中的词依次为$w_1, w_2, \\"
  },
  {
    "path": "docs/chapter06_RNN/6.2_rnn.md",
    "chars": 4653,
    "preview": "# 6.2 循环神经网络\n\n上一节介绍的$n$元语法中,时间步$t$的词$w_t$基于前面所有词的条件概率只考虑了最近时间步的$n-1$个词。如果要考虑比$t-(n-1)$更早时间步的词对$w_t$的可能影响,我们需要增大$n$。但这样模型"
  },
  {
    "path": "docs/chapter06_RNN/6.3_lang-model-dataset.md",
    "chars": 5194,
    "preview": "# 6.3 语言模型数据集(周杰伦专辑歌词)\n\n本节将介绍如何预处理一个语言模型数据集,并将其转换成字符级循环神经网络所需要的输入格式。为此,我们收集了周杰伦从第一张专辑《Jay》到第十张专辑《跨时代》中的歌词,并在后面几节里应用循环神经网"
  },
  {
    "path": "docs/chapter06_RNN/6.4_rnn-scratch.md",
    "chars": 10901,
    "preview": "# 6.4 循环神经网络的从零开始实现\n\n在本节中,我们将从零开始实现一个基于字符级循环神经网络的语言模型,并在周杰伦专辑歌词数据集上训练一个模型来进行歌词创作。首先,我们读取周杰伦专辑歌词数据集:\n\n``` python\nimport t"
  },
  {
    "path": "docs/chapter06_RNN/6.5_rnn-pytorch.md",
    "chars": 7347,
    "preview": "# 6.5 循环神经网络的简洁实现\n\n本节将使用PyTorch来更简洁地实现基于循环神经网络的语言模型。首先,我们读取周杰伦专辑歌词数据集。\n\n``` python\nimport time\nimport math\nimport numpy "
  },
  {
    "path": "docs/chapter06_RNN/6.6_bptt.md",
    "chars": 5406,
    "preview": "# 6.6 通过时间反向传播\n\n在前面两节中,如果不裁剪梯度,模型将无法正常训练。为了深刻理解这一现象,本节将介绍循环神经网络中梯度的计算和存储方法,即通过时间反向传播(back-propagation through time)。\n\n我们"
  },
  {
    "path": "docs/chapter06_RNN/6.7_gru.md",
    "chars": 8587,
    "preview": "# 6.7 门控循环单元(GRU)\n\n上一节介绍了循环神经网络中的梯度计算方法。我们发现,当时间步数较大或者时间步较小时,循环神经网络的梯度较容易出现衰减或爆炸。虽然裁剪梯度可以应对梯度爆炸,但无法解决梯度衰减的问题。通常由于这个原因,循环"
  },
  {
    "path": "docs/chapter06_RNN/6.8_lstm.md",
    "chars": 8584,
    "preview": "# 6.8 长短期记忆(LSTM)\n\n本节将介绍另一种常用的门控循环神经网络:长短期记忆(long short-term memory,LSTM)[1]。它比门控循环单元的结构稍微复杂一点。\n\n## 6.8.1 长短期记忆\n\nLSTM 中引"
  },
  {
    "path": "docs/chapter06_RNN/6.9_deep-rnn.md",
    "chars": 1815,
    "preview": "# 6.9 深度循环神经网络\n\n本章到目前为止介绍的循环神经网络只有一个单向的隐藏层,在深度学习应用里,我们通常会用到含有多个隐藏层的循环神经网络,也称作深度循环神经网络。图6.11演示了一个有$L$个隐藏层的深度循环神经网络,每个隐藏状态"
  },
  {
    "path": "docs/chapter07_optimization/7.1_optimization-intro.md",
    "chars": 3572,
    "preview": "# 7.1 优化与深度学习\n\n本节将讨论优化与深度学习的关系,以及优化在深度学习中的挑战。在一个深度学习问题中,我们通常会预先定义一个损失函数。有了损失函数以后,我们就可以使用优化算法试图将其最小化。在优化中,这样的损失函数通常被称作优化问"
  },
  {
    "path": "docs/chapter07_optimization/7.2_gd-sgd.md",
    "chars": 7355,
    "preview": "# 7.2 梯度下降和随机梯度下降\n\n在本节中,我们将介绍梯度下降(gradient descent)的工作原理。虽然梯度下降在深度学习中很少被直接使用,但理解梯度的意义以及沿着梯度反方向更新自变量可能降低目标函数值的原因是学习后续优化算法"
  },
  {
    "path": "docs/chapter07_optimization/7.3_minibatch-sgd.md",
    "chars": 7054,
    "preview": "# 7.3 小批量随机梯度下降\n\n在每一次迭代中,梯度下降使用整个训练数据集来计算梯度,因此它有时也被称为批量梯度下降(batch gradient descent)。而随机梯度下降在每次迭代中只随机采样一个样本来计算梯度。正如我们在前几章"
  },
  {
    "path": "docs/chapter07_optimization/7.4_momentum.md",
    "chars": 6354,
    "preview": "# 7.4 动量法\n\n在7.2节(梯度下降和随机梯度下降)中我们提到,目标函数有关自变量的梯度代表了目标函数在自变量当前位置下降最快的方向。因此,梯度下降也叫作最陡下降(steepest descent)。在每次迭代中,梯度下降根据自变量当"
  },
  {
    "path": "docs/chapter07_optimization/7.5_adagrad.md",
    "chars": 3873,
    "preview": "# 7.5 AdaGrad算法\n\n在之前介绍过的优化算法中,目标函数自变量的每一个元素在相同时间步都使用同一个学习率来自我迭代。举个例子,假设目标函数为$f$,自变量为一个二维向量$[x_1, x_2]^\\top$,该向量中每一个元素在迭代"
  },
  {
    "path": "docs/chapter07_optimization/7.6_rmsprop.md",
    "chars": 3437,
    "preview": "# 7.6 RMSProp算法\n\n我们在7.5节(AdaGrad算法)中提到,因为调整学习率时分母上的变量$\\boldsymbol{s}_t$一直在累加按元素平方的小批量随机梯度,所以目标函数自变量每个元素的学习率在迭代过程中一直在降低(或"
  },
  {
    "path": "docs/chapter07_optimization/7.7_adadelta.md",
    "chars": 2862,
    "preview": "# 7.7 AdaDelta算法\n\n除了RMSProp算法以外,另一个常用优化算法AdaDelta算法也针对AdaGrad算法在迭代后期可能较难找到有用解的问题做了改进 [1]。有意思的是,**AdaDelta算法没有学习率这一超参数**。"
  },
  {
    "path": "docs/chapter07_optimization/7.8_adam.md",
    "chars": 3538,
    "preview": "# 7.8 Adam算法\n\nAdam算法在RMSProp算法基础上对小批量随机梯度也做了指数加权移动平均 [1]。下面我们来介绍这个算法。\n> 所以Adam算法可以看做是RMSProp算法与动量法的结合。\n\n## 7.8.1 算法\n\nAda"
  },
  {
    "path": "docs/chapter08_computational-performance/8.1_hybridize.md",
    "chars": 1983,
    "preview": "# 8.1 命令式和符号式混合编程\n\n本书到目前为止一直都在使用命令式编程,它使用编程语句改变程序状态。考虑下面这段简单的命令式程序。\n\n``` python\ndef add(a, b):\n    return a + b\n\ndef fan"
  },
  {
    "path": "docs/chapter08_computational-performance/8.2_async-computation.md",
    "chars": 1537,
    "preview": "# 8.2 异步计算\n\n此节内容对应PyTorch的版本本人没怎么用过,网上参考资料也比较少,所以略:),有兴趣的可以去看看[原文](https://zh.d2l.ai/chapter_computational-performance/a"
  },
  {
    "path": "docs/chapter08_computational-performance/8.3_auto-parallelism.md",
    "chars": 1527,
    "preview": "# 8.3 自动并行计算\n\n上一节提到,默认情况下,GPU 操作是异步的。当调用一个使用 GPU 的函数时,这些操作会在特定的设备上排队,但不一定会在稍后执行。这允许我们并行更多的计算,包括 CPU 或其他 GPU 上的操作。\n下面看一个简"
  },
  {
    "path": "docs/chapter08_computational-performance/8.4_multiple-gpus.md",
    "chars": 5154,
    "preview": "# 8.4 多GPU计算\n> 注:相对于本章的前面几节,我们实际中更可能遇到本节所讨论的情况:多GPU计算。原书将MXNet的多GPU计算分成了8.4和8.5两节,但我们将关于PyTorch的多GPU计算统一放在本节讨论。\n需要注意的是,这"
  },
  {
    "path": "docs/chapter09_computer-vision/9.11_neural-style.md",
    "chars": 15007,
    "preview": "# 9.11 样式迁移\n\n如果你是一位摄影爱好者,也许接触过滤镜。它能改变照片的颜色样式,从而使风景照更加锐利或者令人像更加美白。但一个滤镜通常只能改变照片的某个方面。如果要照片达到理想中的样式,经常需要尝试大量不同的组合,其复杂程度不亚于"
  },
  {
    "path": "docs/chapter09_computer-vision/9.1_image-augmentation.md",
    "chars": 8004,
    "preview": "# 9.1 图像增广\n\n在5.6节(深度卷积神经网络)里我们提到过,大规模数据集是成功应用深度神经网络的前提。图像增广(image augmentation)技术通过对训练图像做一系列随机改变,来产生相似但又不同的训练样本,从而扩大训练数据"
  },
  {
    "path": "docs/chapter09_computer-vision/9.2_fine-tuning.md",
    "chars": 7639,
    "preview": "# 9.2 微调\n\n在前面的一些章节中,我们介绍了如何在只有6万张图像的Fashion-MNIST训练数据集上训练模型。我们还描述了学术界当下使用最广泛的大规模图像数据集ImageNet,它有超过1,000万的图像和1,000类的物体。然而"
  },
  {
    "path": "docs/chapter09_computer-vision/9.3_bounding-box.md",
    "chars": 1797,
    "preview": "# 9.3 目标检测和边界框\n\n在前面的一些章节中,我们介绍了诸多用于图像分类的模型。在图像分类任务里,我们假设图像里只有一个主体目标,并关注如何识别该目标的类别。然而,很多时候图像里有多个我们感兴趣的目标,我们不仅想知道它们的类别,还想得"
  },
  {
    "path": "docs/chapter09_computer-vision/9.4_anchor.md",
    "chars": 22129,
    "preview": "# 9.4 锚框\n\n目标检测算法通常会在输入图像中采样大量的区域,然后判断这些区域中是否包含我们感兴趣的目标,并调整区域边缘从而更准确地预测目标的真实边界框(ground-truth bounding box)。不同的模型使用的区域采样方法"
  },
  {
    "path": "docs/chapter09_computer-vision/9.5_multiscale-object-detection.md",
    "chars": 3311,
    "preview": "# 9.5 多尺度目标检测\n\n在9.4节(锚框)中,我们在实验中以输入图像的每个像素为中心生成多个锚框。这些锚框是对输入图像不同区域的采样。然而,如果以图像每个像素为中心都生成锚框,很容易生成过多锚框而造成计算量过大。举个例子,假设输入图像"
  },
  {
    "path": "docs/chapter09_computer-vision/9.6_object-detection-dataset.md",
    "chars": 4867,
    "preview": "# 9.6 目标检测数据集(皮卡丘)\n\n在目标检测领域并没有类似MNIST或Fashion-MNIST那样的小数据集。为了快速测试模型,我们合成了一个小的数据集。我们首先使用一个开源的皮卡丘3D模型生成了1000张不同角度和大小的皮卡丘图像"
  },
  {
    "path": "docs/chapter09_computer-vision/9.8_rcnn.md",
    "chars": 5658,
    "preview": "# 9.8 区域卷积神经网络(R-CNN)系列\n\n\n区域卷积神经网络(region-based CNN或regions with CNN features,R-CNN)是将深度模型应用于目标检测的开创性工作之一 [1]。在本节中,我们将介绍"
  },
  {
    "path": "docs/chapter09_computer-vision/9.9_semantic-segmentation-and-dataset.md",
    "chars": 8770,
    "preview": "# 9.9 语义分割和数据集\n\n在前几节讨论的目标检测问题中,我们一直使用方形边界框来标注和预测图像中的目标。本节将探讨语义分割(semantic segmentation)问题,它关注如何将图像分割成属于不同语义类别的区域。值得一提的是,"
  },
  {
    "path": "docs/chapter10_natural-language-processing/10.10_beam-search.md",
    "chars": 3839,
    "preview": "# 10.10 束搜索\n\n上一节介绍了如何训练输入和输出均为不定长序列的编码器—解码器。本节我们介绍如何使用编码器—解码器来预测不定长的序列。\n\n上一节里已经提到,在准备训练数据集时,我们通常会在样本的输入序列和输出序列后面分别附上一个特殊"
  },
  {
    "path": "docs/chapter10_natural-language-processing/10.11_attention.md",
    "chars": 5542,
    "preview": "# 10.11 注意力机制\n\n在10.9节(编码器—解码器(seq2seq))里,解码器在各个时间步依赖相同的背景变量来获取输入序列信息。当编码器为循环神经网络时,背景变量来自它最终时间步的隐藏状态。\n\n现在,让我们再次思考那一节提到的翻译"
  },
  {
    "path": "docs/chapter10_natural-language-processing/10.12_machine-translation.md",
    "chars": 13336,
    "preview": "# 10.12 机器翻译\n\n机器翻译是指将一段文本从一种语言自动翻译到另一种语言。因为一段文本序列在不同语言中的长度不一定相同,所以我们使用机器翻译为例来介绍编码器—解码器和注意力机制的应用。\n\n## 10.12.1 读取和预处理数据\n\n我"
  },
  {
    "path": "docs/chapter10_natural-language-processing/10.1_word2vec.md",
    "chars": 6711,
    "preview": "# 10.1 词嵌入(word2vec)\n> 注:个人觉得本节和下一节写得过于简洁,对于初学者来说可能比较难懂。所以强烈推荐读一读博客[Word2Vec-知其然知其所以然](https://www.zybuluo.com/Dounm/not"
  },
  {
    "path": "docs/chapter10_natural-language-processing/10.2_approx-training.md",
    "chars": 3851,
    "preview": "# 10.2 近似训练\n\n回忆上一节的内容。跳字模型的核心在于使用softmax运算得到给定中心词$w_c$来生成背景词$w_o$的条件概率\n\n$$P(w_o \\mid w_c) = \\frac{\\text{exp}(\\boldsymbol"
  },
  {
    "path": "docs/chapter10_natural-language-processing/10.3_word2vec-pytorch.md",
    "chars": 15300,
    "preview": "# 10.3 word2vec的实现\n\n本节是对前两节内容的实践。我们以10.1节(词嵌入word2vec)中的跳字模型和10.2节(近似训练)中的负采样为例,介绍在语料库上训练词嵌入模型的实现。我们还会介绍一些实现中的技巧,如二次采样(s"
  },
  {
    "path": "docs/chapter10_natural-language-processing/10.4_fasttext.md",
    "chars": 1488,
    "preview": "# 10.4 子词嵌入(fastText)\n\n英语单词通常有其内部结构和形成方式。例如,我们可以从“dog”“dogs”和“dogcatcher”的字面上推测它们的关系。这些词都有同一个词根“dog”,但使用不同的后缀来改变词的含义。而且,"
  },
  {
    "path": "docs/chapter10_natural-language-processing/10.5_glove.md",
    "chars": 4858,
    "preview": "# 10.5 全局向量的词嵌入(GloVe)\n\n让我们先回顾一下word2vec中的跳字模型。将跳字模型中使用softmax运算表达的条件概率$P(w_j\\mid w_i)$记作$q_{ij}$,即\n\n$$\nq_{ij}=\\frac{\\ex"
  },
  {
    "path": "docs/chapter10_natural-language-processing/10.6_similarity-analogy.md",
    "chars": 4564,
    "preview": "# 10.6 求近义词和类比词\n\n在10.3节(word2vec的实现)中,我们在小规模数据集上训练了一个word2vec词嵌入模型,并通过词向量的余弦相似度搜索近义词。实际中,在大规模语料上预训练的词向量常常可以应用到下游自然语言处理任务"
  },
  {
    "path": "docs/chapter10_natural-language-processing/10.7_sentiment-analysis-rnn.md",
    "chars": 8053,
    "preview": "# 10.7 文本情感分类:使用循环神经网络\n\n文本分类是自然语言处理的一个常见任务,它把一段不定长的文本序列变换为文本的类别。本节关注它的一个子问题:使用文本情感分类来分析文本作者的情绪。这个问题也叫情感分析,并有着广泛的应用。例如,我们"
  },
  {
    "path": "docs/chapter10_natural-language-processing/10.8_sentiment-analysis-cnn.md",
    "chars": 7912,
    "preview": "# 10.8 文本情感分类:使用卷积神经网络(textCNN)\n\n在“卷积神经网络”一章中我们探究了如何使用二维卷积神经网络来处理二维图像数据。在之前的语言模型和文本分类任务中,我们将文本数据看作是只有一个维度的时间序列,并很自然地使用循环"
  },
  {
    "path": "docs/chapter10_natural-language-processing/10.9_seq2seq.md",
    "chars": 3598,
    "preview": "# 10.9 编码器—解码器(seq2seq)\n\n我们已经在前两节中表征并变换了不定长的输入序列。但在自然语言处理的很多应用中,输入和输出都可以是不定长序列。以机器翻译为例,输入可以是一段不定长的英语文本序列,输出可以是一段不定长的法语文本"
  },
  {
    "path": "docs/docsify.js",
    "chars": 152347,
    "preview": "(function () {\n    /**\n     * Create a cached version of a pure function.\n     */\n    function cached(fn) {\n      var ca"
  },
  {
    "path": "docs/index.html",
    "chars": 2847,
    "preview": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <title>Dive-into-DL-PyTorch</title>\n  <meta http-equi"
  },
  {
    "path": "docs/read_guide.md",
    "chars": 649,
    "preview": "# 阅读指南\n和原书一样,docs内容大体可以分为3个部分:\n* 第一部分(第1章至第3章)涵盖预备工作和基础知识。第1章介绍深度学习的背景。第2章提供动手学深度学习所需要的预备知识。第3章包括深度学习最基础的概念和技术,如多层感知机和模型"
  }
]

// ... and 1 more files (download for full content)

About this extraction

This page contains the full source code of the ShusenTang/Dive-into-DL-PyTorch GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 168 files (12.3 MB), approximately 3.2M tokens, and a symbol index with 169 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!