{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 0
   },
   "source": [
    "# Generative Adversarial Networks\n",
    ":label:`sec_basic_gan`\n",
    "\n",
    "Throughout most of this book, we have talked about how to make predictions. In some form or another, we used deep neural networks learned mappings from data examples to labels. This kind of learning is called discriminative learning, as in, we'd like to be able to discriminate between photos cats and photos of dogs. Classifiers and regressors are both examples of discriminative learning. And neural networks trained by backpropagation have upended everything we thought we knew about discriminative learning on large complicated datasets. Classification accuracies on high-res images has gone from useless to human-level (with some caveats) in just 5-6 years. We will spare you another spiel about all the other discriminative tasks where deep neural networks do astoundingly well.\n",
    "\n",
    "But there is more to machine learning than just solving discriminative tasks. For example, given a large dataset, without any labels, we might want to learn a model that concisely captures the characteristics of this data. Given such a model, we could sample synthetic data examples that resemble the distribution of the training data. For example, given a large corpus of photographs of faces, we might want to be able to generate a new photorealistic image that looks like it might plausibly have come from the same dataset. This kind of learning is called generative modeling.\n",
    "\n",
    "Until recently, we had no method that could synthesize novel photorealistic images. But the success of deep neural networks for discriminative learning opened up new possibilities. One big trend over the last three years has been the application of discriminative deep nets to overcome challenges in problems that we do not generally think of as supervised learning problems. The recurrent neural network language models are one example of using a discriminative network (trained to predict the next character) that once trained can act as a generative model.\n",
    "\n",
    "In 2014, a breakthrough paper introduced Generative adversarial networks (GANs) :cite:`Goodfellow.Pouget-Abadie.Mirza.ea.2014`, a clever new way to leverage the power of discriminative models to get good generative models. At their heart, GANs rely on the idea that a data generator is good if we cannot tell fake data apart from real data. In statistics, this is called a two-sample test - a test to answer the question whether datasets $X=\\{x_1,\\ldots, x_n\\}$ and $X'=\\{x'_1,\\ldots, x'_n\\}$ were drawn from the same distribution. The main difference between most statistics papers and GANs is that the latter use this idea in a constructive way. In other words, rather than just training a model to say \"hey, these two datasets do not look like they came from the same distribution\", they use the [two-sample test](https://en.wikipedia.org/wiki/Two-sample_hypothesis_testing) to provide training signals to a generative model. This allows us to improve the data generator until it generates something that resembles the real data. At the very least, it needs to fool the classifier. Even if our classifier is a state of the art deep neural network.\n",
    "\n",
    "![Generative Adversarial Networks](../img/gan.svg)\n",
    ":label:`fig_gan`\n",
    "\n",
    "\n",
    "The GAN architecture is illustrated in :numref:`fig_gan`.\n",
    "As you can see, there are two pieces in GAN architecture - first off, we need a device (say, a deep network but it really could be anything, such as a game rendering engine) that might potentially be able to generate data that looks just like the real thing. If we are dealing with images, this needs to generate images. If we are dealing with speech, it needs to generate audio sequences, and so on. We call this the generator network. The second component is the discriminator network. It attempts to distinguish fake and real data from each other. Both networks are in competition with each other. The generator network attempts to fool the discriminator network. At that point, the discriminator network adapts to the new fake data. This information, in turn is used to improve the generator network, and so on.\n",
    "\n",
    "\n",
    "The discriminator is a binary classifier to distinguish if the input $x$ is real (from real data) or fake (from the generator). Typically, the discriminator outputs a scalar prediction $o\\in\\mathbb R$ for input $\\mathbf x$, such as using a dense layer with hidden size 1, and then applies sigmoid function to obtain the predicted probability $D(\\mathbf x) = 1/(1+e^{-o})$. Assume the label $y$ for the true data is $1$ and $0$ for the fake data. We train the discriminator to minimize the cross-entropy loss, *i.e.*,\n",
    "\n",
    "$$ \\min_D \\{ - y \\log D(\\mathbf x) - (1-y)\\log(1-D(\\mathbf x)) \\},$$\n",
    "\n",
    "For the generator, it first draws some parameter $\\mathbf z\\in\\mathbb R^d$ from a source of randomness, *e.g.*, a normal distribution $\\mathbf z \\sim \\mathcal{N} (0, 1)$. We often call $\\mathbf z$ as the latent variable.\n",
    "It then applies a function to generate $\\mathbf x'=G(\\mathbf z)$. The goal of the generator is to fool the discriminator to classify $\\mathbf x'=G(\\mathbf z)$ as true data, *i.e.*, we want $D( G(\\mathbf z)) \\approx 1$.\n",
    "In other words, for a given discriminator $D$, we update the parameters of the generator $G$ to maximize the cross-entropy loss when $y=0$, *i.e.*,\n",
    "\n",
    "$$ \\max_G \\{ - (1-y) \\log(1-D(G(\\mathbf z))) \\} = \\max_G \\{ - \\log(1-D(G(\\mathbf z))) \\}.$$\n",
    "\n",
    "If the generator does a perfect job, then $D(\\mathbf x')\\approx 1$ so the above loss near 0, which results the gradients are too small to make a good progress for the discriminator. So commonly we minimize the following loss:\n",
    "\n",
    "$$ \\min_G \\{ - y \\log(D(G(\\mathbf z))) \\} = \\min_G \\{ - \\log(D(G(\\mathbf z))) \\}, $$\n",
    "\n",
    "which is just feed $\\mathbf x'=G(\\mathbf z)$ into the discriminator but giving label $y=1$.\n",
    "\n",
    "\n",
    "To sum up, $D$ and $G$ are playing a \"minimax\" game with the comprehensive objective function:\n",
    "\n",
    "$$min_D max_G \\{ -E_{x \\sim \\text{Data}} log D(\\mathbf x) - E_{z \\sim \\text{Noise}} log(1 - D(G(\\mathbf z))) \\}.$$\n",
    "\n",
    "\n",
    "\n",
    "Many of the GANs applications are in the context of images. As a demonstration purpose, we are going to content ourselves with fitting a much simpler distribution first. We will illustrate what happens if we use GANs to build the world's most inefficient estimator of parameters for a Gaussian. Let us get started.\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"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 4
   },
   "source": [
    "## Generate Some \"Real\" Data\n",
    "\n",
    "Since this is going to be the world's lamest example, we simply generate data drawn from a Gaussian.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "origin_pos": 6,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [],
   "source": [
    "X = tf.random.normal((1000, 2), 0.0, 1)\n",
    "A = tf.constant([[1, 2], [-0.1, 0.5]])\n",
    "b = tf.constant([1, 2], tf.float32)\n",
    "data = tf.matmul(X, A) + b"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 7
   },
   "source": [
    "Let us see what we got. This should be a Gaussian shifted in some rather arbitrary way with mean $b$ and covariance matrix $A^TA$.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "origin_pos": 9,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The covariance matrix is\n",
      "[[1.01 1.95]\n",
      " [1.95 4.25]]\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",
       "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"243.156225pt\" height=\"166.978125pt\" viewBox=\"0 0 243.156225 166.978125\" 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-24T13:07:41.518484</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 166.978125 \n",
       "L 243.156225 166.978125 \n",
       "L 243.156225 0 \n",
       "L -0 0 \n",
       "L -0 166.978125 \n",
       "z\n",
       "\" style=\"fill: none\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 38.482813 143.1 \n",
       "L 233.782813 143.1 \n",
       "L 233.782813 7.2 \n",
       "L 38.482813 7.2 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_1\">\n",
       "    <defs>\n",
       "     <path id=\"m7e4c5ba26a\" d=\"M 0 3 \n",
       "C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \n",
       "C 2.683901 1.55874 3 0.795609 3 0 \n",
       "C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \n",
       "C 1.55874 -2.683901 0.795609 -3 0 -3 \n",
       "C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \n",
       "C -2.683901 -1.55874 -3 -0.795609 -3 0 \n",
       "C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \n",
       "C -1.55874 2.683901 -0.795609 3 0 3 \n",
       "z\n",
       "\" style=\"stroke: #1f77b4\"/>\n",
       "    </defs>\n",
       "    <g clip-path=\"url(#pdd22f2f5e9)\">\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"89.066385\" y=\"113.542634\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"160.931157\" y=\"64.088947\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"158.456589\" y=\"62.871606\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"127.265046\" y=\"78.075583\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"112.244249\" y=\"95.035604\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"159.178227\" y=\"65.667611\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"159.567547\" y=\"57.971003\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"172.59934\" y=\"48.50128\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"142.473095\" y=\"76.559573\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"179.096225\" y=\"52.333062\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"105.46627\" y=\"96.659743\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"80.117116\" y=\"115.337532\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"146.192443\" y=\"56.802679\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"159.636205\" y=\"52.143825\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"112.598271\" y=\"81.548459\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"95.904878\" y=\"99.221367\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"137.680181\" y=\"89.959037\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"168.182105\" y=\"59.10056\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"162.82698\" y=\"48.736028\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"129.893707\" y=\"94.425966\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"148.169025\" y=\"62.852277\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"180.772426\" y=\"54.707238\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"146.811192\" y=\"70.941707\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"186.78606\" y=\"52.766831\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"165.174378\" y=\"52.282755\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"155.241494\" y=\"70.754476\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"92.820206\" y=\"108.586114\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"150.394682\" y=\"67.373511\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"63.558219\" y=\"125.298495\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"171.338645\" y=\"48.644979\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"130.032585\" y=\"80.861614\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"182.229803\" y=\"54.758492\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"120.811662\" y=\"81.288475\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"125.696634\" y=\"91.403796\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"151.119133\" y=\"60.422831\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"151.060283\" y=\"70.884879\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"111.295218\" y=\"87.726275\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"147.964278\" y=\"74.030086\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"91.968589\" y=\"108.266069\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"68.141296\" y=\"116.283155\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"148.88269\" y=\"70.646032\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"170.612015\" y=\"50.151618\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"121.76844\" y=\"81.72839\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"145.629372\" y=\"69.601876\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"127.488602\" y=\"76.871491\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"139.019886\" y=\"81.772325\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"156.440425\" y=\"69.935873\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"140.850507\" y=\"72.044035\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"118.316329\" y=\"96.426786\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"202.299478\" y=\"44.733001\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"169.770188\" y=\"55.984997\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"173.828375\" y=\"59.392579\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"137.182452\" y=\"67.588087\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"185.842568\" y=\"62.125942\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"120.349886\" y=\"81.74845\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"126.547287\" y=\"83.646501\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"106.02104\" y=\"99.738588\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"131.210524\" y=\"76.035259\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"173.940073\" y=\"54.877902\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"176.507708\" y=\"51.264256\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"93.104262\" y=\"103.838741\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"140.500733\" y=\"89.309664\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"115.021706\" y=\"88.993586\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"168.745784\" y=\"58.818601\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"108.664908\" y=\"96.836541\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"161.392032\" y=\"67.454972\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"122.745954\" y=\"96.044172\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"224.90554\" y=\"13.377273\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"115.091983\" y=\"90.251263\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"104.610998\" y=\"79.408341\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"150.982595\" y=\"63.034027\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"160.55713\" y=\"57.017531\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"155.439224\" y=\"62.489617\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"122.095719\" y=\"92.676458\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"120.038493\" y=\"91.977305\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"168.091484\" y=\"50.03221\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"118.659969\" y=\"93.337044\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"109.425545\" y=\"86.598776\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"136.131744\" y=\"79.848563\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"127.738466\" y=\"84.73297\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"177.848089\" y=\"45.634689\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"115.209367\" y=\"98.24024\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"168.471045\" y=\"52.331302\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"125.279761\" y=\"86.294049\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"135.087661\" y=\"77.236505\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"138.770228\" y=\"68.582899\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"160.947449\" y=\"64.145292\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"126.613904\" y=\"89.161198\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"127.129383\" y=\"93.368564\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"47.360085\" y=\"136.922727\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"127.773042\" y=\"87.663127\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"178.923394\" y=\"50.551336\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"147.956851\" y=\"74.898402\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"107.177545\" y=\"103.348902\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"151.359163\" y=\"75.431249\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"206.055574\" y=\"29.299924\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"126.984441\" y=\"97.623936\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"74.867809\" y=\"117.52771\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"146.721297\" y=\"81.329187\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m7e4c5ba26a\" x=\"214.920774\" y=\"23.197707\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <defs>\n",
       "       <path id=\"me7301db002\" 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=\"#me7301db002\" x=\"53.845448\" 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(46.474354 157.698438)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-2212\" d=\"M 678 2272 \n",
       "L 4684 2272 \n",
       "L 4684 1741 \n",
       "L 678 1741 \n",
       "L 678 2272 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\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-2212\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"83.789062\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_2\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#me7301db002\" x=\"113.488623\" y=\"143.1\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 0 -->\n",
       "      <g transform=\"translate(110.307373 157.698438)scale(0.1 -0.1)\">\n",
       "       <defs>\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-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#me7301db002\" x=\"173.131799\" y=\"143.1\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 2 -->\n",
       "      <g transform=\"translate(169.950549 157.698438)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#me7301db002\" x=\"232.774975\" y=\"143.1\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 4 -->\n",
       "      <g transform=\"translate(229.593725 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>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <defs>\n",
       "       <path id=\"m784d2b434c\" 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=\"#m784d2b434c\" x=\"38.482813\" y=\"142.520547\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- −5.0 -->\n",
       "      <g transform=\"translate(7.2 146.319766)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-35\" d=\"M 691 4666 \n",
       "L 3169 4666 \n",
       "L 3169 4134 \n",
       "L 1269 4134 \n",
       "L 1269 2991 \n",
       "Q 1406 3038 1543 3061 \n",
       "Q 1681 3084 1819 3084 \n",
       "Q 2600 3084 3056 2656 \n",
       "Q 3513 2228 3513 1497 \n",
       "Q 3513 744 3044 326 \n",
       "Q 2575 -91 1722 -91 \n",
       "Q 1428 -91 1123 -41 \n",
       "Q 819 9 494 109 \n",
       "L 494 744 \n",
       "Q 775 591 1075 516 \n",
       "Q 1375 441 1709 441 \n",
       "Q 2250 441 2565 725 \n",
       "Q 2881 1009 2881 1497 \n",
       "Q 2881 1984 2565 2268 \n",
       "Q 2250 2553 1709 2553 \n",
       "Q 1456 2553 1204 2497 \n",
       "Q 953 2441 691 2322 \n",
       "L 691 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\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-2212\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"83.789062\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"147.412109\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"179.199219\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_6\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m784d2b434c\" x=\"38.482813\" y=\"117.714989\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- −2.5 -->\n",
       "      <g transform=\"translate(7.2 121.514208)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"83.789062\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"147.412109\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"179.199219\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m784d2b434c\" x=\"38.482813\" y=\"92.909431\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 0.0 -->\n",
       "      <g transform=\"translate(15.579688 96.708649)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-30\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_8\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m784d2b434c\" x=\"38.482813\" y=\"68.103873\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 2.5 -->\n",
       "      <g transform=\"translate(15.579688 71.903091)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m784d2b434c\" x=\"38.482813\" y=\"43.298315\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- 5.0 -->\n",
       "      <g transform=\"translate(15.579688 47.097533)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-35\"/>\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_6\">\n",
       "     <g id=\"line2d_10\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m784d2b434c\" x=\"38.482813\" y=\"18.492757\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- 7.5 -->\n",
       "      <g transform=\"translate(15.579688 22.291975)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-37\" d=\"M 525 4666 \n",
       "L 3525 4666 \n",
       "L 3525 4397 \n",
       "L 1831 0 \n",
       "L 1172 0 \n",
       "L 2766 4134 \n",
       "L 525 4134 \n",
       "L 525 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-37\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 38.482813 143.1 \n",
       "L 38.482813 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 233.782813 143.1 \n",
       "L 233.782813 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 38.482813 143.1 \n",
       "L 233.782813 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 38.482813 7.2 \n",
       "L 233.782813 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"pdd22f2f5e9\">\n",
       "   <rect x=\"38.482813\" 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": [
    "d2l.set_figsize()\n",
    "d2l.plt.scatter(data[:100, (0)].numpy(), data[:100, (1)].numpy());\n",
    "print(f'The covariance matrix is\\n{tf.matmul(A, A, transpose_a=True)}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "origin_pos": 10,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [],
   "source": [
    "batch_size = 8\n",
    "data_iter = d2l.load_array((data,), batch_size)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 11
   },
   "source": [
    "## Generator\n",
    "\n",
    "Our generator network will be the simplest network possible - a single layer linear model. This is since we will be driving that linear network with a Gaussian data generator. Hence, it literally only needs to learn the parameters to fake things perfectly.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "origin_pos": 14,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [],
   "source": [
    "net_G = tf.keras.layers.Dense(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 15
   },
   "source": [
    "## Discriminator\n",
    "\n",
    "For the discriminator we will be a bit more discriminating: we will use an MLP with 3 layers to make things a bit more interesting.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "origin_pos": 18,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [],
   "source": [
    "net_D = tf.keras.models.Sequential([\n",
    "    tf.keras.layers.Dense(5, activation=\"tanh\", input_shape=(2,)),\n",
    "    tf.keras.layers.Dense(3, activation=\"tanh\"),\n",
    "    tf.keras.layers.Dense(1)\n",
    "])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 19
   },
   "source": [
    "## Training\n",
    "\n",
    "First we define a function to update the discriminator.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "origin_pos": 22,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [],
   "source": [
    "#@save\n",
    "def update_D(X, Z, net_D, net_G, loss, optimizer_D):\n",
    "    \"\"\"Update discriminator.\"\"\"\n",
    "    batch_size = X.shape[0]\n",
    "    ones = tf.ones((batch_size,)) # Labels corresponding to real data\n",
    "    zeros = tf.zeros((batch_size,)) # Labels corresponding to fake data\n",
    "    # Do not need to compute gradient for `net_G`, so it's outside GradientTape\n",
    "    fake_X = net_G(Z)\n",
    "    with tf.GradientTape() as tape:\n",
    "        real_Y = net_D(X)\n",
    "        fake_Y = net_D(fake_X)\n",
    "        # We multiply the loss by batch_size to match PyTorch's BCEWithLogitsLoss\n",
    "        loss_D = (loss(ones, tf.squeeze(real_Y)) + loss(\n",
    "            zeros, tf.squeeze(fake_Y))) * batch_size / 2\n",
    "    grads_D = tape.gradient(loss_D, net_D.trainable_variables)\n",
    "    optimizer_D.apply_gradients(zip(grads_D, net_D.trainable_variables))\n",
    "    return loss_D"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 23
   },
   "source": [
    "The generator is updated similarly. Here we reuse the cross-entropy loss but change the label of the fake data from $0$ to $1$.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "origin_pos": 26,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [],
   "source": [
    "#@save\n",
    "def update_G(Z, net_D, net_G, loss, optimizer_G):\n",
    "    \"\"\"Update generator.\"\"\"\n",
    "    batch_size = Z.shape[0]\n",
    "    ones = tf.ones((batch_size,))\n",
    "    with tf.GradientTape() as tape:\n",
    "        # We could reuse `fake_X` from `update_D` to save computation\n",
    "        fake_X = net_G(Z)\n",
    "        # Recomputing `fake_Y` is needed since `net_D` is changed\n",
    "        fake_Y = net_D(fake_X)\n",
    "        # We multiply the loss by batch_size to match PyTorch's BCEWithLogits loss\n",
    "        loss_G = loss(ones, tf.squeeze(fake_Y)) * batch_size\n",
    "    grads_G = tape.gradient(loss_G, net_G.trainable_variables)\n",
    "    optimizer_G.apply_gradients(zip(grads_G, net_G.trainable_variables))\n",
    "    return loss_G"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 27
   },
   "source": [
    "Both the discriminator and the generator performs a binary logistic regression with the cross-entropy loss. We use Adam to smooth the training process. In each iteration, we first update the discriminator and then the generator. We visualize both losses and generated examples.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "origin_pos": 30,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [],
   "source": [
    "def train(net_D, net_G, data_iter, num_epochs, lr_D, lr_G, latent_dim, data):\n",
    "    loss = tf.keras.losses.BinaryCrossentropy(\n",
    "        from_logits=True, reduction=tf.keras.losses.Reduction.SUM)\n",
    "    for w in net_D.trainable_variables:\n",
    "        w.assign(tf.random.normal(mean=0, stddev=0.02, shape=w.shape))\n",
    "    for w in net_G.trainable_variables:\n",
    "        w.assign(tf.random.normal(mean=0, stddev=0.02, shape=w.shape))\n",
    "    optimizer_D = tf.keras.optimizers.Adam(learning_rate=lr_D)\n",
    "    optimizer_G = tf.keras.optimizers.Adam(learning_rate=lr_G)\n",
    "    animator = d2l.Animator(\n",
    "        xlabel=\"epoch\", ylabel=\"loss\", xlim=[1, num_epochs], nrows=2,\n",
    "        figsize=(5, 5), legend=[\"discriminator\", \"generator\"])\n",
    "    animator.fig.subplots_adjust(hspace=0.3)\n",
    "    for epoch in range(num_epochs):\n",
    "        # Train one epoch\n",
    "        timer = d2l.Timer()\n",
    "        metric = d2l.Accumulator(3)  # loss_D, loss_G, num_examples\n",
    "        for (X,) in data_iter:\n",
    "            batch_size = X.shape[0]\n",
    "            Z = tf.random.normal(\n",
    "                mean=0, stddev=1, shape=(batch_size, latent_dim))\n",
    "            metric.add(update_D(X, Z, net_D, net_G, loss, optimizer_D),\n",
    "                       update_G(Z, net_D, net_G, loss, optimizer_G),\n",
    "                       batch_size)\n",
    "        # Visualize generated examples\n",
    "        Z = tf.random.normal(mean=0, stddev=1, shape=(100, latent_dim))\n",
    "        fake_X = net_G(Z)\n",
    "        animator.axes[1].cla()\n",
    "        animator.axes[1].scatter(data[:, 0], data[:, 1])\n",
    "        animator.axes[1].scatter(fake_X[:, 0], fake_X[:, 1])\n",
    "        animator.axes[1].legend([\"real\", \"generated\"])\n",
    "\n",
    "        # Show the losses\n",
    "        loss_D, loss_G = metric[0] / metric[2], metric[1] / metric[2]\n",
    "        animator.add(epoch + 1, (loss_D, loss_G))\n",
    "\n",
    "    print(f'loss_D {loss_D:.3f}, loss_G {loss_G:.3f}, '\n",
    "          f'{metric[2] / timer.stop():.1f} examples/sec')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 31
   },
   "source": [
    "Now we specify the hyperparameters to fit the Gaussian distribution.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "origin_pos": 32,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "loss_D 0.693, loss_G 0.694, 337.6 examples/sec\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",
       "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"341.114062pt\" height=\"302.878125pt\" viewBox=\"0 0 341.114062 302.878125\" 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-24T13:08:42.134031</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 302.878125 \n",
       "L 341.114062 302.878125 \n",
       "L 341.114062 0 \n",
       "L 0 0 \n",
       "L 0 302.878125 \n",
       "z\n",
       "\" style=\"fill: none\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 43.78125 125.373913 \n",
       "L 322.78125 125.373913 \n",
       "L 322.78125 7.2 \n",
       "L 43.78125 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 65.807566 125.373913 \n",
       "L 65.807566 7.2 \n",
       "\" clip-path=\"url(#p1aeba1b193)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_2\">\n",
       "      <defs>\n",
       "       <path id=\"mef9a01998c\" 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=\"#mef9a01998c\" x=\"65.807566\" y=\"125.373913\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 2.5 -->\n",
       "      <g transform=\"translate(57.856003 139.972351)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",
       "        <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",
       "        <path id=\"DejaVuSans-35\" d=\"M 691 4666 \n",
       "L 3169 4666 \n",
       "L 3169 4134 \n",
       "L 1269 4134 \n",
       "L 1269 2991 \n",
       "Q 1406 3038 1543 3061 \n",
       "Q 1681 3084 1819 3084 \n",
       "Q 2600 3084 3056 2656 \n",
       "Q 3513 2228 3513 1497 \n",
       "Q 3513 744 3044 326 \n",
       "Q 2575 -91 1722 -91 \n",
       "Q 1428 -91 1123 -41 \n",
       "Q 819 9 494 109 \n",
       "L 494 744 \n",
       "Q 775 591 1075 516 \n",
       "Q 1375 441 1709 441 \n",
       "Q 2250 441 2565 725 \n",
       "Q 2881 1009 2881 1497 \n",
       "Q 2881 1984 2565 2268 \n",
       "Q 2250 2553 1709 2553 \n",
       "Q 1456 2553 1204 2497 \n",
       "Q 953 2441 691 2322 \n",
       "L 691 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <path d=\"M 102.518092 125.373913 \n",
       "L 102.518092 7.2 \n",
       "\" clip-path=\"url(#p1aeba1b193)\" 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=\"#mef9a01998c\" x=\"102.518092\" y=\"125.373913\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 5.0 -->\n",
       "      <g transform=\"translate(94.56653 139.972351)scale(0.1 -0.1)\">\n",
       "       <defs>\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-35\"/>\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=\"xtick_3\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <path d=\"M 139.228618 125.373913 \n",
       "L 139.228618 7.2 \n",
       "\" clip-path=\"url(#p1aeba1b193)\" 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=\"#mef9a01998c\" x=\"139.228618\" y=\"125.373913\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 7.5 -->\n",
       "      <g transform=\"translate(131.277056 139.972351)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-37\" d=\"M 525 4666 \n",
       "L 3525 4666 \n",
       "L 3525 4397 \n",
       "L 1831 0 \n",
       "L 1172 0 \n",
       "L 2766 4134 \n",
       "L 525 4134 \n",
       "L 525 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-37\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <path d=\"M 175.939145 125.373913 \n",
       "L 175.939145 7.2 \n",
       "\" clip-path=\"url(#p1aeba1b193)\" 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=\"#mef9a01998c\" x=\"175.939145\" y=\"125.373913\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 10.0 -->\n",
       "      <g transform=\"translate(164.806332 139.972351)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",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <path d=\"M 212.649671 125.373913 \n",
       "L 212.649671 7.2 \n",
       "\" clip-path=\"url(#p1aeba1b193)\" 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=\"#mef9a01998c\" x=\"212.649671\" y=\"125.373913\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 12.5 -->\n",
       "      <g transform=\"translate(201.516859 139.972351)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <path d=\"M 249.360197 125.373913 \n",
       "L 249.360197 7.2 \n",
       "\" clip-path=\"url(#p1aeba1b193)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_12\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mef9a01998c\" x=\"249.360197\" y=\"125.373913\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 15.0 -->\n",
       "      <g transform=\"translate(238.227385 139.972351)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_7\">\n",
       "     <g id=\"line2d_13\">\n",
       "      <path d=\"M 286.070724 125.373913 \n",
       "L 286.070724 7.2 \n",
       "\" clip-path=\"url(#p1aeba1b193)\" 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=\"#mef9a01998c\" x=\"286.070724\" y=\"125.373913\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 17.5 -->\n",
       "      <g transform=\"translate(274.937911 139.972351)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-37\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_8\">\n",
       "     <g id=\"line2d_15\">\n",
       "      <path d=\"M 322.78125 125.373913 \n",
       "L 322.78125 7.2 \n",
       "\" clip-path=\"url(#p1aeba1b193)\" 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=\"#mef9a01998c\" x=\"322.78125\" y=\"125.373913\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 20.0 -->\n",
       "      <g transform=\"translate(311.648438 139.972351)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_9\">\n",
       "     <!-- epoch -->\n",
       "     <g transform=\"translate(168.053125 153.650476)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_17\">\n",
       "      <path d=\"M 43.78125 112.80821 \n",
       "L 322.78125 112.80821 \n",
       "\" clip-path=\"url(#p1aeba1b193)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_18\">\n",
       "      <defs>\n",
       "       <path id=\"m51fe5e4981\" 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=\"#m51fe5e4981\" x=\"43.78125\" y=\"112.80821\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- 0.6 -->\n",
       "      <g transform=\"translate(20.878125 116.607428)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-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_2\">\n",
       "     <g id=\"line2d_19\">\n",
       "      <path d=\"M 43.78125 70.213469 \n",
       "L 322.78125 70.213469 \n",
       "\" clip-path=\"url(#p1aeba1b193)\" 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=\"#m51fe5e4981\" x=\"43.78125\" y=\"70.213469\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_11\">\n",
       "      <!-- 0.8 -->\n",
       "      <g transform=\"translate(20.878125 74.012688)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-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_3\">\n",
       "     <g id=\"line2d_21\">\n",
       "      <path d=\"M 43.78125 27.618729 \n",
       "L 322.78125 27.618729 \n",
       "\" clip-path=\"url(#p1aeba1b193)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_22\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m51fe5e4981\" x=\"43.78125\" y=\"27.618729\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_12\">\n",
       "      <!-- 1.0 -->\n",
       "      <g transform=\"translate(20.878125 31.417947)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=\"text_13\">\n",
       "     <!-- loss -->\n",
       "     <g transform=\"translate(14.798438 75.944769)rotate(-90)scale(0.1 -0.1)\">\n",
       "      <defs>\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-6c\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6f\" x=\"27.783203\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" x=\"88.964844\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" x=\"141.064453\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_23\">\n",
       "    <path d=\"M 43.78125 120.002372 \n",
       "L 58.465461 110.651132 \n",
       "L 73.149671 97.41184 \n",
       "L 87.833882 95.734755 \n",
       "L 102.518092 93.329818 \n",
       "L 117.202303 93.043164 \n",
       "L 131.886513 93.343209 \n",
       "L 146.570724 92.801287 \n",
       "L 161.254934 92.694556 \n",
       "L 175.939145 92.820835 \n",
       "L 190.623355 93.125958 \n",
       "L 205.307566 93.171413 \n",
       "L 219.991776 93.50208 \n",
       "L 234.675987 92.733093 \n",
       "L 249.360197 92.569267 \n",
       "L 264.044408 92.955783 \n",
       "L 278.728618 92.940361 \n",
       "L 293.412829 92.96104 \n",
       "L 308.097039 92.968211 \n",
       "L 322.78125 92.972902 \n",
       "\" clip-path=\"url(#p1aeba1b193)\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"line2d_24\">\n",
       "    <path d=\"M 43.78125 12.571542 \n",
       "L 58.465461 26.125793 \n",
       "L 73.149671 77.805059 \n",
       "L 87.833882 82.580788 \n",
       "L 102.518092 91.47431 \n",
       "L 117.202303 92.2297 \n",
       "L 131.886513 90.888482 \n",
       "L 146.570724 90.8704 \n",
       "L 161.254934 92.90158 \n",
       "L 175.939145 92.644549 \n",
       "L 190.623355 91.7046 \n",
       "L 205.307566 81.592186 \n",
       "L 219.991776 91.451877 \n",
       "L 234.675987 91.96745 \n",
       "L 249.360197 92.828291 \n",
       "L 264.044408 92.436234 \n",
       "L 278.728618 92.854235 \n",
       "L 293.412829 92.949098 \n",
       "L 308.097039 92.904864 \n",
       "L 322.78125 92.892783 \n",
       "\" clip-path=\"url(#p1aeba1b193)\" style=\"fill: none; stroke-dasharray: 5.55,2.4; stroke-dashoffset: 0; stroke: #bf00bf; stroke-width: 1.5\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 43.78125 125.373913 \n",
       "L 43.78125 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 322.78125 125.373913 \n",
       "L 322.78125 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 43.78125 125.373913 \n",
       "L 322.78125 125.373913 \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 43.78125 7.2 \n",
       "L 322.78125 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 217.923437 44.55625 \n",
       "L 315.78125 44.55625 \n",
       "Q 317.78125 44.55625 317.78125 42.55625 \n",
       "L 317.78125 14.2 \n",
       "Q 317.78125 12.2 315.78125 12.2 \n",
       "L 217.923437 12.2 \n",
       "Q 215.923437 12.2 215.923437 14.2 \n",
       "L 215.923437 42.55625 \n",
       "Q 215.923437 44.55625 217.923437 44.55625 \n",
       "z\n",
       "\" style=\"fill: #ffffff; opacity: 0.8; stroke: #cccccc; stroke-linejoin: miter\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_25\">\n",
       "     <path d=\"M 219.923437 20.298437 \n",
       "L 229.923437 20.298437 \n",
       "L 239.923437 20.298437 \n",
       "\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "    </g>\n",
       "    <g id=\"text_14\">\n",
       "     <!-- discriminator -->\n",
       "     <g transform=\"translate(247.923437 23.798437)scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-64\" d=\"M 2906 2969 \n",
       "L 2906 4863 \n",
       "L 3481 4863 \n",
       "L 3481 0 \n",
       "L 2906 0 \n",
       "L 2906 525 \n",
       "Q 2725 213 2448 61 \n",
       "Q 2172 -91 1784 -91 \n",
       "Q 1150 -91 751 415 \n",
       "Q 353 922 353 1747 \n",
       "Q 353 2572 751 3078 \n",
       "Q 1150 3584 1784 3584 \n",
       "Q 2172 3584 2448 3432 \n",
       "Q 2725 3281 2906 2969 \n",
       "z\n",
       "M 947 1747 \n",
       "Q 947 1113 1208 752 \n",
       "Q 1469 391 1925 391 \n",
       "Q 2381 391 2643 752 \n",
       "Q 2906 1113 2906 1747 \n",
       "Q 2906 2381 2643 2742 \n",
       "Q 2381 3103 1925 3103 \n",
       "Q 1469 3103 1208 2742 \n",
       "Q 947 2381 947 1747 \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-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-6d\" d=\"M 3328 2828 \n",
       "Q 3544 3216 3844 3400 \n",
       "Q 4144 3584 4550 3584 \n",
       "Q 5097 3584 5394 3201 \n",
       "Q 5691 2819 5691 2113 \n",
       "L 5691 0 \n",
       "L 5113 0 \n",
       "L 5113 2094 \n",
       "Q 5113 2597 4934 2840 \n",
       "Q 4756 3084 4391 3084 \n",
       "Q 3944 3084 3684 2787 \n",
       "Q 3425 2491 3425 1978 \n",
       "L 3425 0 \n",
       "L 2847 0 \n",
       "L 2847 2094 \n",
       "Q 2847 2600 2669 2842 \n",
       "Q 2491 3084 2119 3084 \n",
       "Q 1678 3084 1418 2786 \n",
       "Q 1159 2488 1159 1978 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2956 \n",
       "Q 1356 3278 1631 3431 \n",
       "Q 1906 3584 2284 3584 \n",
       "Q 2666 3584 2933 3390 \n",
       "Q 3200 3197 3328 2828 \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-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-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",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-64\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-69\" x=\"63.476562\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" x=\"91.259766\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" x=\"143.359375\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" x=\"198.339844\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-69\" x=\"239.453125\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6d\" x=\"267.236328\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-69\" x=\"364.648438\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6e\" x=\"392.431641\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" x=\"455.810547\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-74\" x=\"517.089844\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6f\" x=\"556.298828\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" x=\"617.480469\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"line2d_26\">\n",
       "     <path d=\"M 219.923437 34.976562 \n",
       "L 229.923437 34.976562 \n",
       "L 239.923437 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_15\">\n",
       "     <!-- generator -->\n",
       "     <g transform=\"translate(247.923437 38.476562)scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-67\" d=\"M 2906 1791 \n",
       "Q 2906 2416 2648 2759 \n",
       "Q 2391 3103 1925 3103 \n",
       "Q 1463 3103 1205 2759 \n",
       "Q 947 2416 947 1791 \n",
       "Q 947 1169 1205 825 \n",
       "Q 1463 481 1925 481 \n",
       "Q 2391 481 2648 825 \n",
       "Q 2906 1169 2906 1791 \n",
       "z\n",
       "M 3481 434 \n",
       "Q 3481 -459 3084 -895 \n",
       "Q 2688 -1331 1869 -1331 \n",
       "Q 1566 -1331 1297 -1286 \n",
       "Q 1028 -1241 775 -1147 \n",
       "L 775 -588 \n",
       "Q 1028 -725 1275 -790 \n",
       "Q 1522 -856 1778 -856 \n",
       "Q 2344 -856 2625 -561 \n",
       "Q 2906 -266 2906 331 \n",
       "L 2906 616 \n",
       "Q 2728 306 2450 153 \n",
       "Q 2172 0 1784 0 \n",
       "Q 1141 0 747 490 \n",
       "Q 353 981 353 1791 \n",
       "Q 353 2603 747 3093 \n",
       "Q 1141 3584 1784 3584 \n",
       "Q 2172 3584 2450 3431 \n",
       "Q 2728 3278 2906 2969 \n",
       "L 2906 3500 \n",
       "L 3481 3500 \n",
       "L 3481 434 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-67\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" x=\"63.476562\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6e\" x=\"125\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" x=\"188.378906\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" x=\"249.902344\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" x=\"291.015625\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-74\" x=\"352.294922\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6f\" x=\"391.503906\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" x=\"452.685547\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       "  <g id=\"axes_2\">\n",
       "   <g id=\"patch_8\">\n",
       "    <path d=\"M 43.78125 279 \n",
       "L 322.78125 279 \n",
       "L 322.78125 160.826087 \n",
       "L 43.78125 160.826087 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_1\">\n",
       "    <defs>\n",
       "     <path id=\"m29dd32cd0d\" d=\"M 0 3 \n",
       "C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \n",
       "C 2.683901 1.55874 3 0.795609 3 0 \n",
       "C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \n",
       "C 1.55874 -2.683901 0.795609 -3 0 -3 \n",
       "C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \n",
       "C -2.683901 -1.55874 -3 -0.795609 -3 0 \n",
       "C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \n",
       "C -1.55874 2.683901 -0.795609 3 0 3 \n",
       "z\n",
       "\" style=\"stroke: #1f77b4\"/>\n",
       "    </defs>\n",
       "    <g clip-path=\"url(#p8f1f66b149)\">\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"116.043497\" y=\"253.297943\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"218.707456\" y=\"210.294737\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"215.172359\" y=\"209.23618\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"170.613011\" y=\"222.457029\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"149.154731\" y=\"237.204873\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"216.203271\" y=\"211.667488\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"216.759442\" y=\"204.974785\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"235.37629\" y=\"196.740244\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"192.338797\" y=\"221.138759\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"244.657553\" y=\"200.072228\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"139.471903\" y=\"238.617168\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"103.258827\" y=\"254.858724\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"197.652151\" y=\"203.958851\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"216.857525\" y=\"199.907674\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"149.660477\" y=\"225.476921\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"125.812772\" y=\"240.844667\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"185.491776\" y=\"232.790467\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"229.065953\" y=\"205.957008\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"221.415774\" y=\"196.944372\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"174.368242\" y=\"236.674753\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"200.475839\" y=\"209.219371\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"247.052127\" y=\"202.136728\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"198.536078\" y=\"216.253658\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"255.643033\" y=\"200.449419\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"224.7692\" y=\"200.028482\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"210.579367\" y=\"216.090848\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"121.406098\" y=\"248.987926\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"203.655349\" y=\"213.150879\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"79.60326\" y=\"263.520431\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"233.575296\" y=\"196.865199\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"174.56664\" y=\"224.879664\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"249.134093\" y=\"202.181297\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"161.393892\" y=\"225.250848\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"168.372423\" y=\"234.046779\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"204.690279\" y=\"207.106809\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"204.606208\" y=\"216.204243\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"147.798972\" y=\"230.848935\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"200.183343\" y=\"218.939205\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"120.189502\" y=\"248.709625\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"86.150512\" y=\"255.681005\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"201.49536\" y=\"215.99655\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"232.537253\" y=\"198.17532\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"162.760717\" y=\"225.633383\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"196.847763\" y=\"215.088587\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"170.932378\" y=\"221.409992\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"187.405641\" y=\"225.671587\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"212.292125\" y=\"215.37902\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"190.020813\" y=\"217.212204\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"157.829131\" y=\"238.414597\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"277.805058\" y=\"193.463479\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"231.334644\" y=\"203.247823\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"237.132053\" y=\"206.210938\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"184.780736\" y=\"213.337467\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"254.295186\" y=\"208.587775\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"160.734212\" y=\"225.650826\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"169.587642\" y=\"227.301306\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"140.264432\" y=\"241.294425\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"176.249409\" y=\"220.682834\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"237.291622\" y=\"202.285132\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"240.959672\" y=\"199.142831\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"121.811892\" y=\"244.859775\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"189.521136\" y=\"232.225794\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"153.122526\" y=\"231.950945\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"229.871209\" y=\"205.711827\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"144.041387\" y=\"238.770906\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"219.365849\" y=\"213.221715\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"164.157166\" y=\"238.081889\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"310.099432\" y=\"166.197628\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"153.222922\" y=\"233.044576\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"138.250087\" y=\"223.615948\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"204.495225\" y=\"209.377415\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"218.173133\" y=\"204.145679\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"210.861838\" y=\"208.904015\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"163.22826\" y=\"235.153441\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"160.289366\" y=\"234.545483\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"228.936495\" y=\"198.071487\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"158.320045\" y=\"235.727865\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"145.128011\" y=\"229.868501\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"183.279724\" y=\"223.998751\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"171.289327\" y=\"228.246061\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"242.874502\" y=\"194.247556\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"153.390614\" y=\"239.991513\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"229.478726\" y=\"200.070698\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"167.77689\" y=\"229.603521\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"181.788176\" y=\"221.727396\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"187.048987\" y=\"214.202521\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"218.730731\" y=\"210.343732\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"169.68281\" y=\"232.096694\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"170.419208\" y=\"235.755273\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"56.463068\" y=\"273.628458\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"171.338721\" y=\"230.794023\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"244.410652\" y=\"198.522901\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"200.172734\" y=\"219.694263\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"141.916582\" y=\"244.433828\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"205.03318\" y=\"220.157608\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"283.170909\" y=\"180.043412\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"170.212148\" y=\"239.455596\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"95.759817\" y=\"256.763226\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"198.407656\" y=\"225.286249\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m29dd32cd0d\" x=\"295.835481\" y=\"174.737137\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_2\">\n",
       "    <defs>\n",
       "     <path id=\"m42da4c7223\" d=\"M 0 3 \n",
       "C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \n",
       "C 2.683901 1.55874 3 0.795609 3 0 \n",
       "C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \n",
       "C 1.55874 -2.683901 0.795609 -3 0 -3 \n",
       "C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \n",
       "C -2.683901 -1.55874 -3 -0.795609 -3 0 \n",
       "C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \n",
       "C -1.55874 2.683901 -0.795609 3 0 3 \n",
       "z\n",
       "\" style=\"stroke: #ff7f0e\"/>\n",
       "    </defs>\n",
       "    <g clip-path=\"url(#p8f1f66b149)\">\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"143.195033\" y=\"245.505596\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"260.704148\" y=\"184.66322\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"128.995717\" y=\"246.85185\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"186.150707\" y=\"221.591281\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"207.438479\" y=\"212.122265\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"181.140491\" y=\"212.442781\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"239.621373\" y=\"202.312975\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"110.635694\" y=\"250.516839\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"234.187306\" y=\"195.761407\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"208.087975\" y=\"211.728365\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"211.4291\" y=\"207.552819\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"162.468041\" y=\"233.481\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"224.385285\" y=\"210.090637\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"98.185248\" y=\"257.585618\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"145.200698\" y=\"247.907507\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"162.855326\" y=\"229.871838\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"180.479805\" y=\"228.028761\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"173.163127\" y=\"225.513323\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"211.449917\" y=\"206.351927\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"149.307474\" y=\"237.517032\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"234.585681\" y=\"200.351061\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"241.39574\" y=\"190.692497\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"143.323993\" y=\"249.648157\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"205.04905\" y=\"207.843542\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"182.978074\" y=\"211.666476\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"110.694514\" y=\"259.547863\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"212.278702\" y=\"213.465954\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"228.389674\" y=\"193.555587\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"144.392106\" y=\"241.398553\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"183.670059\" y=\"223.031065\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"288.880093\" y=\"173.191471\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"289.83435\" y=\"174.136621\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"258.62273\" y=\"182.018012\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"179.019138\" y=\"221.741193\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"155.120569\" y=\"229.576386\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"192.380096\" y=\"216.980766\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"201.851242\" y=\"214.141724\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"229.233308\" y=\"197.890213\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"185.488482\" y=\"221.721753\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"202.539437\" y=\"215.304955\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"169.378083\" y=\"226.715205\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"217.872501\" y=\"191.886879\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"115.3653\" y=\"254.374639\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"191.129722\" y=\"215.212566\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"214.146677\" y=\"194.488485\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"232.125857\" y=\"186.75123\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"246.108099\" y=\"194.314341\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"200.129891\" y=\"214.316394\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"136.078105\" y=\"253.864965\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"146.877947\" y=\"234.813845\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"117.773504\" y=\"256.690537\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"159.42193\" y=\"239.331344\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"128.869245\" y=\"239.186564\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"185.20415\" y=\"217.23692\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"174.904742\" y=\"231.875482\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"205.684321\" y=\"214.816561\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"157.201311\" y=\"234.903543\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"135.076659\" y=\"239.268016\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"145.958632\" y=\"237.327371\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"168.025934\" y=\"233.34525\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"158.677412\" y=\"227.663284\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"197.894607\" y=\"214.426543\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"279.281017\" y=\"188.192005\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"204.229382\" y=\"217.63384\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"193.078102\" y=\"212.144225\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"219.654165\" y=\"203.564058\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"204.439793\" y=\"213.544555\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"156.745663\" y=\"235.790508\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"217.019694\" y=\"211.288708\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"200.94183\" y=\"215.50789\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"158.838472\" y=\"236.745983\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"140.436614\" y=\"248.655649\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"131.426516\" y=\"244.507737\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"177.033561\" y=\"217.084062\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"153.566785\" y=\"226.220718\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"226.461548\" y=\"206.877317\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"141.977553\" y=\"239.111777\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"180.058979\" y=\"225.315969\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"162.187538\" y=\"229.616122\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"188.46334\" y=\"218.295819\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"185.967797\" y=\"222.339942\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"197.208115\" y=\"213.096229\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"213.553102\" y=\"200.719233\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"234.684835\" y=\"203.478704\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"210.845769\" y=\"211.76694\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"164.461191\" y=\"234.239965\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"242.908143\" y=\"203.896402\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"174.369657\" y=\"226.30275\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"191.496749\" y=\"215.2768\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"123.942113\" y=\"247.749449\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"212.943347\" y=\"202.501262\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"190.905942\" y=\"219.290113\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"210.13692\" y=\"209.578482\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"195.56603\" y=\"218.83889\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"190.773289\" y=\"213.624613\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"218.066706\" y=\"202.471216\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"239.94234\" y=\"196.828686\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"144.312027\" y=\"242.537702\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"130.421708\" y=\"250.26992\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#m42da4c7223\" x=\"172.225859\" y=\"224.102969\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_3\">\n",
       "    <g id=\"xtick_9\">\n",
       "     <g id=\"line2d_27\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mef9a01998c\" x=\"65.727872\" y=\"279\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_16\">\n",
       "      <!-- −2 -->\n",
       "      <g transform=\"translate(58.356778 293.598437)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-2212\" d=\"M 678 2272 \n",
       "L 4684 2272 \n",
       "L 4684 1741 \n",
       "L 678 1741 \n",
       "L 678 2272 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"83.789062\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_10\">\n",
       "     <g id=\"line2d_28\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mef9a01998c\" x=\"108.33014\" y=\"279\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_17\">\n",
       "      <!-- −1 -->\n",
       "      <g transform=\"translate(100.959046 293.598437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"83.789062\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_11\">\n",
       "     <g id=\"line2d_29\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mef9a01998c\" x=\"150.932408\" y=\"279\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_18\">\n",
       "      <!-- 0 -->\n",
       "      <g transform=\"translate(147.751158 293.598437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_12\">\n",
       "     <g id=\"line2d_30\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mef9a01998c\" x=\"193.534677\" y=\"279\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_19\">\n",
       "      <!-- 1 -->\n",
       "      <g transform=\"translate(190.353427 293.598437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_13\">\n",
       "     <g id=\"line2d_31\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mef9a01998c\" x=\"236.136945\" y=\"279\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_20\">\n",
       "      <!-- 2 -->\n",
       "      <g transform=\"translate(232.955695 293.598437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_14\">\n",
       "     <g id=\"line2d_32\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mef9a01998c\" x=\"278.739213\" y=\"279\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_21\">\n",
       "      <!-- 3 -->\n",
       "      <g transform=\"translate(275.557963 293.598437)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-33\" d=\"M 2597 2516 \n",
       "Q 3050 2419 3304 2112 \n",
       "Q 3559 1806 3559 1356 \n",
       "Q 3559 666 3084 287 \n",
       "Q 2609 -91 1734 -91 \n",
       "Q 1441 -91 1130 -33 \n",
       "Q 819 25 488 141 \n",
       "L 488 750 \n",
       "Q 750 597 1062 519 \n",
       "Q 1375 441 1716 441 \n",
       "Q 2309 441 2620 675 \n",
       "Q 2931 909 2931 1356 \n",
       "Q 2931 1769 2642 2001 \n",
       "Q 2353 2234 1838 2234 \n",
       "L 1294 2234 \n",
       "L 1294 2753 \n",
       "L 1863 2753 \n",
       "Q 2328 2753 2575 2939 \n",
       "Q 2822 3125 2822 3475 \n",
       "Q 2822 3834 2567 4026 \n",
       "Q 2313 4219 1838 4219 \n",
       "Q 1578 4219 1281 4162 \n",
       "Q 984 4106 628 3988 \n",
       "L 628 4550 \n",
       "Q 988 4650 1302 4700 \n",
       "Q 1616 4750 1894 4750 \n",
       "Q 2613 4750 3031 4423 \n",
       "Q 3450 4097 3450 3541 \n",
       "Q 3450 3153 3228 2886 \n",
       "Q 3006 2619 2597 2516 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-33\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_15\">\n",
       "     <g id=\"line2d_33\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mef9a01998c\" x=\"321.341481\" y=\"279\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_22\">\n",
       "      <!-- 4 -->\n",
       "      <g transform=\"translate(318.160231 293.598437)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>\n",
       "   <g id=\"matplotlib.axis_4\">\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_34\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m51fe5e4981\" x=\"43.78125\" y=\"278.496128\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_23\">\n",
       "      <!-- −5 -->\n",
       "      <g transform=\"translate(22.039063 282.295346)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"83.789062\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_35\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m51fe5e4981\" x=\"43.78125\" y=\"235.356027\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_24\">\n",
       "      <!-- 0 -->\n",
       "      <g transform=\"translate(30.41875 239.155245)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"line2d_36\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m51fe5e4981\" x=\"43.78125\" y=\"192.215926\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_25\">\n",
       "      <!-- 5 -->\n",
       "      <g transform=\"translate(30.41875 196.015145)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-35\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"patch_9\">\n",
       "    <path d=\"M 43.78125 279 \n",
       "L 43.78125 160.826087 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_10\">\n",
       "    <path d=\"M 322.78125 279 \n",
       "L 322.78125 160.826087 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_11\">\n",
       "    <path d=\"M 43.78125 279 \n",
       "L 322.78125 279 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_12\">\n",
       "    <path d=\"M 43.78125 160.826087 \n",
       "L 322.78125 160.826087 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"legend_2\">\n",
       "    <g id=\"patch_13\">\n",
       "     <path d=\"M 50.78125 198.182337 \n",
       "L 134.434375 198.182337 \n",
       "Q 136.434375 198.182337 136.434375 196.182337 \n",
       "L 136.434375 167.826087 \n",
       "Q 136.434375 165.826087 134.434375 165.826087 \n",
       "L 50.78125 165.826087 \n",
       "Q 48.78125 165.826087 48.78125 167.826087 \n",
       "L 48.78125 196.182337 \n",
       "Q 48.78125 198.182337 50.78125 198.182337 \n",
       "z\n",
       "\" style=\"fill: #ffffff; opacity: 0.8; stroke: #cccccc; stroke-linejoin: miter\"/>\n",
       "    </g>\n",
       "    <g id=\"PathCollection_3\">\n",
       "     <g>\n",
       "      <use xlink:href=\"#m29dd32cd0d\" x=\"62.78125\" y=\"174.799524\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_26\">\n",
       "     <!-- real -->\n",
       "     <g transform=\"translate(80.78125 177.424524)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-72\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" x=\"38.863281\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" x=\"100.386719\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6c\" x=\"161.666016\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"PathCollection_4\">\n",
       "     <g>\n",
       "      <use xlink:href=\"#m42da4c7223\" x=\"62.78125\" y=\"189.477649\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_27\">\n",
       "     <!-- generated -->\n",
       "     <g transform=\"translate(80.78125 192.102649)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-67\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" x=\"63.476562\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6e\" x=\"125\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" x=\"188.378906\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" x=\"249.902344\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" x=\"291.015625\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-74\" x=\"352.294922\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" x=\"391.503906\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-64\" x=\"453.027344\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p1aeba1b193\">\n",
       "   <rect x=\"43.78125\" y=\"7.2\" width=\"279\" height=\"118.173913\"/>\n",
       "  </clipPath>\n",
       "  <clipPath id=\"p8f1f66b149\">\n",
       "   <rect x=\"43.78125\" y=\"160.826087\" width=\"279\" height=\"118.173913\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 360x360 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "lr_D, lr_G, latent_dim, num_epochs = 0.05, 0.005, 2, 20\n",
    "train(net_D, net_G, data_iter, num_epochs, lr_D, lr_G,\n",
    "      latent_dim, data[:100].numpy())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 33
   },
   "source": [
    "## Summary\n",
    "\n",
    "* Generative adversarial networks (GANs) composes of two deep networks, the generator and the discriminator.\n",
    "* The generator generates the image as much closer to the true image as possible to fool the discriminator, via maximizing the cross-entropy loss, *i.e.*, $\\max \\log(D(\\mathbf{x'}))$.\n",
    "* The discriminator tries to distinguish the generated images from the true images, via minimizing the cross-entropy loss, *i.e.*, $\\min - y \\log D(\\mathbf{x}) - (1-y)\\log(1-D(\\mathbf{x}))$.\n",
    "\n",
    "## Exercises\n",
    "\n",
    "* Does an equilibrium exist where the generator wins, *i.e.* the discriminator ends up unable to distinguish the two distributions on finite samples?\n"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}