{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 0
   },
   "source": [
    "# Deep Convolutional Neural Networks (AlexNet)\n",
    ":label:`sec_alexnet`\n",
    "\n",
    "\n",
    "Although CNNs were well known\n",
    "in the computer vision and machine learning communities\n",
    "following the introduction of LeNet,\n",
    "they did not immediately dominate the field.\n",
    "Although LeNet achieved good results on early small datasets,\n",
    "the performance and feasibility of training CNNs\n",
    "on larger, more realistic datasets had yet to be established.\n",
    "In fact, for much of the intervening time between the early 1990s\n",
    "and the watershed results of 2012,\n",
    "neural networks were often surpassed by other machine learning methods,\n",
    "such as support vector machines.\n",
    "\n",
    "\n",
    "For computer vision, this comparison is perhaps not fair.\n",
    "That is although the inputs to convolutional networks\n",
    "consist of raw or lightly-processed (e.g., by centering) pixel values, practitioners would never feed raw pixels into traditional models.\n",
    "Instead, typical computer vision pipelines\n",
    "consisted of manually engineering feature extraction pipelines.\n",
    "Rather than *learn the features*, the features were *crafted*.\n",
    "Most of the progress came from having more clever ideas for features,\n",
    "and the learning algorithm was often relegated to an afterthought.\n",
    "\n",
    "Although some neural network accelerators were available in the 1990s,\n",
    "they were not yet sufficiently powerful to make\n",
    "deep multichannel, multilayer CNNs\n",
    "with a large number of parameters.\n",
    "Moreover, datasets were still relatively small.\n",
    "Added to these obstacles, key tricks for training neural networks\n",
    "including parameter initialization heuristics,\n",
    "clever variants of stochastic gradient descent,\n",
    "non-squashing activation functions,\n",
    "and effective regularization techniques were still missing.\n",
    "\n",
    "Thus, rather than training *end-to-end* (pixel to classification) systems,\n",
    "classical pipelines looked more like this:\n",
    "\n",
    "1. Obtain an interesting dataset. In early days, these datasets required expensive sensors (at the time, 1 megapixel images were state-of-the-art).\n",
    "2. Preprocess the dataset with hand-crafted features based on some knowledge of optics, geometry, other analytic tools, and occasionally on the serendipitous discoveries of lucky graduate students.\n",
    "3. Feed the data through a standard set of feature extractors such as the SIFT (scale-invariant feature transform) :cite:`Lowe.2004`, the SURF (speeded up robust features) :cite:`Bay.Tuytelaars.Van-Gool.2006`, or any number of other hand-tuned pipelines.\n",
    "4. Dump the resulting representations into your favorite classifier, likely a linear model or kernel method, to train a classifier.\n",
    "\n",
    "If you spoke to machine learning researchers,\n",
    "they believed that machine learning was both important and beautiful.\n",
    "Elegant theories proved the properties of various classifiers.\n",
    "The field of machine learning was thriving, rigorous, and eminently useful. However, if you spoke to a computer vision researcher,\n",
    "you would hear a very different story.\n",
    "The dirty truth of image recognition, they would tell you,\n",
    "is that features, not learning algorithms, drove progress.\n",
    "Computer vision researchers justifiably believed\n",
    "that a slightly bigger or cleaner dataset\n",
    "or a slightly improved feature-extraction pipeline\n",
    "mattered far more to the final accuracy than any learning algorithm.\n",
    "\n",
    "## Learning Representations\n",
    "\n",
    "Another way to cast the state of affairs is that\n",
    "the most important part of the pipeline was the representation.\n",
    "And up until 2012 the representation was calculated mechanically.\n",
    "In fact, engineering a new set of feature functions, improving results, and writing up the method was a prominent genre of paper.\n",
    "SIFT :cite:`Lowe.2004`,\n",
    "SURF :cite:`Bay.Tuytelaars.Van-Gool.2006`,\n",
    "HOG (histograms of oriented gradient) :cite:`Dalal.Triggs.2005`,\n",
    "[bags of visual words](https://en.wikipedia.org/wiki/Bag-of-words_model_in_computer_vision)\n",
    "and similar feature extractors ruled the roost.\n",
    "\n",
    "Another group of researchers,\n",
    "including Yann LeCun, Geoff Hinton, Yoshua Bengio,\n",
    "Andrew Ng, Shun-ichi Amari, and Juergen Schmidhuber,\n",
    "had different plans.\n",
    "They believed that features themselves ought to be learned.\n",
    "Moreover, they believed that to be reasonably complex,\n",
    "the features ought to be hierarchically composed\n",
    "with multiple jointly learned layers, each with learnable parameters.\n",
    "In the case of an image, the lowest layers might come\n",
    "to detect edges, colors, and textures.\n",
    "Indeed,\n",
    "Alex Krizhevsky, Ilya Sutskever, and Geoff Hinton\n",
    "proposed a new variant of a CNN,\n",
    "*AlexNet*,\n",
    "that achieved excellent performance in the 2012 ImageNet challenge.\n",
    "AlexNet was named after Alex Krizhevsky,\n",
    "the first author of the breakthrough ImageNet classification paper :cite:`Krizhevsky.Sutskever.Hinton.2012`.\n",
    "\n",
    "Interestingly in the lowest layers of the network,\n",
    "the model learned feature extractors that resembled some traditional filters.\n",
    ":numref:`fig_filters` is reproduced from the AlexNet paper :cite:`Krizhevsky.Sutskever.Hinton.2012`\n",
    "and describes lower-level image descriptors.\n",
    "\n",
    "![Image filters learned by the first layer of AlexNet.](../img/filters.png)\n",
    ":width:`400px`\n",
    ":label:`fig_filters`\n",
    "\n",
    "Higher layers in the network might build upon these representations\n",
    "to represent larger structures, like eyes, noses, blades of grass, and so on.\n",
    "Even higher layers might represent whole objects\n",
    "like people, airplanes, dogs, or frisbees.\n",
    "Ultimately, the final hidden state learns a compact representation\n",
    "of the image that summarizes its contents\n",
    "such that data belonging to different categories can be easily separated.\n",
    "\n",
    "While the ultimate breakthrough for many-layered CNNs\n",
    "came in 2012, a core group of researchers had dedicated themselves\n",
    "to this idea, attempting to learn hierarchical representations of visual data\n",
    "for many years.\n",
    "The ultimate breakthrough in 2012 can be attributed to two key factors.\n",
    "\n",
    "### Missing Ingredient: Data\n",
    "\n",
    "Deep models with many layers require large amounts of data\n",
    "in order to enter the regime\n",
    "where they significantly outperform traditional methods\n",
    "based on convex optimizations (e.g., linear and kernel methods).\n",
    "However, given the limited storage capacity of computers,\n",
    "the relative expense of sensors,\n",
    "and the comparatively tighter research budgets in the 1990s,\n",
    "most research relied on tiny datasets.\n",
    "Numerous papers addressed the UCI collection of datasets,\n",
    "many of which contained only hundreds or (a few) thousands of images\n",
    "captured in unnatural settings with low resolution.\n",
    "\n",
    "In 2009, the ImageNet dataset was released,\n",
    "challenging researchers to learn models from 1 million examples,\n",
    "1000 each from 1000 distinct categories of objects.\n",
    "The researchers, led by Fei-Fei Li, who introduced this dataset\n",
    "leveraged Google Image Search to prefilter large candidate sets\n",
    "for each category and employed\n",
    "the Amazon Mechanical Turk crowdsourcing pipeline\n",
    "to confirm for each image whether it belonged to the associated category.\n",
    "This scale was unprecedented.\n",
    "The associated competition, dubbed the ImageNet Challenge\n",
    "pushed computer vision and machine learning research forward,\n",
    "challenging researchers to identify which models performed best\n",
    "at a greater scale than academics had previously considered.\n",
    "\n",
    "### Missing Ingredient: Hardware\n",
    "\n",
    "Deep learning models are voracious consumers of compute cycles.\n",
    "Training can take hundreds of epochs, and each iteration\n",
    "requires passing data through many layers of computationally-expensive\n",
    "linear algebra operations.\n",
    "This is one of the main reasons why in the 1990s and early 2000s,\n",
    "simple algorithms based on the more-efficiently optimized\n",
    "convex objectives were preferred.\n",
    "\n",
    "*Graphical processing units* (GPUs) proved to be a game changer\n",
    "in making deep learning feasible.\n",
    "These chips had long been developed for accelerating\n",
    "graphics processing to benefit computer games.\n",
    "In particular, they were optimized for high throughput $4 \\times 4$ matrix-vector products, which are needed for many computer graphics tasks.\n",
    "Fortunately, this math is strikingly similar\n",
    "to that required to calculate convolutional layers.\n",
    "Around that time, NVIDIA and ATI had begun optimizing GPUs\n",
    "for general computing operations,\n",
    "going as far as to market them as *general-purpose GPUs* (GPGPU).\n",
    "\n",
    "To provide some intuition, consider the cores of a modern microprocessor\n",
    "(CPU).\n",
    "Each of the cores is fairly powerful running at a high clock frequency\n",
    "and sporting large caches (up to several megabytes of L3).\n",
    "Each core is well-suited to executing a wide range of instructions,\n",
    "with branch predictors, a deep pipeline, and other bells and whistles\n",
    "that enable it to run a large variety of programs.\n",
    "This apparent strength, however, is also its Achilles heel:\n",
    "general-purpose cores are very expensive to build.\n",
    "They require lots of chip area,\n",
    "a sophisticated support structure\n",
    "(memory interfaces, caching logic between cores,\n",
    "high-speed interconnects, and so on),\n",
    "and they are comparatively bad at any single task.\n",
    "Modern laptops have up to 4 cores,\n",
    "and even high-end servers rarely exceed 64 cores,\n",
    "simply because it is not cost effective.\n",
    "\n",
    "By comparison, GPUs consist of $100 \\sim 1000$ small processing elements\n",
    "(the details differ somewhat between NVIDIA, ATI, ARM and other chip vendors),\n",
    "often grouped into larger groups (NVIDIA calls them warps).\n",
    "While each core is relatively weak,\n",
    "sometimes even running at sub-1GHz clock frequency,\n",
    "it is the total number of such cores that makes GPUs orders of magnitude faster than CPUs.\n",
    "For instance, NVIDIA's recent Volta generation offers up to 120 TFlops per chip for specialized instructions\n",
    "(and up to 24 TFlops for more general-purpose ones),\n",
    "while floating point performance of CPUs has not exceeded 1 TFlop to date.\n",
    "The reason for why this is possible is actually quite simple:\n",
    "first, power consumption tends to grow *quadratically* with clock frequency.\n",
    "Hence, for the power budget of a CPU core that runs 4 times faster (a typical number),\n",
    "you can use 16 GPU cores at $1/4$ the speed,\n",
    "which yields $16 \\times 1/4 = 4$ times the performance.\n",
    "Furthermore, GPU cores are much simpler\n",
    "(in fact, for a long time they were not even *able*\n",
    "to execute general-purpose code),\n",
    "which makes them more energy efficient.\n",
    "Last, many operations in deep learning require high memory bandwidth.\n",
    "Again, GPUs shine here with buses that are at least 10 times as wide as many CPUs.\n",
    "\n",
    "Back to 2012. A major breakthrough came\n",
    "when Alex Krizhevsky and Ilya Sutskever\n",
    "implemented a deep CNN\n",
    "that could run on GPU hardware.\n",
    "They realized that the computational bottlenecks in CNNs,\n",
    "convolutions and matrix multiplications,\n",
    "are all operations that could be parallelized in hardware.\n",
    "Using two NVIDIA GTX 580s with 3GB of memory,\n",
    "they implemented fast convolutions.\n",
    "The code [cuda-convnet](https://code.google.com/archive/p/cuda-convnet/)\n",
    "was good enough that for several years\n",
    "it was the industry standard and powered\n",
    "the first couple years of the deep learning boom.\n",
    "\n",
    "## AlexNet\n",
    "\n",
    "AlexNet, which employed an 8-layer CNN,\n",
    "won the ImageNet Large Scale Visual Recognition Challenge 2012\n",
    "by a phenomenally large margin.\n",
    "This network showed, for the first time,\n",
    "that the features obtained by learning can transcend manually-designed features, breaking the previous paradigm in computer vision.\n",
    "\n",
    "The architectures of AlexNet and LeNet are very similar,\n",
    "as :numref:`fig_alexnet` illustrates.\n",
    "Note that we provide a slightly streamlined version of AlexNet\n",
    "removing some of the design quirks that were needed in 2012\n",
    "to make the model fit on two small GPUs.\n",
    "\n",
    "![From LeNet (left) to AlexNet (right).](../img/alexnet.svg)\n",
    ":label:`fig_alexnet`\n",
    "\n",
    "The design philosophies of AlexNet and LeNet are very similar,\n",
    "but there are also significant differences.\n",
    "First, AlexNet is much deeper than the comparatively small LeNet5.\n",
    "AlexNet consists of eight layers: five convolutional layers,\n",
    "two fully-connected hidden layers, and one fully-connected output layer. Second, AlexNet used the ReLU instead of the sigmoid\n",
    "as its activation function.\n",
    "Let us delve into the details below.\n",
    "\n",
    "### Architecture\n",
    "\n",
    "In AlexNet's first layer, the convolution window shape is $11\\times11$.\n",
    "Since most images in ImageNet are more than ten times higher and wider\n",
    "than the MNIST images,\n",
    "objects in ImageNet data tend to occupy more pixels.\n",
    "Consequently, a larger convolution window is needed to capture the object.\n",
    "The convolution window shape in the second layer\n",
    "is reduced to $5\\times5$, followed by $3\\times3$.\n",
    "In addition, after the first, second, and fifth convolutional layers,\n",
    "the network adds maximum pooling layers\n",
    "with a window shape of $3\\times3$ and a stride of 2.\n",
    "Moreover, AlexNet has ten times more convolution channels than LeNet.\n",
    "\n",
    "After the last convolutional layer there are two fully-connected layers\n",
    "with 4096 outputs.\n",
    "These two huge fully-connected layers produce model parameters of nearly 1 GB.\n",
    "Due to the limited memory in early GPUs,\n",
    "the original AlexNet used a dual data stream design,\n",
    "so that each of their two GPUs could be responsible\n",
    "for storing and computing only its half of the model.\n",
    "Fortunately, GPU memory is comparatively abundant now,\n",
    "so we rarely need to break up models across GPUs these days\n",
    "(our version of the AlexNet model deviates\n",
    "from the original paper in this aspect).\n",
    "\n",
    "### Activation Functions\n",
    "\n",
    "Besides, AlexNet changed the sigmoid activation function to a simpler ReLU activation function. On one hand, the computation of the ReLU activation function is simpler. For example, it does not have the exponentiation operation found in the sigmoid activation function.\n",
    " On the other hand, the ReLU activation function makes model training easier when using different parameter initialization methods. This is because, when the output of the sigmoid activation function is very close to 0 or 1, the gradient of these regions is almost 0, so that backpropagation cannot continue to update some of the model parameters. In contrast, the gradient of the ReLU activation function in the positive interval is always 1. Therefore, if the model parameters are not properly initialized, the sigmoid function may obtain a gradient of almost 0 in the positive interval, so that the model cannot be effectively trained.\n",
    "\n",
    "### Capacity Control and Preprocessing\n",
    "\n",
    "AlexNet controls the model complexity of the fully-connected layer\n",
    "by dropout (:numref:`sec_dropout`),\n",
    "while LeNet only uses weight decay.\n",
    "To augment the data even further, the training loop of AlexNet\n",
    "added a great deal of image augmentation,\n",
    "such as flipping, clipping, and color changes.\n",
    "This makes the model more robust and the larger sample size effectively reduces overfitting.\n",
    "We will discuss data augmentation in greater detail in :numref:`sec_image_augmentation`.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "origin_pos": 3,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [],
   "source": [
    "import tensorflow as tf\n",
    "from d2l import tensorflow as d2l\n",
    "\n",
    "\n",
    "def net():\n",
    "    return tf.keras.models.Sequential([\n",
    "        # Here, we use a larger 11 x 11 window to capture objects. At the same\n",
    "        # time, we use a stride of 4 to greatly reduce the height and width of\n",
    "        # the output. Here, the number of output channels is much larger than\n",
    "        # that in LeNet\n",
    "        tf.keras.layers.Conv2D(filters=96, kernel_size=11, strides=4,\n",
    "                               activation='relu'),\n",
    "        tf.keras.layers.MaxPool2D(pool_size=3, strides=2),\n",
    "        # Make the convolution window smaller, set padding to 2 for consistent\n",
    "        # height and width across the input and output, and increase the\n",
    "        # number of output channels\n",
    "        tf.keras.layers.Conv2D(filters=256, kernel_size=5, padding='same',\n",
    "                               activation='relu'),\n",
    "        tf.keras.layers.MaxPool2D(pool_size=3, strides=2),\n",
    "        # Use three successive convolutional layers and a smaller convolution\n",
    "        # window. Except for the final convolutional layer, the number of\n",
    "        # output channels is further increased. Pooling layers are not used to\n",
    "        # reduce the height and width of input after the first two\n",
    "        # convolutional layers\n",
    "        tf.keras.layers.Conv2D(filters=384, kernel_size=3, padding='same',\n",
    "                               activation='relu'),\n",
    "        tf.keras.layers.Conv2D(filters=384, kernel_size=3, padding='same',\n",
    "                               activation='relu'),\n",
    "        tf.keras.layers.Conv2D(filters=256, kernel_size=3, padding='same',\n",
    "                               activation='relu'),\n",
    "        tf.keras.layers.MaxPool2D(pool_size=3, strides=2),\n",
    "        tf.keras.layers.Flatten(),\n",
    "        # Here, the number of outputs of the fully-connected layer is several\n",
    "        # times larger than that in LeNet. Use the dropout layer to mitigate\n",
    "        # overfitting\n",
    "        tf.keras.layers.Dense(4096, activation='relu'),\n",
    "        tf.keras.layers.Dropout(0.5),\n",
    "        tf.keras.layers.Dense(4096, activation='relu'),\n",
    "        tf.keras.layers.Dropout(0.5),\n",
    "        # Output layer. Since we are using Fashion-MNIST, the number of\n",
    "        # classes is 10, instead of 1000 as in the paper\n",
    "        tf.keras.layers.Dense(10)\n",
    "    ])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 4
   },
   "source": [
    "We [**construct a single-channel data example**] with both height and width of 224 (**to observe the output shape of each layer**). It matches the AlexNet architecture in :numref:`fig_alexnet`.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "origin_pos": 7,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Conv2D output shape:\t (1, 54, 54, 96)\n",
      "MaxPooling2D output shape:\t (1, 26, 26, 96)\n",
      "Conv2D output shape:\t (1, 26, 26, 256)\n",
      "MaxPooling2D output shape:\t (1, 12, 12, 256)\n",
      "Conv2D output shape:\t (1, 12, 12, 384)\n",
      "Conv2D output shape:\t (1, 12, 12, 384)\n",
      "Conv2D output shape:\t (1, 12, 12, 256)\n",
      "MaxPooling2D output shape:\t (1, 5, 5, 256)\n",
      "Flatten output shape:\t (1, 6400)\n",
      "Dense output shape:\t (1, 4096)\n",
      "Dropout output shape:\t (1, 4096)\n",
      "Dense output shape:\t (1, 4096)\n",
      "Dropout output shape:\t (1, 4096)\n",
      "Dense output shape:\t (1, 10)\n"
     ]
    }
   ],
   "source": [
    "X = tf.random.uniform((1, 224, 224, 1))\n",
    "for layer in net().layers:\n",
    "    X = layer(X)\n",
    "    print(layer.__class__.__name__, 'output shape:\\t', X.shape)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 8
   },
   "source": [
    "## Reading the Dataset\n",
    "\n",
    "Although AlexNet is trained on ImageNet in the paper, we use Fashion-MNIST here\n",
    "since training an ImageNet model to convergence could take hours or days\n",
    "even on a modern GPU.\n",
    "One of the problems with applying AlexNet directly on [**Fashion-MNIST**]\n",
    "is that its (**images have lower resolution**) ($28 \\times 28$ pixels)\n",
    "(**than ImageNet images.**)\n",
    "To make things work, (**we upsample them to $224 \\times 224$**)\n",
    "(generally not a smart practice,\n",
    "but we do it here to be faithful to the AlexNet architecture).\n",
    "We perform this resizing with the `resize` argument in the `d2l.load_data_fashion_mnist` function.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "origin_pos": 9,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [],
   "source": [
    "batch_size = 128\n",
    "train_iter, test_iter = d2l.load_data_fashion_mnist(batch_size, resize=224)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 10
   },
   "source": [
    "## Training\n",
    "\n",
    "Now, we can [**start training AlexNet.**]\n",
    "Compared with LeNet in :numref:`sec_lenet`,\n",
    "the main change here is the use of a smaller learning rate\n",
    "and much slower training due to the deeper and wider network,\n",
    "the higher image resolution, and the more costly convolutions.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "origin_pos": 11,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "loss 0.329, train acc 0.879, test acc 0.882\n",
      "4429.3 examples/sec on /GPU:0\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<keras.engine.sequential.Sequential at 0x7f0c604e1d00>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "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",
       "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"238.965625pt\" height=\"180.65625pt\" viewBox=\"0 0 238.965625 180.65625\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n",
       " <metadata>\n",
       "  <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
       "   <cc:Work>\n",
       "    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
       "    <dc:date>2022-03-24T12:23:45.107221</dc:date>\n",
       "    <dc:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Matplotlib v3.5.1, https://matplotlib.org/</dc:title>\n",
       "     </cc:Agent>\n",
       "    </dc:creator>\n",
       "   </cc:Work>\n",
       "  </rdf:RDF>\n",
       " </metadata>\n",
       " <defs>\n",
       "  <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 180.65625 \n",
       "L 238.965625 180.65625 \n",
       "L 238.965625 0 \n",
       "L 0 0 \n",
       "L 0 180.65625 \n",
       "z\n",
       "\" style=\"fill: none\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 30.103125 143.1 \n",
       "L 225.403125 143.1 \n",
       "L 225.403125 7.2 \n",
       "L 30.103125 7.2 \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",
       "      <path d=\"M 51.803125 143.1 \n",
       "L 51.803125 7.2 \n",
       "\" clip-path=\"url(#p225845864a)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_2\">\n",
       "      <defs>\n",
       "       <path id=\"me97f34a624\" d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#me97f34a624\" x=\"51.803125\" y=\"143.1\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 2 -->\n",
       "      <g transform=\"translate(48.621875 157.698438)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-32\" d=\"M 1228 531 \n",
       "L 3431 531 \n",
       "L 3431 0 \n",
       "L 469 0 \n",
       "L 469 531 \n",
       "Q 828 903 1448 1529 \n",
       "Q 2069 2156 2228 2338 \n",
       "Q 2531 2678 2651 2914 \n",
       "Q 2772 3150 2772 3378 \n",
       "Q 2772 3750 2511 3984 \n",
       "Q 2250 4219 1831 4219 \n",
       "Q 1534 4219 1204 4116 \n",
       "Q 875 4013 500 3803 \n",
       "L 500 4441 \n",
       "Q 881 4594 1212 4672 \n",
       "Q 1544 4750 1819 4750 \n",
       "Q 2544 4750 2975 4387 \n",
       "Q 3406 4025 3406 3419 \n",
       "Q 3406 3131 3298 2873 \n",
       "Q 3191 2616 2906 2266 \n",
       "Q 2828 2175 2409 1742 \n",
       "Q 1991 1309 1228 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <path d=\"M 95.203125 143.1 \n",
       "L 95.203125 7.2 \n",
       "\" clip-path=\"url(#p225845864a)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#me97f34a624\" x=\"95.203125\" y=\"143.1\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 4 -->\n",
       "      <g transform=\"translate(92.021875 157.698438)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-34\" d=\"M 2419 4116 \n",
       "L 825 1625 \n",
       "L 2419 1625 \n",
       "L 2419 4116 \n",
       "z\n",
       "M 2253 4666 \n",
       "L 3047 4666 \n",
       "L 3047 1625 \n",
       "L 3713 1625 \n",
       "L 3713 1100 \n",
       "L 3047 1100 \n",
       "L 3047 0 \n",
       "L 2419 0 \n",
       "L 2419 1100 \n",
       "L 313 1100 \n",
       "L 313 1709 \n",
       "L 2253 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-34\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <path d=\"M 138.603125 143.1 \n",
       "L 138.603125 7.2 \n",
       "\" clip-path=\"url(#p225845864a)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_6\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#me97f34a624\" x=\"138.603125\" y=\"143.1\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 6 -->\n",
       "      <g transform=\"translate(135.421875 157.698438)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-36\" d=\"M 2113 2584 \n",
       "Q 1688 2584 1439 2293 \n",
       "Q 1191 2003 1191 1497 \n",
       "Q 1191 994 1439 701 \n",
       "Q 1688 409 2113 409 \n",
       "Q 2538 409 2786 701 \n",
       "Q 3034 994 3034 1497 \n",
       "Q 3034 2003 2786 2293 \n",
       "Q 2538 2584 2113 2584 \n",
       "z\n",
       "M 3366 4563 \n",
       "L 3366 3988 \n",
       "Q 3128 4100 2886 4159 \n",
       "Q 2644 4219 2406 4219 \n",
       "Q 1781 4219 1451 3797 \n",
       "Q 1122 3375 1075 2522 \n",
       "Q 1259 2794 1537 2939 \n",
       "Q 1816 3084 2150 3084 \n",
       "Q 2853 3084 3261 2657 \n",
       "Q 3669 2231 3669 1497 \n",
       "Q 3669 778 3244 343 \n",
       "Q 2819 -91 2113 -91 \n",
       "Q 1303 -91 875 529 \n",
       "Q 447 1150 447 2328 \n",
       "Q 447 3434 972 4092 \n",
       "Q 1497 4750 2381 4750 \n",
       "Q 2619 4750 2861 4703 \n",
       "Q 3103 4656 3366 4563 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-36\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <path d=\"M 182.003125 143.1 \n",
       "L 182.003125 7.2 \n",
       "\" clip-path=\"url(#p225845864a)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_8\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#me97f34a624\" x=\"182.003125\" y=\"143.1\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 8 -->\n",
       "      <g transform=\"translate(178.821875 157.698438)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-38\" d=\"M 2034 2216 \n",
       "Q 1584 2216 1326 1975 \n",
       "Q 1069 1734 1069 1313 \n",
       "Q 1069 891 1326 650 \n",
       "Q 1584 409 2034 409 \n",
       "Q 2484 409 2743 651 \n",
       "Q 3003 894 3003 1313 \n",
       "Q 3003 1734 2745 1975 \n",
       "Q 2488 2216 2034 2216 \n",
       "z\n",
       "M 1403 2484 \n",
       "Q 997 2584 770 2862 \n",
       "Q 544 3141 544 3541 \n",
       "Q 544 4100 942 4425 \n",
       "Q 1341 4750 2034 4750 \n",
       "Q 2731 4750 3128 4425 \n",
       "Q 3525 4100 3525 3541 \n",
       "Q 3525 3141 3298 2862 \n",
       "Q 3072 2584 2669 2484 \n",
       "Q 3125 2378 3379 2068 \n",
       "Q 3634 1759 3634 1313 \n",
       "Q 3634 634 3220 271 \n",
       "Q 2806 -91 2034 -91 \n",
       "Q 1263 -91 848 271 \n",
       "Q 434 634 434 1313 \n",
       "Q 434 1759 690 2068 \n",
       "Q 947 2378 1403 2484 \n",
       "z\n",
       "M 1172 3481 \n",
       "Q 1172 3119 1398 2916 \n",
       "Q 1625 2713 2034 2713 \n",
       "Q 2441 2713 2670 2916 \n",
       "Q 2900 3119 2900 3481 \n",
       "Q 2900 3844 2670 4047 \n",
       "Q 2441 4250 2034 4250 \n",
       "Q 1625 4250 1398 4047 \n",
       "Q 1172 3844 1172 3481 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-38\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <path d=\"M 225.403125 143.1 \n",
       "L 225.403125 7.2 \n",
       "\" clip-path=\"url(#p225845864a)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_10\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#me97f34a624\" x=\"225.403125\" y=\"143.1\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 10 -->\n",
       "      <g transform=\"translate(219.040625 157.698438)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-31\" d=\"M 794 531 \n",
       "L 1825 531 \n",
       "L 1825 4091 \n",
       "L 703 3866 \n",
       "L 703 4441 \n",
       "L 1819 4666 \n",
       "L 2450 4666 \n",
       "L 2450 531 \n",
       "L 3481 531 \n",
       "L 3481 0 \n",
       "L 794 0 \n",
       "L 794 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-30\" d=\"M 2034 4250 \n",
       "Q 1547 4250 1301 3770 \n",
       "Q 1056 3291 1056 2328 \n",
       "Q 1056 1369 1301 889 \n",
       "Q 1547 409 2034 409 \n",
       "Q 2525 409 2770 889 \n",
       "Q 3016 1369 3016 2328 \n",
       "Q 3016 3291 2770 3770 \n",
       "Q 2525 4250 2034 4250 \n",
       "z\n",
       "M 2034 4750 \n",
       "Q 2819 4750 3233 4129 \n",
       "Q 3647 3509 3647 2328 \n",
       "Q 3647 1150 3233 529 \n",
       "Q 2819 -91 2034 -91 \n",
       "Q 1250 -91 836 529 \n",
       "Q 422 1150 422 2328 \n",
       "Q 422 3509 836 4129 \n",
       "Q 1250 4750 2034 4750 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_6\">\n",
       "     <!-- epoch -->\n",
       "     <g transform=\"translate(112.525 171.376563)scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-65\" d=\"M 3597 1894 \n",
       "L 3597 1613 \n",
       "L 953 1613 \n",
       "Q 991 1019 1311 708 \n",
       "Q 1631 397 2203 397 \n",
       "Q 2534 397 2845 478 \n",
       "Q 3156 559 3463 722 \n",
       "L 3463 178 \n",
       "Q 3153 47 2828 -22 \n",
       "Q 2503 -91 2169 -91 \n",
       "Q 1331 -91 842 396 \n",
       "Q 353 884 353 1716 \n",
       "Q 353 2575 817 3079 \n",
       "Q 1281 3584 2069 3584 \n",
       "Q 2775 3584 3186 3129 \n",
       "Q 3597 2675 3597 1894 \n",
       "z\n",
       "M 3022 2063 \n",
       "Q 3016 2534 2758 2815 \n",
       "Q 2500 3097 2075 3097 \n",
       "Q 1594 3097 1305 2825 \n",
       "Q 1016 2553 972 2059 \n",
       "L 3022 2063 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-70\" d=\"M 1159 525 \n",
       "L 1159 -1331 \n",
       "L 581 -1331 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2969 \n",
       "Q 1341 3281 1617 3432 \n",
       "Q 1894 3584 2278 3584 \n",
       "Q 2916 3584 3314 3078 \n",
       "Q 3713 2572 3713 1747 \n",
       "Q 3713 922 3314 415 \n",
       "Q 2916 -91 2278 -91 \n",
       "Q 1894 -91 1617 61 \n",
       "Q 1341 213 1159 525 \n",
       "z\n",
       "M 3116 1747 \n",
       "Q 3116 2381 2855 2742 \n",
       "Q 2594 3103 2138 3103 \n",
       "Q 1681 3103 1420 2742 \n",
       "Q 1159 2381 1159 1747 \n",
       "Q 1159 1113 1420 752 \n",
       "Q 1681 391 2138 391 \n",
       "Q 2594 391 2855 752 \n",
       "Q 3116 1113 3116 1747 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-6f\" d=\"M 1959 3097 \n",
       "Q 1497 3097 1228 2736 \n",
       "Q 959 2375 959 1747 \n",
       "Q 959 1119 1226 758 \n",
       "Q 1494 397 1959 397 \n",
       "Q 2419 397 2687 759 \n",
       "Q 2956 1122 2956 1747 \n",
       "Q 2956 2369 2687 2733 \n",
       "Q 2419 3097 1959 3097 \n",
       "z\n",
       "M 1959 3584 \n",
       "Q 2709 3584 3137 3096 \n",
       "Q 3566 2609 3566 1747 \n",
       "Q 3566 888 3137 398 \n",
       "Q 2709 -91 1959 -91 \n",
       "Q 1206 -91 779 398 \n",
       "Q 353 888 353 1747 \n",
       "Q 353 2609 779 3096 \n",
       "Q 1206 3584 1959 3584 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-63\" d=\"M 3122 3366 \n",
       "L 3122 2828 \n",
       "Q 2878 2963 2633 3030 \n",
       "Q 2388 3097 2138 3097 \n",
       "Q 1578 3097 1268 2742 \n",
       "Q 959 2388 959 1747 \n",
       "Q 959 1106 1268 751 \n",
       "Q 1578 397 2138 397 \n",
       "Q 2388 397 2633 464 \n",
       "Q 2878 531 3122 666 \n",
       "L 3122 134 \n",
       "Q 2881 22 2623 -34 \n",
       "Q 2366 -91 2075 -91 \n",
       "Q 1284 -91 818 406 \n",
       "Q 353 903 353 1747 \n",
       "Q 353 2603 823 3093 \n",
       "Q 1294 3584 2113 3584 \n",
       "Q 2378 3584 2631 3529 \n",
       "Q 2884 3475 3122 3366 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-68\" d=\"M 3513 2113 \n",
       "L 3513 0 \n",
       "L 2938 0 \n",
       "L 2938 2094 \n",
       "Q 2938 2591 2744 2837 \n",
       "Q 2550 3084 2163 3084 \n",
       "Q 1697 3084 1428 2787 \n",
       "Q 1159 2491 1159 1978 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 4863 \n",
       "L 1159 4863 \n",
       "L 1159 2956 \n",
       "Q 1366 3272 1645 3428 \n",
       "Q 1925 3584 2291 3584 \n",
       "Q 2894 3584 3203 3211 \n",
       "Q 3513 2838 3513 2113 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-65\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-70\" x=\"61.523438\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6f\" x=\"125\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" x=\"186.181641\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-68\" x=\"241.162109\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <path d=\"M 30.103125 127.631611 \n",
       "L 225.403125 127.631611 \n",
       "\" clip-path=\"url(#p225845864a)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_12\">\n",
       "      <defs>\n",
       "       <path id=\"mb407b3c7e1\" d=\"M 0 0 \n",
       "L -3.5 0 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#mb407b3c7e1\" x=\"30.103125\" y=\"127.631611\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 0.4 -->\n",
       "      <g transform=\"translate(7.2 131.43083)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-2e\" d=\"M 684 794 \n",
       "L 1344 794 \n",
       "L 1344 0 \n",
       "L 684 0 \n",
       "L 684 794 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_13\">\n",
       "      <path d=\"M 30.103125 101.384846 \n",
       "L 225.403125 101.384846 \n",
       "\" clip-path=\"url(#p225845864a)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_14\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mb407b3c7e1\" x=\"30.103125\" y=\"101.384846\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 0.6 -->\n",
       "      <g transform=\"translate(7.2 105.184065)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-36\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_15\">\n",
       "      <path d=\"M 30.103125 75.138081 \n",
       "L 225.403125 75.138081 \n",
       "\" clip-path=\"url(#p225845864a)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_16\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mb407b3c7e1\" x=\"30.103125\" y=\"75.138081\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- 0.8 -->\n",
       "      <g transform=\"translate(7.2 78.937299)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-38\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_17\">\n",
       "      <path d=\"M 30.103125 48.891315 \n",
       "L 225.403125 48.891315 \n",
       "\" clip-path=\"url(#p225845864a)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_18\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mb407b3c7e1\" x=\"30.103125\" y=\"48.891315\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- 1.0 -->\n",
       "      <g transform=\"translate(7.2 52.690534)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_19\">\n",
       "      <path d=\"M 30.103125 22.64455 \n",
       "L 225.403125 22.64455 \n",
       "\" clip-path=\"url(#p225845864a)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_20\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mb407b3c7e1\" x=\"30.103125\" y=\"22.64455\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_11\">\n",
       "      <!-- 1.2 -->\n",
       "      <g transform=\"translate(7.2 26.443769)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_21\">\n",
       "    <path d=\"M 30.103125 13.377273 \n",
       "L 51.803125 94.62011 \n",
       "L 73.503125 109.481139 \n",
       "L 95.203125 118.225738 \n",
       "L 116.903125 123.720846 \n",
       "L 138.603125 127.716793 \n",
       "L 160.303125 130.406106 \n",
       "L 182.003125 133.040139 \n",
       "L 203.703125 135.00733 \n",
       "L 225.403125 136.922727 \n",
       "\" clip-path=\"url(#p225845864a)\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"line2d_22\">\n",
       "    <path d=\"M 30.103125 111.12677 \n",
       "L 51.803125 80.809573 \n",
       "L 73.503125 75.203699 \n",
       "L 95.203125 71.771936 \n",
       "L 116.903125 69.558457 \n",
       "L 138.603125 67.90491 \n",
       "L 160.303125 67.165623 \n",
       "L 182.003125 66.100442 \n",
       "L 203.703125 65.492396 \n",
       "L 225.403125 64.788105 \n",
       "\" clip-path=\"url(#p225845864a)\" style=\"fill: none; stroke-dasharray: 5.55,2.4; stroke-dashoffset: 0; stroke: #bf00bf; stroke-width: 1.5\"/>\n",
       "   </g>\n",
       "   <g id=\"line2d_23\">\n",
       "    <path d=\"M 30.103125 85.348075 \n",
       "L 51.803125 76.096089 \n",
       "L 73.503125 71.988469 \n",
       "L 95.203125 71.161699 \n",
       "L 116.903125 67.998963 \n",
       "L 138.603125 66.725995 \n",
       "L 160.303125 65.794229 \n",
       "L 182.003125 65.256175 \n",
       "L 203.703125 64.652501 \n",
       "L 225.403125 64.311291 \n",
       "\" clip-path=\"url(#p225845864a)\" style=\"fill: none; stroke-dasharray: 9.6,2.4,1.5,2.4; stroke-dashoffset: 0; stroke: #008000; stroke-width: 1.5\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 30.103125 143.1 \n",
       "L 30.103125 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 225.403125 143.1 \n",
       "L 225.403125 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 30.103125 143.1 \n",
       "L 225.403125 143.1 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 30.103125 7.2 \n",
       "L 225.403125 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"legend_1\">\n",
       "    <g id=\"patch_7\">\n",
       "     <path d=\"M 140.634375 59.234375 \n",
       "L 218.403125 59.234375 \n",
       "Q 220.403125 59.234375 220.403125 57.234375 \n",
       "L 220.403125 14.2 \n",
       "Q 220.403125 12.2 218.403125 12.2 \n",
       "L 140.634375 12.2 \n",
       "Q 138.634375 12.2 138.634375 14.2 \n",
       "L 138.634375 57.234375 \n",
       "Q 138.634375 59.234375 140.634375 59.234375 \n",
       "z\n",
       "\" style=\"fill: #ffffff; opacity: 0.8; stroke: #cccccc; stroke-linejoin: miter\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_24\">\n",
       "     <path d=\"M 142.634375 20.298438 \n",
       "L 152.634375 20.298438 \n",
       "L 162.634375 20.298438 \n",
       "\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "    </g>\n",
       "    <g id=\"text_12\">\n",
       "     <!-- train loss -->\n",
       "     <g transform=\"translate(170.634375 23.798438)scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-74\" d=\"M 1172 4494 \n",
       "L 1172 3500 \n",
       "L 2356 3500 \n",
       "L 2356 3053 \n",
       "L 1172 3053 \n",
       "L 1172 1153 \n",
       "Q 1172 725 1289 603 \n",
       "Q 1406 481 1766 481 \n",
       "L 2356 481 \n",
       "L 2356 0 \n",
       "L 1766 0 \n",
       "Q 1100 0 847 248 \n",
       "Q 594 497 594 1153 \n",
       "L 594 3053 \n",
       "L 172 3053 \n",
       "L 172 3500 \n",
       "L 594 3500 \n",
       "L 594 4494 \n",
       "L 1172 4494 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-72\" d=\"M 2631 2963 \n",
       "Q 2534 3019 2420 3045 \n",
       "Q 2306 3072 2169 3072 \n",
       "Q 1681 3072 1420 2755 \n",
       "Q 1159 2438 1159 1844 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2956 \n",
       "Q 1341 3275 1631 3429 \n",
       "Q 1922 3584 2338 3584 \n",
       "Q 2397 3584 2469 3576 \n",
       "Q 2541 3569 2628 3553 \n",
       "L 2631 2963 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-61\" d=\"M 2194 1759 \n",
       "Q 1497 1759 1228 1600 \n",
       "Q 959 1441 959 1056 \n",
       "Q 959 750 1161 570 \n",
       "Q 1363 391 1709 391 \n",
       "Q 2188 391 2477 730 \n",
       "Q 2766 1069 2766 1631 \n",
       "L 2766 1759 \n",
       "L 2194 1759 \n",
       "z\n",
       "M 3341 1997 \n",
       "L 3341 0 \n",
       "L 2766 0 \n",
       "L 2766 531 \n",
       "Q 2569 213 2275 61 \n",
       "Q 1981 -91 1556 -91 \n",
       "Q 1019 -91 701 211 \n",
       "Q 384 513 384 1019 \n",
       "Q 384 1609 779 1909 \n",
       "Q 1175 2209 1959 2209 \n",
       "L 2766 2209 \n",
       "L 2766 2266 \n",
       "Q 2766 2663 2505 2880 \n",
       "Q 2244 3097 1772 3097 \n",
       "Q 1472 3097 1187 3025 \n",
       "Q 903 2953 641 2809 \n",
       "L 641 3341 \n",
       "Q 956 3463 1253 3523 \n",
       "Q 1550 3584 1831 3584 \n",
       "Q 2591 3584 2966 3190 \n",
       "Q 3341 2797 3341 1997 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-69\" d=\"M 603 3500 \n",
       "L 1178 3500 \n",
       "L 1178 0 \n",
       "L 603 0 \n",
       "L 603 3500 \n",
       "z\n",
       "M 603 4863 \n",
       "L 1178 4863 \n",
       "L 1178 4134 \n",
       "L 603 4134 \n",
       "L 603 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-6e\" d=\"M 3513 2113 \n",
       "L 3513 0 \n",
       "L 2938 0 \n",
       "L 2938 2094 \n",
       "Q 2938 2591 2744 2837 \n",
       "Q 2550 3084 2163 3084 \n",
       "Q 1697 3084 1428 2787 \n",
       "Q 1159 2491 1159 1978 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2956 \n",
       "Q 1366 3272 1645 3428 \n",
       "Q 1925 3584 2291 3584 \n",
       "Q 2894 3584 3203 3211 \n",
       "Q 3513 2838 3513 2113 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-20\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-6c\" d=\"M 603 4863 \n",
       "L 1178 4863 \n",
       "L 1178 0 \n",
       "L 603 0 \n",
       "L 603 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-73\" d=\"M 2834 3397 \n",
       "L 2834 2853 \n",
       "Q 2591 2978 2328 3040 \n",
       "Q 2066 3103 1784 3103 \n",
       "Q 1356 3103 1142 2972 \n",
       "Q 928 2841 928 2578 \n",
       "Q 928 2378 1081 2264 \n",
       "Q 1234 2150 1697 2047 \n",
       "L 1894 2003 \n",
       "Q 2506 1872 2764 1633 \n",
       "Q 3022 1394 3022 966 \n",
       "Q 3022 478 2636 193 \n",
       "Q 2250 -91 1575 -91 \n",
       "Q 1294 -91 989 -36 \n",
       "Q 684 19 347 128 \n",
       "L 347 722 \n",
       "Q 666 556 975 473 \n",
       "Q 1284 391 1588 391 \n",
       "Q 1994 391 2212 530 \n",
       "Q 2431 669 2431 922 \n",
       "Q 2431 1156 2273 1281 \n",
       "Q 2116 1406 1581 1522 \n",
       "L 1381 1569 \n",
       "Q 847 1681 609 1914 \n",
       "Q 372 2147 372 2553 \n",
       "Q 372 3047 722 3315 \n",
       "Q 1072 3584 1716 3584 \n",
       "Q 2034 3584 2315 3537 \n",
       "Q 2597 3491 2834 3397 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-74\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" x=\"39.208984\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" x=\"80.322266\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-69\" x=\"141.601562\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6e\" x=\"169.384766\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-20\" x=\"232.763672\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6c\" x=\"264.550781\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6f\" x=\"292.333984\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" x=\"353.515625\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" x=\"405.615234\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"line2d_25\">\n",
       "     <path d=\"M 142.634375 34.976562 \n",
       "L 152.634375 34.976562 \n",
       "L 162.634375 34.976562 \n",
       "\" style=\"fill: none; stroke-dasharray: 5.55,2.4; stroke-dashoffset: 0; stroke: #bf00bf; stroke-width: 1.5\"/>\n",
       "    </g>\n",
       "    <g id=\"text_13\">\n",
       "     <!-- train acc -->\n",
       "     <g transform=\"translate(170.634375 38.476562)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-74\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" x=\"39.208984\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" x=\"80.322266\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-69\" x=\"141.601562\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6e\" x=\"169.384766\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-20\" x=\"232.763672\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" x=\"264.550781\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" x=\"325.830078\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" x=\"380.810547\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"line2d_26\">\n",
       "     <path d=\"M 142.634375 49.654688 \n",
       "L 152.634375 49.654688 \n",
       "L 162.634375 49.654688 \n",
       "\" style=\"fill: none; stroke-dasharray: 9.6,2.4,1.5,2.4; stroke-dashoffset: 0; stroke: #008000; stroke-width: 1.5\"/>\n",
       "    </g>\n",
       "    <g id=\"text_14\">\n",
       "     <!-- test acc -->\n",
       "     <g transform=\"translate(170.634375 53.154688)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-74\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" x=\"39.208984\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" x=\"100.732422\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-74\" x=\"152.832031\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-20\" x=\"192.041016\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" x=\"223.828125\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" x=\"285.107422\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" x=\"340.087891\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p225845864a\">\n",
       "   <rect x=\"30.103125\" y=\"7.2\" width=\"195.3\" height=\"135.9\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 252x180 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "lr, num_epochs = 0.01, 10\n",
    "d2l.train_ch6(net, train_iter, test_iter, num_epochs, lr, d2l.try_gpu())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 12
   },
   "source": [
    "## Summary\n",
    "\n",
    "* AlexNet has a similar structure to that of LeNet, but uses more convolutional layers and a larger parameter space to fit the large-scale ImageNet dataset.\n",
    "* Today AlexNet has been surpassed by much more effective architectures but it is a key step from shallow to deep networks that are used nowadays.\n",
    "* Although it seems that there are only a few more lines in AlexNet's implementation than in LeNet, it took the academic community many years to embrace this conceptual change and take advantage of its excellent experimental results. This was also due to the lack of efficient computational tools.\n",
    "* Dropout, ReLU, and preprocessing were the other key steps in achieving excellent performance in computer vision tasks.\n",
    "\n",
    "## Exercises\n",
    "\n",
    "1. Try increasing the number of epochs. Compared with LeNet, how are the results different? Why?\n",
    "1. AlexNet may be too complex for the Fashion-MNIST dataset.\n",
    "    1. Try simplifying the model to make the training faster, while ensuring that the accuracy does not drop significantly.\n",
    "    1. Design a better model that works directly on $28 \\times 28$ images.\n",
    "1. Modify the batch size, and observe the changes in accuracy and GPU memory.\n",
    "1. Analyze computational performance of AlexNet.\n",
    "    1. What is the dominant part for the memory footprint of AlexNet?\n",
    "    1. What is the dominant part for computation in AlexNet?\n",
    "    1. How about memory bandwidth when computing the results?\n",
    "1. Apply dropout and ReLU to LeNet-5. Does it improve? How about preprocessing?\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 15,
    "tab": [
     "tensorflow"
    ]
   },
   "source": [
    "[Discussions](https://discuss.d2l.ai/t/276)\n"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}