<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Ashutosh</title>
    <description>Ashutosh Mishra&apos;s personal site, blog and resume/portfolio.</description>
    <link>https://ashutoshmishra.dev/</link>
    <atom:link href="https://ashutoshmishra.dev/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Sun, 22 Nov 2026 08:24:25 +0000</pubDate>
    <lastBuildDate>Sun, 22 Nov 2026 08:24:25 +0000</lastBuildDate>
    <generator>Jekyll v3.10.0</generator>
    
      <item>
        <title>Four Pages to Read a Blood Test: OpenBMB’s MiniCPM‑V Learns What It Was Skipping</title>
        <description>&lt;p&gt;Small vision-language models that run on a laptop or phone can miss important parts of a real document, and on-device you don’t have a server to fine-tune them. In this post I test whether four corrected blood test reports are enough to fix one of those failures in OpenBMB’s MiniCPM-V-4.7-1B using a single forward pass of a LoRA hypernetwork. You’ll see how I found the failure, how the generated adapter did on unseen reports, and every way it still falls short.&lt;/p&gt;

&lt;p&gt;In the &lt;a href=&quot;/blog/show-to-lora/&quot;&gt;previous post&lt;/a&gt; I wrote about Show-to-LoRA, a small network that reads a few example pages of a new document type and outputs a LoRA adapter for a frozen vision-language model in one forward pass. Averaged over 78 held-out tasks, the method works. Averages on synthetic forms and public benchmarks only tell you so much, though. They don’t show whether it helps on a real document someone actually needs read.&lt;/p&gt;

&lt;p&gt;I wanted one concrete case where the base model clearly fails, so I could check whether four corrected pages would fix it. Blood test reports gave me that case.&lt;/p&gt;

&lt;p&gt;The model is &lt;a href=&quot;https://huggingface.co/openbmb/MiniCPM-V-4.7-1B&quot;&gt;MiniCPM-V-4.7-1B&lt;/a&gt; from &lt;a href=&quot;https://github.com/OpenBMB&quot;&gt;OpenBMB&lt;/a&gt;, a vision-language model small enough to run on a laptop or phone. This work is part of my entry to OpenBMB’s MiniCPM Spark Program (On-Device Agent Challenge). Running on-device is where a cheap, per-document skill actually matters, because there is no server to fine-tune on.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The short version:&lt;/strong&gt; on complete blood count (CBC) reports from one lab, MiniCPM-V-4.7-1B reads the first nine rows and stops, skipping the whole differential count. An adapter built from 4 corrected reports in 34 seconds got the same model reading the differential percentages. It beat the base model on &lt;strong&gt;all 8&lt;/strong&gt; unseen reports, pushing field F1 from &lt;strong&gt;0.50 to 0.73&lt;/strong&gt;. It still misses the absolute counts, and I’ll walk through every place it goes wrong below.&lt;/p&gt;

&lt;h2 id=&quot;the-data&quot;&gt;The data&lt;/h2&gt;

&lt;p&gt;The reports come from the public &lt;a href=&quot;https://doi.org/10.17632/bygfmk4rx9.2&quot;&gt;Clinical Laboratory Test Reports&lt;/a&gt; dataset on Mendeley Data (CC BY 4.0). It holds 260 real scanned and printed reports from 24 laboratories in Egypt, written in English with Arabic headers. Because the dataset has no structured labels, I made them myself.&lt;/p&gt;

&lt;h2 id=&quot;finding-where-the-model-fails&quot;&gt;Finding where the model fails&lt;/h2&gt;

&lt;p&gt;My first attempt was on Alfa Laboratories’ chemistry and hormone panels, and it turned up nothing. Those pages have clean printed rows, so the base model already scored 0.97 F1. There wasn’t room for an adapter to help, and on 6 test pages it didn’t (0.965).&lt;/p&gt;

&lt;p&gt;That negative result was still useful. A skill only helps where the base model is wrong, so I needed to find a real failure first. I ran the base model alone on 3 pages from each of 7 lab layouts and checked every output against its page by eye.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Layout&lt;/th&gt;
      &lt;th&gt;What the base model did&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Blood counts at Alfa, Al Mokhtabar, Omega and Grand&lt;/td&gt;
      &lt;td&gt;Read the first ~9 rows, then stopped. The differential count was dropped on every page&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Green Lab blood count&lt;/td&gt;
      &lt;td&gt;Returned no rows at all&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Mabaret El Asafra (mostly blank forms)&lt;/td&gt;
      &lt;td&gt;Put reference ranges in the result column&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Single tests (ferritin, CRP), lipids, urine&lt;/td&gt;
      &lt;td&gt;Mostly right&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Every lab that prints a blood count triggered the same failure, and it hits a part of the report that matters. The differential count splits white blood cells into six types, which a doctor reads to tell, for example, a bacterial infection from a viral one.&lt;/p&gt;

&lt;h2 id=&quot;the-test&quot;&gt;The test&lt;/h2&gt;

&lt;p&gt;I went with Alfa Laboratories blood counts, the most common layout in the dataset. Four reports appear more than once in the dataset, so I removed the duplicates before splitting, leaving 17 distinct reports.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;4 reports taught the skill.&lt;/strong&gt; Each came with its correct JSON, the “corrections” a user would supply.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;8 other reports were only scored.&lt;/strong&gt; The hypernetwork never saw them, and it had never seen any lab report during training either.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Each label has 21 rows:&lt;/strong&gt; 9 main counts, 6 differential percentages, and 6 absolute counts, each with its unit and reference range. I drafted the labels from the images, and a person checked every page against the original.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both models ran with the same plain prompt, greedy decoding, and the same A10G GPU:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Extract the lab unit and every test row from this lab report.
Return only JSON with this shape: {&quot;unit&quot;: str, &quot;tests&quot;: [{&quot;name&quot;: str, &quot;result&quot;: str, &quot;unit&quot;: str, &quot;range&quot;: str}]}
Copy text exactly as printed. Use an empty string or empty list when a field is absent.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Nothing in the prompt tells the model that differential rows count as test rows. It only learns that from the four examples.&lt;/p&gt;

&lt;h2 id=&quot;what-changed-on-the-page&quot;&gt;What changed on the page&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/static/portfolio/blog-covers/cbc-annotated.png&quot; alt=&quot;A blood count report annotated in four regions: main counts read by both models, differential percentages read only with the adapter, absolute counts missed by both, and a platelet count both models misread&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;One of the 8 test reports. (1) The nine main counts: both models read them. (2) The differential percentages: the base model returned none, while the adapter returned all six correctly. (3) The absolute counts: neither model returned them under the cells’ names. (4) Both models read the platelet count of 287 as 227.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here is the end of each model’s output for that report:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Base model (stops here)            With the emitted adapter
-----------------------            ------------------------
T-LC          8.2   x10^9/uL       T-LC          8.2   x10^9/uL
                                   Basophils     1     %   0 - 1
                                   Eosinophils   2     %   0 - 6
                                   Stab          0     %   0 - 7
                                   Segmented     60    %   40 - 75
                                   Lymphocytes   29    %   20 - 45
                                   Monocytes     8     %   1 - 10
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;results&quot;&gt;Results&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/static/portfolio/blog-covers/cbc-per-report.png&quot; alt=&quot;Dot plot of field F1 per report: the adapter beats the base model on all 8 unseen reports&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Field F1 per unseen report. Grey: base model. Blue: with the adapter written from 4 example reports.&lt;/em&gt;&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt; &lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Base model&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;With the adapter&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Field F1 (8 reports)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.496&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;0.733&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Recall&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.356&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.701&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Precision&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.817&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.769&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Reports better&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8 of 8&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;F1 is computed over (field, value) pairs after Unicode and whitespace normalisation, ignoring row order.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/static/portfolio/blog-covers/cbc-what-was-read.png&quot; alt=&quot;Bar chart of values read correctly: main counts 51 of 72 for the base model and 59 of 72 with the adapter; differential percentages 0 of 48 and 44 of 48; absolute counts 0 of 48 for both&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Where the gain comes from. Almost all of it is the differential percentages, going from 0 of 48 to 44 of 48.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Building the skill took &lt;strong&gt;34 seconds&lt;/strong&gt; on the GPU and produced a &lt;strong&gt;3.6 MB&lt;/strong&gt; file. Because the base model weights stay untouched, a device can keep a library of these skills and load the right one for each document. Generation does take longer with the adapter, about 20 to 30 seconds per report on an A10G compared to about 15 for the base model, because the model is now writing out the rows it used to skip.&lt;/p&gt;

&lt;h2 id=&quot;what-still-doesnt-work&quot;&gt;What still doesn’t work&lt;/h2&gt;

&lt;p&gt;I didn’t expect a 1B model on a phone to read every report perfectly, and this skill doesn’t either. Here is where it still falls short:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Absolute counts are still missed.&lt;/strong&gt; The skill reads that column group, but it labels the rows “Absolute Count” instead of naming the cell. Those 48 values don’t count.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;A heading sometimes turns into a row.&lt;/strong&gt; On 2 of the 8 reports, that shifts the percentages down by one row. That’s also why precision lands slightly below the base model’s (0.77 vs. 0.82).&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;The output shape matters.&lt;/strong&gt; When I asked for a separate &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;differential&lt;/code&gt; section, results got worse (0.51 vs. 0.85). The hypernetwork only learned flat lists.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;The test set is small:&lt;/strong&gt; 8 reports from one lab.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This isn’t a medical tool, so check every value against the original report.&lt;/p&gt;

&lt;h2 id=&quot;try-it&quot;&gt;Try it&lt;/h2&gt;

&lt;p&gt;The adapter is on Hugging Face at &lt;a href=&quot;https://huggingface.co/ASHu2/openT2L-skill-alfa-cbc&quot;&gt;ASHu2/openT2L-skill-alfa-cbc&lt;/a&gt;. It’s a standard PEFT LoRA, with the exact prompt and the names of the 4 example reports saved in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;skill.json&lt;/code&gt;. It was generated by the &lt;a href=&quot;https://huggingface.co/ASHu2/openT2L-MiniCPM-V-4.7-1B-docs&quot;&gt;openT2L hypernetwork&lt;/a&gt; and carries the same non-commercial license (CC BY-NC 4.0) as the hypernetwork. I’m not redistributing the report images, since they’re available in the Mendeley dataset linked above.&lt;/p&gt;

&lt;p&gt;I’ll add the agent code (learning a skill, keeping it in a local library, and switching adapters per document) along with the script behind every number in this post to &lt;a href=&quot;https://github.com/ASH1998/openBMB-spark-t2l&quot;&gt;openBMB-spark-t2l&lt;/a&gt; with the rest of the project.&lt;/p&gt;

&lt;p&gt;The failures make the next steps pretty clear. First, I need to teach the hypernetwork to produce outputs with more than one section, so a schema like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tests&lt;/code&gt; plus &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;differential&lt;/code&gt; works. Second, I want to run the whole loop on a laptop with llama.cpp instead of a cloud GPU.&lt;/p&gt;
</description>
        <pubDate>Sun, 22 Nov 2026 05:00:00 +0000</pubDate>
        <link>https://ashutoshmishra.dev/blog/show-to-lora-blood-counts/</link>
        <guid isPermaLink="true">https://ashutoshmishra.dev/blog/show-to-lora-blood-counts/</guid>
        
        <category>OpenBMB</category>
        
        <category>MiniCPM</category>
        
        <category>MiniCPM-V</category>
        
        <category>LoRA</category>
        
        <category>Hypernetworks</category>
        
        <category>Document AI</category>
        
        <category>Lab reports</category>
        
        <category>On-device AI</category>
        
        
        <category>Machine Learning</category>
        
        <category>Projects</category>
        
      </item>
    
      <item>
        <title>Show‑to‑LoRA: Teaching a 1B Vision Model a New Document from Four Examples</title>
        <description>&lt;p&gt;I built a small hypernetwork that reads four example pages of a new document type and outputs a LoRA adapter for MiniCPM-V in one forward pass, with nothing trained at use time. Across 78 document tasks the network never saw during training, those adapters raised field-level F1 from &lt;strong&gt;0.728 to 0.881&lt;/strong&gt; and helped on &lt;strong&gt;71 of the 78&lt;/strong&gt; tasks. This post explains how the system works, the checks I ran before building each piece, what the results do and don’t show yet, and where to find the code and weights.&lt;/p&gt;

&lt;p&gt;Small vision-language models now run on a laptop or a phone, yet they constantly meet document layouts they have never seen: a new invoice template, a lab’s report format, a shipping label. The usual fix is to fine-tune an adapter for each layout. That requires a GPU, a training loop, and someone who knows how to run it.&lt;/p&gt;

&lt;p&gt;I wanted something closer to teaching a person: show the model a few pages with the right answers and let it pick up the pattern. That is the idea behind &lt;strong&gt;Show-to-LoRA&lt;/strong&gt;, which reads a handful of example pages and writes a LoRA adapter for the frozen model in a single forward pass. I built it on &lt;a href=&quot;https://huggingface.co/openbmb/MiniCPM-V-4.7-1B&quot;&gt;MiniCPM-V-4.7-1B&lt;/a&gt; as an entry in OpenBMB’s MiniCPM Spark Program (On-Device Agent Challenge). A &lt;a href=&quot;/blog/show-to-lora-blood-counts/&quot;&gt;companion post&lt;/a&gt; applies it to a real-world case: reading blood test reports.&lt;/p&gt;

&lt;h2 id=&quot;prompts-skills-and-lora-adapters&quot;&gt;Prompts, skills and LoRA adapters&lt;/h2&gt;

&lt;p&gt;There are three common ways to get a model to do a new job. They work at different levels, so I find it helpful to look at them side by side.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt; &lt;/th&gt;
      &lt;th&gt;Prompting (including few-shot)&lt;/th&gt;
      &lt;th&gt;Skills and plugins&lt;/th&gt;
      &lt;th&gt;LoRA adapters&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;What it changes&lt;/td&gt;
      &lt;td&gt;the text the model reads&lt;/td&gt;
      &lt;td&gt;the instructions, files and tools the model can load or call&lt;/td&gt;
      &lt;td&gt;the model’s weights, through a small add-on&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Best for&lt;/td&gt;
      &lt;td&gt;stating the task, the format and the rules&lt;/td&gt;
      &lt;td&gt;reaching outside the model: APIs, code, search, saved procedures&lt;/td&gt;
      &lt;td&gt;abilities the model lacks even when told exactly what to do: a layout, a style, a domain’s conventions&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Cost per request&lt;/td&gt;
      &lt;td&gt;the prompt is paid for every time, and long few-shot prompts add up&lt;/td&gt;
      &lt;td&gt;small until loaded, then the skill’s text and any tool calls&lt;/td&gt;
      &lt;td&gt;no extra input; the add-on is a few MB and can be merged into the weights&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Setup&lt;/td&gt;
      &lt;td&gt;write text&lt;/td&gt;
      &lt;td&gt;write instructions or code, inside an agent that supports them&lt;/td&gt;
      &lt;td&gt;usually a training run, with labelled data and a GPU&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Limits&lt;/td&gt;
      &lt;td&gt;context length, and how well the model follows long instructions (often weak in small models)&lt;/td&gt;
      &lt;td&gt;can’t make the model see or read better than it already does&lt;/td&gt;
      &lt;td&gt;needs access to the weights; one adapter per job; can hurt outside its domain&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Switching&lt;/td&gt;
      &lt;td&gt;instant&lt;/td&gt;
      &lt;td&gt;instant&lt;/td&gt;
      &lt;td&gt;load a different adapter file&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;These approaches stack rather than compete. A prompt tells the model what you want, and a skill gives it tools and procedures. An adapter changes how well the model does the work itself. I start with a prompt, then add skills when the job needs something outside the model. If the model keeps failing at something it has been clearly told to do, I use an adapter.&lt;/p&gt;

&lt;p&gt;The catch with adapters has always been the training run. Show-to-LoRA gets rid of it. You pass in a few labelled examples and get an adapter out in one forward pass.&lt;/p&gt;

&lt;h2 id=&quot;how-it-works&quot;&gt;How it works&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/static/portfolio/blog-covers/show-to-lora-pipeline.png&quot; alt=&quot;Show-to-LoRA pipeline: example pages and their answers go through the frozen base model, a hypernetwork turns the pooled vectors into a LoRA adapter, and the base model with that adapter reads new pages&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;From k example pages to a PEFT adapter. The base model’s weights stay frozen; the adapter is a separate 3.6 MB file.&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Encode the examples.&lt;/strong&gt; The frozen base model reads each example page along with its correct JSON answer. I average its final hidden states over the answer tokens to get one vector per example.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Write the adapter.&lt;/strong&gt; A hypernetwork of roughly 72M parameters averages those vectors and outputs rank-8 LoRA weights for 48 modules of the language model.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Use it.&lt;/strong&gt; The adapter saves in the standard PEFT format, so transformers, vLLM, or llama.cpp (after conversion) can load it just like any ordinary LoRA.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The setup follows Sakana AI’s &lt;a href=&quot;https://github.com/SakanaAI/text-to-lora&quot;&gt;Text-to-LoRA&lt;/a&gt;, which generates adapters from a text description of a task. Here the description is a few labelled page images instead. For document layouts, handing over a few pages is often much easier for a user than writing an exact specification.&lt;/p&gt;

&lt;h2 id=&quot;under-the-hood&quot;&gt;Under the hood&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The adapter.&lt;/strong&gt; LoRA leaves each frozen weight matrix \(W\) untouched and adds a small low-rank correction beside it:&lt;/p&gt;

\[h = W x + \frac{\alpha}{r}\, B A x\]

&lt;p&gt;Here \(A\) and \(B\) are thin matrices of rank \(r = 8\), and \(\alpha = 16\). There are 48 adapted modules in the language model: the \(q\) and \(v\) projections in the 6 full-attention layers, plus the input and output projections in the 18 linear-attention layers. The hypernetwork’s entire job is to produce every \(A\) and \(B\).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From examples to one vector.&lt;/strong&gt; For each example page, the frozen model reads the page, the prompt, and the correct JSON. I average its last-layer hidden states over the answer tokens only, giving a vector \(e_i\) of 1,024 numbers, and then average those across the \(k\) examples:&lt;/p&gt;

\[z = \frac{1}{k} \sum_{i=1}^{k} e_i\]

&lt;p&gt;Pooling only the answer tokens focuses the vector on what the right output looks like for that kind of page. On the development tasks this scored 0.978 F1, compared to 0.975 when I pooled the page tokens as well.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From the vector to weights.&lt;/strong&gt; A small 3-layer MLP (width 512) runs once per module. It takes the task vector plus two learned tags indicating which layer and which kind of projection it is writing for, and linear output heads turn its output into that module’s \(A\) and \(B\). Most of the 72M parameters live in those heads. A learned shared adapter sits on top to cover whatever all document tasks have in common. The hypernetwork output starts at zero, so at the beginning of training the adapter changes nothing, just like a fresh LoRA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Training.&lt;/strong&gt; Each step picks 8 tasks. For each one, the hypernetwork sees \(k \in \{1, 2, 4, 8\}\) support pages, writes an adapter, and gets scored on a different page \((x, y)\) from the same task using the usual next-token loss:&lt;/p&gt;

\[\mathcal{L}(\theta) = -\sum_{t} \log p_{\,W + \Delta W_\theta(z)}\big(y_t \mid x,\ y_{&amp;lt;t}\big)\]

&lt;p&gt;Only the hypernetwork’s weights \(\theta\) are updated. Gradients flow back through the frozen model into the hypernetwork, pushing it to write adapters that hold up on pages it did not see. The final run used AdamW at a learning rate of \(10^{-4}\) with a cosine schedule for 6,000 steps, covering 48,000 query pages across 333 training tasks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scoring.&lt;/strong&gt; I flatten every prediction and label into (field, value) pairs, ignoring row order, and compute F1 over those pairs across all pages of a task. Any output that is not valid JSON counts as an empty prediction.&lt;/p&gt;

&lt;h2 id=&quot;step-1-checking-whether-an-adapter-has-room-to-help&quot;&gt;Step 1: checking whether an adapter has room to help&lt;/h2&gt;

&lt;p&gt;A hypernetwork can only write adapters as good as ordinary ones. Before building it, I tested whether a standard LoRA trained directly on each task beats the base model on 20 receipt and form tasks (CORD, SROIE, WildReceipt, FUNSD, and XFUND). It had to beat both the plain model and the model given 1 or 4 examples in the prompt.&lt;/p&gt;

&lt;p&gt;Three things came out of that check:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;There is real headroom.&lt;/strong&gt; Ordinary LoRAs gained +0.1 to +0.4 F1 on most of the receipt tasks.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;In-prompt examples barely help small models, and often hurt.&lt;/strong&gt; On one model, putting four examples in the prompt dropped SROIE scores by 0.3 to 0.5. Simply showing examples in the prompt is a weak option at this size, which is the gap an adapter fills.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Which layers you adapt matters.&lt;/strong&gt; MiniCPM-V 4.7 has a hybrid language model: only 6 of its 24 layers have standard attention projections, while the other 18 use linear attention. Adapting only the standard q and v projections reaches a quarter of the model. Adding the linear-attention projections did better on both models I tested (14 wins against 7 on one, and a higher mean gain on the other), so every adapter in this project targets both.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I also exported one adapter to llama.cpp, the runtime most on-device apps use. Across 150 documents, it scored within 0.03 F1 of the PyTorch run, provided the base model’s GGUF is converted without fusing the projection weights.&lt;/p&gt;

&lt;h2 id=&quot;step-2-picking-the-base-model-honestly&quot;&gt;Step 2: picking the base model honestly&lt;/h2&gt;

&lt;p&gt;The first check pointed to MiniCPM-OCR-1.0 as the model with the most headroom. A follow-up showed why: I had run it at a lower image resolution than its default. At its default resolution its baseline climbed, and the LoRA beat it on only 7 of 20 tasks. MiniCPM-V-4.7-1B with a LoRA, running at its own defaults, matched or beat OCR’s best baseline on 18 of 20. I switched to V-4.7.&lt;/p&gt;

&lt;h2 id=&quot;step-3-building-a-pool-of-tasks&quot;&gt;Step 3: building a pool of tasks&lt;/h2&gt;

&lt;p&gt;To learn how examples map to adapters, the hypernetwork needs a broad set of tasks. I built &lt;strong&gt;443 tasks&lt;/strong&gt;:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt; &lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Training&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Held out for testing&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Synthetic forms in English and Chinese&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;320&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;64&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Receipts, forms, tables, charts, formulas (public datasets)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;45&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;10&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Invoices (public dataset)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Total&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;365&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;78&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Whole datasets and whole domains are held out&lt;/strong&gt;, not random pages. The test set consists of FinTabNet, ChartQA, an invoice dataset, and every template from four synthetic domains: payslips, purchase orders, restaurant bills, and shipping labels. The network never saw any of them, or anything from those domains.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Every label is real.&lt;/strong&gt; Public tasks use the datasets’ own annotations, and synthetic forms use the exact strings the renderer printed. No label anywhere comes from another model.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Duplicates were checked across splits.&lt;/strong&gt; That check caught receipts from the same store sitting in both the training and evaluation splits of SROIE, which had slightly inflated my first headroom numbers. I removed those pages, and no duplicate crossed into the held-out set.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;step-4-training-the-hypernetwork&quot;&gt;Step 4: training the hypernetwork&lt;/h2&gt;

&lt;p&gt;Training runs end to end. The hypernetwork writes an adapter from 4 support pages, the frozen model uses that adapter to answer a different page of the same task, and the loss on that answer trains the hypernetwork. The final run learned from 333 of the 365 training tasks, took 6,000 steps (about five hours on one A10G GPU), and brought the training loss down from 0.171 to 0.033. I used the other 32 training tasks as a development set to choose the learning rate and embedding recipe before touching the test set. On those 32 tasks, the base model scored 0.873 and the emitted adapters reached 0.978.&lt;/p&gt;

&lt;h2 id=&quot;results-on-78-held-out-tasks&quot;&gt;Results on 78 held-out tasks&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/static/portfolio/blog-covers/gate1-heldout-scatter.png&quot; alt=&quot;Scatter plot of base model F1 against F1 with an emitted adapter for 78 held-out tasks; almost all points lie above the no-change diagonal&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Each point is one held-out task: base model F1 on the x axis, F1 with an adapter emitted from 4 pages on the y axis. Points above the dashed line improved.&lt;/em&gt;&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Held-out tasks&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Base model&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Emitted adapter (4 pages)&lt;/th&gt;
      &lt;th&gt;Gain [95% CI]&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Better / worse&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;All (78)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.728&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.881&lt;/td&gt;
      &lt;td&gt;+0.154 [+0.116, +0.195]&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;71 / 2&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Synthetic forms (64)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.813&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.957&lt;/td&gt;
      &lt;td&gt;+0.145&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;58 / 1&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Charts, financial tables, invoices (14)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.339&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.533&lt;/td&gt;
      &lt;td&gt;+0.194&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;13 / 1&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Both columns use the same pages, the same greedy decoding, and the same GPU. “Better” and “worse” mean a change of more than 0.005 F1 on the task.&lt;/p&gt;

&lt;p&gt;The largest gains show up where the base model is weakest. A Chinese purchase-order form went from 0.24 to 0.98, and one FinTabNet table task rose from 0.21 to 0.79. On English synthetic forms the base model is already near 0.95, so there is little room left to add. Charts are the weakest area, with gains between +0.01 and +0.27. Two tasks got worse: an invoice-parties task (0.62 to 0.52) and one Chinese restaurant bill (0.97 to 0.94).&lt;/p&gt;

&lt;h2 id=&quot;what-these-results-dont-show-yet&quot;&gt;What these results don’t show yet&lt;/h2&gt;

&lt;p&gt;I only compared against the plain base model. To save time and budget, I did not run these on the held-out tasks:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;the same 4 examples placed in the prompt instead of turned into an adapter;&lt;/li&gt;
  &lt;li&gt;one multi-task LoRA trained on all 365 training tasks;&lt;/li&gt;
  &lt;li&gt;a LoRA trained directly on each held-out task, as an upper bound.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The multi-task LoRA matters most. In an earlier pilot on the 20 receipt and form tasks, a single LoRA trained across all of them beat the per-task LoRAs. So I can say the emitted adapters clearly beat the base model on unseen document types, but not yet that they beat one well-trained general adapter. That multi-task adapter is already trained, so running that comparison is next.&lt;/p&gt;

&lt;h2 id=&quot;code-and-weights&quot;&gt;Code and weights&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Library:&lt;/strong&gt; &lt;a href=&quot;https://github.com/ASH1998/openT2L&quot;&gt;openT2L on GitHub&lt;/a&gt;. The core depends only on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;torch&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;safetensors&lt;/code&gt; and works with any PyTorch model whose adapted layers are &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nn.Linear&lt;/code&gt;. You give it module-name patterns, it reads the shapes from the model, and adapters come out in PEFT format.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Hypernetwork weights:&lt;/strong&gt; &lt;a href=&quot;https://huggingface.co/ASHu2/openT2L-MiniCPM-V-4.7-1B-docs&quot;&gt;ASHu2/openT2L-MiniCPM-V-4.7-1B-docs&lt;/a&gt; on Hugging Face. I ran the model card’s code as published on three held-out tasks, and it reproduced the evaluation outputs exactly on two of them.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Experiment code, protocols and every result:&lt;/strong&gt; &lt;a href=&quot;https://github.com/ASH1998/openBMB-spark-t2l&quot;&gt;openBMB-spark-t2l&lt;/a&gt;. Each stage has a protocol written before its runs, and failed and negative runs are logged too.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The hypernetwork weights are released for &lt;strong&gt;non-commercial use&lt;/strong&gt; (CC BY-NC 4.0) because some of the training datasets are non-commercial. The code is Apache-2.0.&lt;/p&gt;

&lt;p&gt;From the first headroom check to the final evaluation, the whole project used about USD 170 of cloud GPU time by my own ledger.&lt;/p&gt;

&lt;h2 id=&quot;whats-next&quot;&gt;What’s next&lt;/h2&gt;

&lt;p&gt;The point of all this is an on-device agent. It hits a document it reads badly, the user corrects a few pages, and it installs a new 3.6 MB skill in seconds, keeping a local library of them. The &lt;a href=&quot;/blog/show-to-lora-blood-counts/&quot;&gt;next post&lt;/a&gt; walks through that loop on real blood test reports, including the parts that still don’t work.&lt;/p&gt;
</description>
        <pubDate>Fri, 20 Nov 2026 04:30:00 +0000</pubDate>
        <link>https://ashutoshmishra.dev/blog/show-to-lora/</link>
        <guid isPermaLink="true">https://ashutoshmishra.dev/blog/show-to-lora/</guid>
        
        <category>OpenBMB</category>
        
        <category>MiniCPM</category>
        
        <category>LoRA</category>
        
        <category>Hypernetworks</category>
        
        <category>Text-to-LoRA</category>
        
        <category>Document AI</category>
        
        <category>On-device AI</category>
        
        <category>PEFT</category>
        
        
        <category>Machine Learning</category>
        
        <category>Projects</category>
        
      </item>
    
      <item>
        <title>Zephyr: Exploring Shape and Airflow with AI</title>
        <description>&lt;p&gt;I wanted to make a question easier to explore: if I change this part of a vehicle, what happens to the air around it?&lt;/p&gt;

&lt;p&gt;A drag number gives one part of the answer. Understanding the change also means looking at the original shape, seeing exactly what moved, and comparing the pressure and airflow around both versions. I built &lt;strong&gt;Zephyr&lt;/strong&gt; to bring those pieces into the same workspace.&lt;/p&gt;

&lt;p&gt;The project combines a 3D viewer, a geometry controller, NVIDIA DoMINO aerodynamic predictions, and a language interface powered by Nemotron through Nebius. A design request can become a constrained shape study, with the resulting geometry, predictions, and explanation kept together.&lt;/p&gt;

&lt;p&gt;One saved sedan comparison captures the idea well: predicted drag fell from &lt;strong&gt;621.6956 N to 600.9733 N&lt;/strong&gt;, a &lt;strong&gt;3.333% reduction&lt;/strong&gt;, while the protected passenger cabin stayed unchanged. That is an interesting research result to inspect. The candidate remains unaccepted, and the reduction has not been established by independent CFD or a wind-tunnel test.&lt;/p&gt;

&lt;h2 id=&quot;a-workspace-for-asking-questions-about-shape&quot;&gt;A workspace for asking questions about shape&lt;/h2&gt;

&lt;p&gt;Zephyr lets me switch between the original and changed geometry, inspect predicted surface pressure, follow airflow paths, and see where the body moved. Keeping these views connected makes it easier to relate a number to the shape that produced it.&lt;/p&gt;

&lt;p&gt;The catalog contains nine selectable vehicles: a sedan, hatchback, SUV, wagon, coupe, sports car, van, NASA X-57, and NASA Global Hawk. They provide different shapes to explore within the same interface.&lt;/p&gt;

&lt;p&gt;The aircraft workspace also includes an illustrative flow mode. Its orange wingtip spirals explain a flow concept; they are separate from the model’s predicted velocity field. Aircraft predictions are experimental because the DoMINO checkpoint used here was trained on cars, so these views do not establish aircraft performance.&lt;/p&gt;

&lt;p&gt;For the car comparisons, each view answers a different question. Pressure shows the model’s predicted loading across the surface. Airflow makes the surrounding velocity field easier to inspect. The change view shows displacement, so an orange patch there means that the geometry moved. Sensitivity highlights places where the model suggests a small change might affect drag, giving me a hypothesis to test.&lt;/p&gt;

&lt;p&gt;Animated particles help make the flow paths legible. They trace a saved, steady velocity field; their movement is a visualization of that field rather than a time-resolved flow simulation.&lt;/p&gt;

&lt;h2 id=&quot;giving-each-model-a-concrete-job&quot;&gt;Giving each model a concrete job&lt;/h2&gt;

&lt;p&gt;The two AI components have different responsibilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DoMINO predicts the aerodynamic quantities.&lt;/strong&gt; Zephyr runs NVIDIA’s open DoMINO &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.mdlus&lt;/code&gt; checkpoints on a local CUDA GPU. Surface predictions support the pressure and force comparison, while volume predictions provide the surrounding velocity field used by the airflow viewer. These are surrogate estimates: a trained model predicts quantities that would otherwise require a separate physics-based calculation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nemotron interprets the request and explains the evidence.&lt;/strong&gt; Served through Nebius Token Factory, it translates a supported plain-language brief into a structured plan and answers questions about a completed run. It can explain what changed, what the recorded numbers mean, and why the application accepted or refused a step for further evaluation.&lt;/p&gt;

&lt;p&gt;The geometry controller handles the actual movement of the mesh. It applies supported transformations, preserves protected regions, and checks the resulting shape. The application’s rules also decide whether a result meets its acceptance criteria. Nemotron cannot move arbitrary vertices or relax those criteria.&lt;/p&gt;

&lt;p&gt;This division makes the interaction practical. I can describe a change in ordinary language while keeping the geometry operation and the evidence behind the answer inspectable.&lt;/p&gt;

&lt;h2 id=&quot;from-a-brief-to-a-comparison&quot;&gt;From a brief to a comparison&lt;/h2&gt;

&lt;p&gt;A typical request might ask for a subtle rear taper, keep the cabin unchanged, and set a maximum movement in millimetres. In the full application, the workflow proceeds through a few explicit steps:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Interpret the brief.&lt;/strong&gt; Turn the request into a supported plan and expose the effective movement limit. Unsupported changes need clarification or are refused.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Construct the candidate.&lt;/strong&gt; Apply a deterministic deformation while preserving the mesh’s connectivity and protected coordinates.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Check the geometry.&lt;/strong&gt; Inspect displacement bounds, triangle quality, surface orientation, intersections, and the other constraints required by the selected workflow.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Evaluate and compare.&lt;/strong&gt; Run fresh predictions for the relevant geometry and present the original and candidate fields together.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Explain the recorded result.&lt;/strong&gt; Connect the force difference, shape change, validation outcome, and remaining questions to the same run.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The ordinary bounded-edit workflow has a 4 mm movement ceiling. The featured sedan result comes from a separate research workflow with larger, explicitly constrained morphs. Keeping those workflows distinct matters: the saved research candidate’s maximum movement was approximately &lt;strong&gt;32.174 mm&lt;/strong&gt;, so describing it as a tiny 4 mm edit would misrepresent the result.&lt;/p&gt;

&lt;h2 id=&quot;looking-closely-at-the-saved-sedan-result&quot;&gt;Looking closely at the saved sedan result&lt;/h2&gt;

&lt;p&gt;The research workflow explores seven shape parameters: rear taper, deck height, hood camber, nose width, side shoulders, front overhang, and rear overhang. The selected candidate combines several of these changes while preserving the protected cabin.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Recorded quantity&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Original&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Changed&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Predicted drag&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;621.6956 N&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;600.9733 N&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Difference from original&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;—&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;−20.7222 N&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Relative change&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;—&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;−3.333%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Protected cabin movement&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;—&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0 mm&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The geometry checks passed for this candidate, and the saved replay includes freshly evaluated surface and volume fields. I can inspect the shape at true scale, compare the predicted pressure, and follow the airflow around both versions instead of relying on the percentage alone.&lt;/p&gt;

&lt;p&gt;The search was stopped before its planned control comparisons and repeated finalist evaluations were complete. The relationship between these local shape transformations and the model’s training distribution also remains unverified, and there is no independent CFD comparison for this candidate. Those gaps explain why the application retains the lower predicted drag while refusing acceptance.&lt;/p&gt;

&lt;p&gt;That distinction is useful in the interface itself. A promising number becomes a specific candidate with a specific next question: does the apparent improvement hold up under further evaluation?&lt;/p&gt;

&lt;p&gt;The other saved sessions provide different comparisons. A synthetic hood dent lets me inspect a local shape disturbance and its predicted flow; it is not a crash simulation or a structural assessment. A bounded rear-taper session shows a small edit whose evidence was insufficient for acceptance. Together, the sessions show how the workspace handles different outcomes.&lt;/p&gt;

&lt;h2 id=&quot;bringing-another-car-into-the-workspace&quot;&gt;Bringing another car into the workspace&lt;/h2&gt;

&lt;p&gt;The full application also supports importing a car mesh. Before running a baseline, I can review its orientation, size, and prepared surface, then confirm what will actually enter the prediction pipeline. Eligible imports can proceed to a separate bounded shape test.&lt;/p&gt;

&lt;p&gt;There is also an experimental photo-assisted path that selects and scales a catalog template. That produces an approximation to review, rather than reconstructing the exact car in the photograph. Keeping this distinction visible helps connect the prediction to the geometry that was actually evaluated.&lt;/p&gt;

&lt;p&gt;This part of the project brought attention back to input preparation. Units, orientation, and the usable surface all affect what a comparison means. A convincing viewer needs to make those choices understandable before a calculation starts.&lt;/p&gt;

&lt;h2 id=&quot;keeping-the-evidence-with-the-result&quot;&gt;Keeping the evidence with the result&lt;/h2&gt;

&lt;p&gt;Zephyr records more than the final drag value. Run evidence includes geometry and model identifiers, constraints, validation results, timings, and the reasons behind an acceptance decision. Hashes bind the saved artifacts to the meshes and model checkpoint used for the calculation.&lt;/p&gt;

&lt;p&gt;Those records also give the language interface something concrete to explain. Questions about a result are tied to that completed run, and asking for an explanation does not launch another aerodynamic calculation.&lt;/p&gt;

&lt;p&gt;The separate static demo packages three saved sessions, recorded Nemotron answers, and downloadable evidence. It lets a reader explore those comparisons without running a GPU backend. Fresh inference, new design requests, and uploads belong to the full application.&lt;/p&gt;

&lt;p&gt;The recorded demo and source repository are not publicly available yet. This article introduces the project and the saved results; public access will follow separately.&lt;/p&gt;

&lt;h2 id=&quot;what-i-learned-from-building-zephyr&quot;&gt;What I learned from building Zephyr&lt;/h2&gt;

&lt;p&gt;The most useful part of Zephyr is being able to move between a request, a visible shape change, and the evidence for its predicted effect. Each step gives the next one context.&lt;/p&gt;

&lt;p&gt;Building that loop took work around the models: preparing geometry, defining legal changes, protecting regions, checking meshes, comparing fields, and preserving the records needed to explain an outcome. The language interface becomes useful because it can refer to those concrete results.&lt;/p&gt;

&lt;p&gt;The saved sedan comparison is where I would start a walkthrough. It has a measurable predicted difference, an unchanged cabin, and a shape that can be inspected alongside its airflow. It also leaves a clear research question open. That is the kind of exploration I wanted the workspace to support.&lt;/p&gt;
</description>
        <pubDate>Sat, 10 Oct 2026 06:30:00 +0000</pubDate>
        <link>https://ashutoshmishra.dev/blog/zephyr/</link>
        <guid isPermaLink="true">https://ashutoshmishra.dev/blog/zephyr/</guid>
        
        <category>Zephyr</category>
        
        <category>Aerodynamics</category>
        
        <category>NVIDIA</category>
        
        <category>DoMINO</category>
        
        <category>Nemotron</category>
        
        <category>Nebius</category>
        
        <category>3D</category>
        
        <category>Scientific ML</category>
        
        
        <category>Machine Learning</category>
        
        <category>Projects</category>
        
      </item>
    
      <item>
        <title>What I Learned Benchmarking Jev Against Classical Machine Learning</title>
        <description>&lt;p&gt;I wanted to answer a practical question: if I have a classification problem, how far can a prompt-driven model get before I train a conventional machine-learning pipeline?&lt;/p&gt;

&lt;p&gt;The tempting version of this experiment is a race with one winner. That is not what the results showed. Jev was excellent on one sentiment task, competitive on a few other text problems, and much less convincing on the tabular datasets. Classical models remained difficult to beat when structured features and labeled training data were available.&lt;/p&gt;

&lt;p&gt;That mixed result is more useful than a sweeping claim. It tells me where Jev may be worth trying first, where a classical baseline remains essential, and which evaluation choices can reverse the apparent winner.&lt;/p&gt;

&lt;h2 id=&quot;what-i-compared&quot;&gt;What I compared&lt;/h2&gt;

&lt;p&gt;I evaluated Jev 1.13.0 on eight public classification datasets:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Text:&lt;/strong&gt; AG News, Banking77, SMS Spam, and IMDb.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Tabular:&lt;/strong&gt; Bank Marketing, Online Shoppers, Breast Cancer, and Iris.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For Jev, I tested two prompting strategies. The zero-shot version received the task and class descriptions but no labeled examples. The few-shot version received one training example per class. Tabular rows were represented as structured feature values rather than converted into free-form prose.&lt;/p&gt;

&lt;p&gt;The classical side included logistic regression, SVM, decision tree, random forest, extra trees, k-nearest neighbours, Naive Bayes, histogram gradient boosting, XGBoost, CatBoost, and a voting ensemble. I also kept a majority-class baseline in the report so that every score had some context.&lt;/p&gt;

&lt;p&gt;All approaches were evaluated on the same held-out cases for each dataset. Classical models used up to 8,000 training rows, a separate validation set for model selection, and three training seeds. For binary tasks, I also created a second result panel in which decision thresholds were learned from a separate labeled policy split.&lt;/p&gt;

&lt;p&gt;The main metric was &lt;strong&gt;balanced accuracy&lt;/strong&gt;: the average recall across classes. This matters for datasets such as SMS Spam and Bank Marketing, where plain accuracy can hide poor performance on the minority class.&lt;/p&gt;

&lt;h2 id=&quot;the-raw-results&quot;&gt;The raw results&lt;/h2&gt;

&lt;p&gt;The table below keeps the comparison readable by showing both Jev variants and the strongest classical mean for each dataset. Values are mean balanced accuracy across three seeds; the best classical model is chosen retrospectively from the eleven pipelines.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Dataset&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Jev zero-shot&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Jev few-shot&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Best classical result&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;AG News&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;87.5%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;86.3%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;88.4% — SVM&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Banking77&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;78.9%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;81.9%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;89.7% — SVM&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SMS Spam&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;96.1%&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;95.6%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;95.0% — Naive Bayes&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;IMDb&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;96.3%&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;95.9%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;88.4% — Logistic regression&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Bank Marketing&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;53.4%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;55.3%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;71.8% — SVM&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Online Shoppers&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;51.4%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;54.7%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;69.1% — SVM&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Breast Cancer&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;61.0%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;88.8%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;100.0% — SVM / k-NN&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Iris&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;97.0%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;94.5%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;100.0% — multiple models&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The clearest result is IMDb. Zero-shot Jev reached 96.3%, while logistic regression—the strongest classical result in this run—reached 88.4%. A 7.9-point difference is large enough to be interesting even before discussing deployment trade-offs.&lt;/p&gt;

&lt;p&gt;Jev also led the raw SMS Spam comparison, although by a much smaller margin. AG News was effectively close: Jev reached 87.5% and SVM reached 88.4%. Banking77 was less favourable to Jev, with SVM ahead by 7.8 points.&lt;/p&gt;

&lt;p&gt;The four tabular datasets tell a different story. Jev came close on Iris, but Iris had only 30 test cases and several classical models scored 100%. On the two business-style tabular tasks—Bank Marketing and Online Shoppers—the gap was substantial. Those are the results I would pay attention to before treating a general-purpose model as a drop-in replacement for a trained tabular pipeline.&lt;/p&gt;

&lt;h2 id=&quot;imdb-is-the-standout-not-proof-of-a-universal-advantage&quot;&gt;IMDb is the standout, not proof of a universal advantage&lt;/h2&gt;

&lt;p&gt;Sentiment classification is a natural fit for a language model. The label depends on meaning distributed across a review, and the model arrives with a broad prior about language and sentiment. A bag-of-words or similarly bounded classical representation has to learn that relationship from the task data.&lt;/p&gt;

&lt;p&gt;That helps explain why IMDb produced Jev’s strongest result. It does not prove that Jev is better at text classification in general. Banking77 contains 77 fine-grained intent labels and favoured SVM. AG News was close. The benchmark also did not include fine-tuned transformers, modern embedding pipelines, or other language-model APIs.&lt;/p&gt;

&lt;p&gt;My interpretation is narrower: Jev looks especially promising when the task aligns with knowledge already represented by the model and when obtaining task-specific labels is expensive.&lt;/p&gt;

&lt;h2 id=&quot;thresholds-changed-the-sms-result&quot;&gt;Thresholds changed the SMS result&lt;/h2&gt;

&lt;p&gt;A classifier has two related jobs. It must separate the classes, and it must choose a decision point. The default decision point is not always the best one, particularly when classes are imbalanced or the cost of false positives and false negatives differs.&lt;/p&gt;

&lt;p&gt;I therefore repeated the binary comparisons after selecting thresholds on a separate labeled policy set. That changed the story:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Dataset&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Adjusted Jev zero-shot&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Adjusted Jev few-shot&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Best adjusted classical result&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;SMS Spam&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;95.9%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;95.8%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;96.3% — Naive Bayes&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;IMDb&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;96.1%&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;95.5%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;88.3% — Logistic regression&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Bank Marketing&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;59.7%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;59.0%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;73.3% — Voting ensemble&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Online Shoppers&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;51.8%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;53.6%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;71.2% — Voting ensemble&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Breast Cancer&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;88.4%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;92.7%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;100.0% — Logistic regression&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The raw SMS lead disappeared: Naive Bayes moved slightly ahead after threshold selection. IMDb barely changed and remained Jev’s strongest result. Threshold adjustment helped Jev considerably on Breast Cancer, but not enough to catch the classical models. It also failed to close the large gaps on Bank Marketing and Online Shoppers.&lt;/p&gt;

&lt;p&gt;There is an important naming detail here. The adjusted Jev result may use a zero-shot &lt;strong&gt;prompt&lt;/strong&gt;, but the complete decision system is no longer zero-shot because labeled policy data was used to select its threshold.&lt;/p&gt;

&lt;h2 id=&quot;one-example-per-class-was-not-consistently-better&quot;&gt;One example per class was not consistently better&lt;/h2&gt;

&lt;p&gt;I expected the few-shot prompt to improve most tasks. Instead, examples helped selectively.&lt;/p&gt;

&lt;p&gt;The largest gain was Breast Cancer, where raw balanced accuracy rose from 61.0% to 88.8%. Banking77 also improved from 78.9% to 81.9%. But the few-shot mean was lower on AG News, SMS Spam, IMDb, and Iris.&lt;/p&gt;

&lt;p&gt;This is a useful warning against treating “add examples” as a universal prompt-engineering recipe. One example per class can clarify an unfamiliar label, but it can also be unrepresentative, introduce accidental wording cues, or narrow the model’s interpretation too aggressively. Few-shot selection is part of the model design and should be validated like any other hyperparameter.&lt;/p&gt;

&lt;h2 id=&quot;why-i-did-not-calculate-one-overall-winner&quot;&gt;Why I did not calculate one overall winner&lt;/h2&gt;

&lt;p&gt;It would be easy to average the eight rows and publish a single leaderboard number. I chose not to do that.&lt;/p&gt;

&lt;p&gt;The datasets differ in class count, test-set size, modality, difficulty, and practical meaning. A constant prediction gives roughly 1.3% balanced accuracy on the 77-class Banking77 task but 50% on a binary task. Iris contains only 30 test cases; Banking77 contains 1,500. Treating all eight numbers as interchangeable would create an apparently precise result with very little meaning.&lt;/p&gt;

&lt;p&gt;I would rather report the pattern:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Jev was strongest on IMDb sentiment classification.&lt;/li&gt;
  &lt;li&gt;It was competitive on some other text tasks, but not all of them.&lt;/li&gt;
  &lt;li&gt;Classical pipelines clearly led on the business-oriented tabular datasets.&lt;/li&gt;
  &lt;li&gt;Threshold selection and example choice were large enough to alter the interpretation.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;limits-i-would-keep-in-mind&quot;&gt;Limits I would keep in mind&lt;/h2&gt;

&lt;p&gt;These results are descriptive, not a statistical-significance claim. The displayed variation is across three training seeds, not a confidence interval. Identical successful zero-shot API requests were cached, so the three zero-shot rows are not independent model repetitions.&lt;/p&gt;

&lt;p&gt;The classical search was intentionally bounded: four candidates per family, restricted feature budgets, at most 150 trees, and at most 60 histogram-boosting iterations. A larger search or a different representation could improve those models. The comparison also says nothing about the best possible transformer or embedding-based classifier.&lt;/p&gt;

&lt;p&gt;The smallest holdouts deserve special caution. Perfect performance on 30 Iris examples or 114 Breast Cancer examples does not imply perfect generalisation. Public-dataset exposure during model pretraining is also unknown.&lt;/p&gt;

&lt;p&gt;Finally, Banking77 produced warnings about predictions outside the allowed label set. Failed requests were counted as incorrect, but the published run does not contain enough diagnostics to separate model errors from API failures precisely.&lt;/p&gt;

&lt;h2 id=&quot;what-i-would-do-on-a-real-project&quot;&gt;What I would do on a real project&lt;/h2&gt;

&lt;p&gt;I would not choose between Jev and classical ML from the model name alone. I would begin with three baselines:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;a simple classical pipeline with careful validation;&lt;/li&gt;
  &lt;li&gt;a zero-shot prompt that includes explicit class definitions;&lt;/li&gt;
  &lt;li&gt;a small labeled policy set for threshold and error-cost analysis.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a language task with few labels, Jev may provide a strong starting point and sometimes the best result. For structured business data, I would still expect a tuned classical pipeline to be the default challenger. In both cases, I would inspect per-class errors, latency, cost, stability, and failure handling before thinking about deployment.&lt;/p&gt;

&lt;p&gt;The lesson from this benchmark is not that one family replaced the other. It is that pretrained models and classical pipelines have different strengths. The useful engineering decision is knowing which one to test first—and never skipping the baseline that can prove you wrong.&lt;/p&gt;

&lt;p&gt;The complete notebook, protocol, and result files are available in the &lt;a href=&quot;https://github.com/QuicqDev/Jev-vs-ML&quot;&gt;Jev vs. ML repository&lt;/a&gt;.&lt;/p&gt;
</description>
        <pubDate>Sun, 20 Sep 2026 06:30:00 +0000</pubDate>
        <link>https://ashutoshmishra.dev/blog/jev-vs-classical-ml/</link>
        <guid isPermaLink="true">https://ashutoshmishra.dev/blog/jev-vs-classical-ml/</guid>
        
        <category>Jev</category>
        
        <category>Classical ML</category>
        
        <category>Classification</category>
        
        <category>Benchmarking</category>
        
        <category>NLP</category>
        
        <category>Tabular Data</category>
        
        <category>Balanced Accuracy</category>
        
        
        <category>Machine Learning</category>
        
        <category>Benchmarks</category>
        
      </item>
    
      <item>
        <title>Rune Goblin: My Build Small Hackathon Winner</title>
        <description>&lt;p&gt;Rune Goblin, my winning project from the Hugging Face Build Small hackathon, started with a question: what would spell casting feel like if you had to draw the spell yourself?&lt;/p&gt;

&lt;p&gt;I wanted the player to learn a small magical language, experiment with combinations, and sometimes get a result they did not quite intend. A confident sketch could become a useful spell. A messy one could still do something, but with a weaker effect, a curse, or an unexpected consequence.&lt;/p&gt;

&lt;p&gt;That idea became an AI dungeon crawler built around hand-drawn runes, a fine-tuned vision model, and a game engine that checks every proposed action. Getting those pieces to cooperate was the interesting engineering problem.&lt;/p&gt;

&lt;h2 id=&quot;a-dungeon-that-responds-to-your-drawings&quot;&gt;A dungeon that responds to your drawings&lt;/h2&gt;

&lt;p&gt;Players draw rune glyphs on a canvas. The game interprets the drawing, works out the spell intent, checks it against a spell system called RuneLang, and applies the result to the world. The same interaction can affect a battle, an NPC encounter, a locked door, or a hidden dungeon event.&lt;/p&gt;

&lt;p&gt;The campaign includes more than nine maps, fourteen-plus spells, rune customizations, hidden quests, boss encounters, and hero evolution. Exploring the side quests and figuring out the boss mechanics can take roughly four hours.&lt;/p&gt;

&lt;p&gt;Boss encounters give the drawing system a purpose beyond visual novelty. Some require a particular rune; others depend on combinations, status effects, or discoveries made elsewhere in the dungeon. There are also shrines, portals, chests, NPC hints, and class-specific advantages to discover.&lt;/p&gt;

&lt;p&gt;Ambiguity is part of the mechanic. The player is learning how the world responds to their marks, including what happens when those marks are unclear. That makes recognition quality a game-design decision as well as a model-quality problem.&lt;/p&gt;

&lt;h2 id=&quot;two-ai-paths-one-source-of-game-state&quot;&gt;Two AI paths, one source of game state&lt;/h2&gt;

&lt;p&gt;Rune Goblin uses OpenBMB’s MiniCPM-V-4.6 model family in two roles. The base model helps with NPC dialogue, dungeon narration, and story beats. A version fine-tuned on the custom RuneLang visual dataset interprets drawn spells and produces structured JSON.&lt;/p&gt;

&lt;p&gt;Both paths feed into a deterministic game engine. The model can suggest what a drawing means or how an NPC speaks, but persistent changes to health, inventory, quests, and combat go through the game’s rules.&lt;/p&gt;

&lt;p&gt;That boundary matters during ordinary interactions too. An NPC can offer a clue without changing quest progress on its own. A shopkeeper can haggle within predefined price bands, while the engine checks the item, final price, and inventory transaction before completing the sale.&lt;/p&gt;

&lt;p&gt;The resulting split gives the model room to make the dungeon expressive while keeping a save file consistent across turns.&lt;/p&gt;

&lt;h2 id=&quot;what-happens-when-you-cast-a-spell&quot;&gt;What happens when you cast a spell&lt;/h2&gt;

&lt;p&gt;Each spell turn starts with context. The game packages the drawn or selected runes with a compact snapshot of the situation: player health, the enemy, the room, known weaknesses, inventory hints, and recent story state.&lt;/p&gt;

&lt;p&gt;The rune interpreter returns a proposal containing information such as detected runes, confidence, ambiguity, spell name, target, effect, status changes, presentation text, and visual tags. The engine then takes that proposal through several checks:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Parse the response.&lt;/strong&gt; Read the JSON and repair malformed output where possible.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Constrain the fields.&lt;/strong&gt; Clamp the result to the spell schema so downstream code receives an expected structure.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Resolve RuneLang.&lt;/strong&gt; Apply the language’s grammar, rune combinations, and ambiguity rules.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Check the encounter.&lt;/strong&gt; Account for enemy weaknesses, resistances, and the relevant world rules.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Select allowed actions.&lt;/strong&gt; Translate the resolved spell into the small set of actions the engine supports.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Update and render.&lt;/strong&gt; Apply the state changes, then show spell text, particles, visual effects, sound cues, and dungeon logs.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Those actions include damage, healing, status effects, unlocking a door, looting a chest, charging a boss pylon, recording a discovery, setting a story flag, or moving between rooms. A model response has to pass through this vocabulary of supported actions to affect the world.&lt;/p&gt;

&lt;p&gt;This is the agentic loop at the heart of the game: observe the situation, propose an interpretation, validate it, and act. The validation step connects a flexible model response to a world with durable rules.&lt;/p&gt;

&lt;h2 id=&quot;teaching-a-vision-model-runelang&quot;&gt;Teaching a vision model RuneLang&lt;/h2&gt;

&lt;p&gt;The training task was deliberately narrow. I needed a model that could recognize Rune Goblin’s spell language: shapes, ordering, combinations, and ambiguity, then connect those observations to valid spell intent.&lt;/p&gt;

&lt;p&gt;The offline pipeline began with the RuneLang rulebook. It defined the vocabulary, grammar, combinations, risks, and chaos rules. From there, the pipeline generated synthetic game states and rune combinations, then rendered glyph images with variation in strokes, rotation, scale, noise, and color.&lt;/p&gt;

&lt;p&gt;That variation matters because a player drawing on a canvas will not reproduce a clean reference glyph every time. Training examples need to represent imperfect input as well as recognizable spells.&lt;/p&gt;

&lt;p&gt;The train and validation records paired images and prompts with target rune metadata, spell presentations, and structured spell JSON. Dataset construction included balanced coverage and ambiguous examples, so the task covered uncertainty as well as straightforward recognition.&lt;/p&gt;

&lt;p&gt;The workflow then used LoRA/QLoRA fine-tuning and published the resulting artifacts. The &lt;a href=&quot;https://huggingface.co/datasets/ASHu2/rune_goblin_visual_dataset&quot;&gt;Rune Goblin visual dataset&lt;/a&gt; and &lt;a href=&quot;https://huggingface.co/ASHu2/goblinV1&quot;&gt;goblinV1 model artifacts&lt;/a&gt; are available on Hugging Face.&lt;/p&gt;

&lt;p&gt;Evaluation covered JSON validity, rune detection accuracy, ambiguity handling, and basic gameplay sanity. These checks address different failure modes: a response might have valid syntax but identify the wrong rune, or recognize the drawing yet propose something the game cannot safely apply. Runtime validation remains necessary even with a fine-tuned model.&lt;/p&gt;

&lt;h2 id=&quot;where-codex-helped&quot;&gt;Where Codex helped&lt;/h2&gt;

&lt;p&gt;Codex helped throughout the work around the model: designing the RuneLang data format, generating synthetic spell examples, building the glyph renderer, adding noisy and ambiguous variations, and keeping the training targets aligned with the runtime schema.&lt;/p&gt;

&lt;p&gt;It also helped write evaluation code and work through the fine-tuning workflow, including Modal notebook steps, LoRA/QLoRA configuration, export notes, local inference paths, and GGUF conversion documentation.&lt;/p&gt;

&lt;p&gt;Keeping those pieces aligned was a substantial part of the project. The dataset, model output, validator, and game integration all needed to agree on what a spell meant. Changes also had to make their way into the README, deployment scripts, and instructions for running the project again.&lt;/p&gt;

&lt;p&gt;One useful distinction in that documentation was between training artifacts and serving artifacts. The training workflow uses safetensors, while the deployed inference path uses a quantized GGUF build. Keeping those roles clear made the path from fine-tuning to a playable game easier to follow.&lt;/p&gt;

&lt;h2 id=&quot;deploying-an-interactive-game-without-an-always-on-gpu&quot;&gt;Deploying an interactive game without an always-on GPU&lt;/h2&gt;

&lt;p&gt;The application uses Gradio and FastAPI and can run on a CPU-only Hugging Face Space. Vision inference runs separately on Modal. When a player draws a spell, the application calls the GPU endpoint, receives structured spell JSON, and continues the game through its own engine.&lt;/p&gt;

&lt;p&gt;The deployed model uses a Q8_0 GGUF build with a separate multimodal projector on a Modal A10G GPU. The serving configuration includes:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A CUDA build of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;llama-cpp-python&lt;/code&gt; exposing an OpenAI-compatible &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/v1/chat/completions&lt;/code&gt; endpoint.&lt;/li&gt;
  &lt;li&gt;A Modal Volume named &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;goblin-gguf-cache&lt;/code&gt; for the model cache.&lt;/li&gt;
  &lt;li&gt;Scale-to-zero with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;min_containers=0&lt;/code&gt; and a five-minute idle window.&lt;/li&gt;
  &lt;li&gt;Up to ten in-flight requests per replica.&lt;/li&gt;
  &lt;li&gt;CPU memory and GPU VRAM snapshots to reduce cold-start time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cold starts were especially important for this project. During early experiments, loading the full safetensors model with PyTorch took around five minutes. The GGUF serving pipeline with Modal snapshotting brought that down to roughly ten seconds. These are approximate observations from the project, and they refer to startup time rather than the latency of every spell request.&lt;/p&gt;

&lt;p&gt;The working MiniCPM-V-4.6 multimodal path used &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;llama-cpp-python&lt;/code&gt;’s &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Llama&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MTMDChatHandler&lt;/code&gt;. The deployment followed that same path used by the local backend, rather than relying on the standalone &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;llama-server&lt;/code&gt; binary.&lt;/p&gt;

&lt;p&gt;The Modal image builds the runtime with CUDA support, starts the server, sends a warmup multimodal request, and snapshots the loaded state. Later cold starts can restore the model with its weights already in VRAM. Scaling to zero lets the game avoid keeping a private GPU server running when nobody is playing.&lt;/p&gt;

&lt;h2 id=&quot;what-i-took-away-from-the-build&quot;&gt;What I took away from the build&lt;/h2&gt;

&lt;p&gt;The most satisfying part of Rune Goblin is the connection between a player’s drawing and a consequence in the dungeon. A sketch can change a fight, reveal a path, or produce a cursed outcome. The model becomes part of the interaction itself.&lt;/p&gt;

&lt;p&gt;Making that work required attention to the entire loop: the spell language, training examples, structured outputs, validation, persistent state, and inference startup. Each part affects whether drawing a rune feels like playing a game.&lt;/p&gt;

&lt;p&gt;Winning the Build Small hackathon was a great milestone for the project. The engineering lesson I take from it is the value of giving a model a clearly defined role and building the surrounding system carefully enough that its output becomes something a player can rely on, experiment with, and occasionally be surprised by.&lt;/p&gt;
</description>
        <pubDate>Sun, 14 Jun 2026 06:30:00 +0000</pubDate>
        <link>https://ashutoshmishra.dev/blog/rune-goblin/</link>
        <guid isPermaLink="true">https://ashutoshmishra.dev/blog/rune-goblin/</guid>
        
        <category>Rune Goblin</category>
        
        <category>Hugging Face</category>
        
        <category>Build Small</category>
        
        <category>OpenBMB</category>
        
        <category>MiniCPM</category>
        
        <category>Fine-tuning</category>
        
        <category>Gradio</category>
        
        <category>Modal</category>
        
        <category>Codex</category>
        
        
        <category>Hackathons</category>
        
        <category>Machine Learning</category>
        
      </item>
    
      <item>
        <title>GPU-Server-SetUp-for-DeepLearning</title>
        <description>&lt;h1 id=&quot;introduction&quot;&gt;Introduction&lt;/h1&gt;
&lt;p&gt;This blog is about how to setup gpu drivers and nvidia-smi for Deep Learning in ubuntu servers.      &lt;br /&gt;
This guide will be using conda install of python as it is easier to maintain and keep track of correct versions using it.&lt;/p&gt;

&lt;h2 id=&quot;dependencies-&quot;&gt;Dependencies :&lt;/h2&gt;
&lt;p&gt;No particular dependencies except this has been only tested on ubuntu 16.04 LTS and 18.04 LTS.      &lt;br /&gt;
(Should work in other versions as well)&lt;/p&gt;

&lt;h2 id=&quot;steps-&quot;&gt;Steps :&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Download conda :      &lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Install the latest version of conda :     &lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bash Miniconda3-latest-Linux-x86_64.sh&lt;/code&gt;          &lt;br /&gt;
Here during installing add the path to ~/bashrc, so that you can call conda using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bash&lt;/code&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Now create a new conda virtual environment for TF-GPU     &lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;conda create -n TFGPU -c defaults tensorflow-gpu&lt;/code&gt; &lt;br /&gt;
(this will install the tensorflow base gpu, cudnn and all required modules)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Then after this start it by using  &lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;conda activate TFGPU&lt;/code&gt;     &lt;br /&gt;
(But at this point there are no nvidia drivers so module wont use gpu)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Now install nvidia-drivers ( this takes a little bit time)&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#!/bin/bash                
	echo &quot;Checking for CUDA and installing.&quot;          
	# Check for CUDA and try to install.             
	if ! dpkg-query -W cuda; then
	  # The 16.04 installer works with 16.10.
	  curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
	  dpkg -i ./cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
	  apt-get update
	  # apt-get install cuda -y
	  sudo apt-get install cuda-8-0
fi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;Then after it is complete you can check the status by &lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvidia-smi&lt;/code&gt; :  &lt;br /&gt;
Result should be something like this 
————————————————&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;https://camo.githubusercontent.com/98d45361d9e667750865d2b2574d22921b875214/68747470733a2f2f7331342e706f7374696d672e696f2f36686d7a656f616f782f696d6167652e706e67&quot; alt=&quot;from https://github.com/torch/cutorch/issues/478 &quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Sat, 15 Feb 2020 00:00:00 +0000</pubDate>
        <link>https://ashutoshmishra.dev/deep%20learning/python/machine%20learning/2020/02/15/GCLOUD-GPU-SETUP.html</link>
        <guid isPermaLink="true">https://ashutoshmishra.dev/deep%20learning/python/machine%20learning/2020/02/15/GCLOUD-GPU-SETUP.html</guid>
        
        <category>GPU</category>
        
        <category>Python</category>
        
        <category>Deep-Learning</category>
        
        
        <category>Deep Learning</category>
        
        <category>Python</category>
        
        <category>Machine Learning</category>
        
      </item>
    
      <item>
        <title>Pytorch English to Hindi Translation using Attention</title>
        <description>&lt;h1 id=&quot;language-translation&quot;&gt;Language Translation&lt;/h1&gt;

&lt;h2 id=&quot;a-english-to-hindi-translation-model&quot;&gt;A English to Hindi Translation model.&lt;/h2&gt;

&lt;h3 id=&quot;encoder-decoder-model-using-attention&quot;&gt;Encoder-decoder model using attention.&lt;/h3&gt;

&lt;h3 id=&quot;import-modules&quot;&gt;Import modules&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# util modules.
&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;__future__&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;unicode_literals&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;print_function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;division&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;io&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;open&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;unicodedata&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;string&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;re&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;random&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;tqdm&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;tqdm&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tnrange&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;torch&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;torch.nn&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;torch&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;optim&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;torch.nn.functional&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;F&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;#use cuda if gpu is available else cpu.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;device&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;cuda&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cuda&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;is_available&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;cpu&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;matplotlib&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;inline&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;data-preprocessing&quot;&gt;Data Preprocessing&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# tokens for start of sentence(SOS) and end of sentence(EOS)
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;SOS_token&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;EOS_token&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;&apos;&apos;&apos;
    class for word object, storing sentences, words and word counts.
    &apos;&apos;&apos;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word2index&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word2count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index2word&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;SOS&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;EOS&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_words&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# Count SOS and EOS
&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;addSentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;addWord&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;addWord&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word2index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word2index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_words&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word2count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index2word&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_words&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_words&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word2count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Turn a Unicode string to plain ASCII, thanks to
# https://stackoverflow.com/a/518232/2809427
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;unicodeToAscii&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;unicodedata&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;normalize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;NFD&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;unicodedata&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;category&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&apos;Mn&apos;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;


&lt;span class=&quot;c1&quot;&gt;# Lowercase, trim, and remove non-letter characters
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;normalizeString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lower&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;re&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sub&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;([.!?])&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot; \1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;#s = re.sub(r&quot;[^a-zA-Z.!?]+&quot;, r&quot; &quot;, s)
&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;readLangs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lang1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lang2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reverse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;&apos;&apos;&apos;
    Read lines, from text file.
    lang1 - laguage as input,
    lang2 - output language,
    reverse - to reverse the languages as input and output.
    &apos;&apos;&apos;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Reading lines...&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# Read the file and split into lines
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;lines&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;data/%s-%s.txt&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lang1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lang2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoding&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;utf-8&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;\
        &lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# Split every line into pairs and normalize
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;pairs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;normalizeString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;l&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\t&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;l&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lines&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# Reverse pairs, make Lang instances
&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reverse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;pairs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;reversed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;p&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pairs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;input_lang&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lang2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;output_lang&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lang1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;input_lang&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lang1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;output_lang&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lang2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pairs&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;MAX_LENGTH&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#max length of words in a sentence.
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;eng_prefixes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;&quot;i am &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;i m &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;&quot;he is&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;he s &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;&quot;she is&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;she s &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;&quot;you are&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;you re &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;&quot;we are&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;we re &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;&quot;they are&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;they re &quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;filterPair&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MAX_LENGTH&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;and&lt;/span&gt; \
        &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MAX_LENGTH&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#and \
&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;#p[1].startswith(eng_prefixes)
&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;filterPairs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pair&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pair&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pairs&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;filterPair&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pair&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;prepareData&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lang1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lang2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reverse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;&apos;&apos;&apos;
    prepare class objects for the languages.
    &apos;&apos;&apos;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;input_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pairs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;readLangs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lang1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lang2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reverse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Read %s sentence pairs&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;pairs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;filterPairs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Trimmed to %s sentence pairs&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Counting words...&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pair&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pairs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;input_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;addSentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pair&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;output_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;addSentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pair&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Counted words:&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_words&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_words&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pairs&lt;/span&gt;


&lt;span class=&quot;n&quot;&gt;input_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pairs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prepareData&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;eng&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&apos;hin&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;choice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Reading lines...
Read 2831 sentence pairs
Trimmed to 2787 sentence pairs
Counting words...
Counted words:
eng 2463
hin 3022
[&apos;he is angry with you .&apos;, &apos;वह तुमसे नाराज़ है।&apos;]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;encoder-model&quot;&gt;Encoder model&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;EncoderRNN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Module&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EncoderRNN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;

        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;embedding&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Embedding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gru&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GRU&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;forward&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;embedded&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;embedding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;embedded&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gru&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;initHidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zeros&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;decoder-model&quot;&gt;Decoder Model&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DecoderRNN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Module&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DecoderRNN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;

        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;embedding&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Embedding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gru&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GRU&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;out&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Linear&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;softmax&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LogSoftmax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dim&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;forward&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;embedding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;F&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;relu&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gru&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;softmax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]))&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;initHidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zeros&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;global-attention-model&quot;&gt;Global Attention Model&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AttnDecoderRNN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Module&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dropout_p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max_length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MAX_LENGTH&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AttnDecoderRNN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output_size&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dropout_p&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dropout_p&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;max_length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max_length&lt;/span&gt;

        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;embedding&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Embedding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;attn&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Linear&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;max_length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;attn_combine&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Linear&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dropout&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Dropout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dropout_p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gru&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GRU&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;out&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Linear&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;forward&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder_outputs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;embedded&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;embedding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;embedded&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dropout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;embedded&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;attn_weights&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;F&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;softmax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;attn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;embedded&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dim&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;attn_applied&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bmm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;attn_weights&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unsqueeze&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                                 &lt;span class=&quot;n&quot;&gt;encoder_outputs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unsqueeze&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;embedded&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;attn_applied&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;attn_combine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unsqueeze&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;F&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;relu&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gru&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;F&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;log_softmax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dim&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;attn_weights&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;initHidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zeros&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;create-input-tensors&quot;&gt;create input tensors&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;indexesFromSentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word2index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;tensorFromSentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;indexes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;indexesFromSentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;indexes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EOS_token&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;indexes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dtype&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;long&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;tensorsFromPair&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pair&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;input_tensor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tensorFromSentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pair&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;target_tensor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tensorFromSentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pair&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_tensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target_tensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;training-utils&quot;&gt;Training utils&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;teacher_forcing_ratio&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_tensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target_tensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder_optimizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder_optimizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;criterion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max_length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MAX_LENGTH&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;encoder_hidden&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;initHidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;encoder_optimizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zero_grad&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;decoder_optimizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zero_grad&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;input_length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input_tensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;target_length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target_tensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;encoder_outputs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zeros&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;max_length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;loss&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ei&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;encoder_output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder_hidden&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;input_tensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ei&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder_hidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;encoder_outputs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ei&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder_output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;decoder_input&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SOS_token&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;decoder_hidden&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder_hidden&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;use_teacher_forcing&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;teacher_forcing_ratio&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;use_teacher_forcing&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;# Teacher forcing: Feed the target as the next input
&lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;di&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;target_length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;decoder_output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder_hidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder_attention&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;decoder_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder_hidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder_outputs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;loss&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;criterion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;decoder_output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target_tensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;di&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;decoder_input&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target_tensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;di&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# Teacher forcing
&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;# Without teacher forcing: use its own predictions as the next input
&lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;di&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;target_length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;decoder_output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder_hidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder_attention&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;decoder_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder_hidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder_outputs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;topv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;topi&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder_output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;topk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;decoder_input&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;topi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;squeeze&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;detach&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# detach from history as input
&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;loss&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;criterion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;decoder_output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target_tensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;di&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;EOS_token&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;loss&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;backward&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;encoder_optimizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;step&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;decoder_optimizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;step&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;loss&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target_length&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;time&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;math&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;asMinutes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;math&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;floor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;60&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;60&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&apos;%dm %ds&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;timeSince&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;since&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;percent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;now&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;now&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;since&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;es&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;percent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;rs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;es&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&apos;%s (- %s)&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;asMinutes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;asMinutes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;trainIters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n_iters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;print_every&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plot_every&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;learning_rate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.01&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;start&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plot_losses&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;print_loss_total&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# Reset every print_every
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;plot_loss_total&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# Reset every plot_every
&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;encoder_optimizer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;optim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SGD&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;parameters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;learning_rate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;decoder_optimizer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;optim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SGD&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;decoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;parameters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;learning_rate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;training_pairs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tensorsFromPair&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;choice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
                      &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_iters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;criterion&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NLLLoss&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tnrange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n_iters&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;training_pair&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;training_pairs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;input_tensor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;training_pair&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;target_tensor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;training_pair&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;loss&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_tensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target_tensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                     &lt;span class=&quot;n&quot;&gt;decoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder_optimizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder_optimizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;criterion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;print_loss_total&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;loss&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;plot_loss_total&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;loss&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;print_every&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;print_loss_avg&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;print_loss_total&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;print_every&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;print_loss_total&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;%s (%d %d%%) %.4f&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timeSince&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n_iters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                                         &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n_iters&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;print_loss_avg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plot_every&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;plot_loss_avg&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plot_loss_total&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plot_every&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;plot_losses&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plot_loss_avg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;plot_loss_total&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;showPlot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plot_losses&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;switch_backend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;agg&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;matplotlib.ticker&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ticker&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;showPlot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;points&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;fig&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ax&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;subplots&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;# this locator puts ticks at regular intervals
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ticker&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MultipleLocator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;base&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;ax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;yaxis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_major_locator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;points&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;evaluate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max_length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MAX_LENGTH&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;no_grad&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;input_tensor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tensorFromSentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;input_length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input_tensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;encoder_hidden&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;initHidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;encoder_outputs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zeros&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;max_length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ei&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;encoder_output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder_hidden&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_tensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ei&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
                                                     &lt;span class=&quot;n&quot;&gt;encoder_hidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;encoder_outputs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ei&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder_output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;decoder_input&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SOS_token&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# SOS
&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;decoder_hidden&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder_hidden&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;decoded_words&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;decoder_attentions&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zeros&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;max_length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max_length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;di&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;max_length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;decoder_output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder_hidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder_attention&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;decoder_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder_hidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder_outputs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;decoder_attentions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;di&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder_attention&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;topv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;topi&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder_output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;topk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;topi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;EOS_token&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;decoded_words&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;&amp;lt;EOS&amp;gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;decoded_words&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index2word&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;topi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()])&lt;/span&gt;

            &lt;span class=&quot;n&quot;&gt;decoder_input&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;topi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;squeeze&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;detach&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoded_words&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder_attentions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;di&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;evaluateRandomly&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;pair&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;choice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;&amp;gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pair&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;=&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pair&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;output_words&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;attentions&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;evaluate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pair&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;output_sentence&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output_words&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;&amp;lt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output_sentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;512&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;encoder1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;EncoderRNN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_words&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;attn_decoder1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AttnDecoderRNN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hidden_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_words&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dropout_p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;trainIters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encoder1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;attn_decoder1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;40000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;print_every&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plot_every&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;HBox(children=(IntProgress(value=0, max=40000), HTML(value=&apos;&apos;)))


2m 27s (- 22m 4s) (4000 10%) 4.7749
4m 55s (- 19m 40s) (8000 20%) 3.9016
7m 27s (- 17m 24s) (12000 30%) 3.0221
10m 0s (- 15m 0s) (16000 40%) 2.2249
12m 35s (- 12m 35s) (20000 50%) 1.5835
15m 11s (- 10m 7s) (24000 60%) 1.1962
17m 48s (- 7m 37s) (28000 70%) 0.8713
20m 27s (- 5m 6s) (32000 80%) 0.6325
23m 5s (- 2m 33s) (36000 90%) 0.4721
25m 45s (- 0m 0s) (40000 100%) 0.3605



&amp;lt;Figure size 432x288 with 0 Axes&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/1Rvu70y.png&quot; alt=&quot;png&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;evaluateRandomly&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encoder1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;attn_decoder1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;gt; does anyone here speak english ?
= यहाँ पर कोई अंग्रेज़ी बोलता है क्या ?
&amp;lt; यहाँ पर कोई अंग्रेज़ी बोलता है क्या ? &amp;lt;EOS&amp;gt;

&amp;gt; i have never come across such a stubborn person .
= इतने अड़ियल व्यक्ति से मेरी कभी भी मुलाकात नहीं हुई है।
&amp;lt; इतने अड़ियल व्यक्ति से मेरी कभी नहीं हुई है। &amp;lt;EOS&amp;gt;

&amp;gt; did you read it at all ?
= तुमने पूरा पढ़ लिया क्या ?
&amp;lt; तुमने पूरा पढ़ लिया क्या ? &amp;lt;EOS&amp;gt;

&amp;gt; canada is a large country .
= कनाडा एक बड़ा देश है ।
&amp;lt; कनाडा एक बड़ा देश है । &amp;lt;EOS&amp;gt;

&amp;gt; i have no time to see you .
= मेरे पास तुमसे मिलने के लिए समय नहीं है।
&amp;lt; मेरे पास तुमसे मिलने के लिए समय नहीं है। &amp;lt;EOS&amp;gt;

&amp;gt; hello !
= नमस्कार।
&amp;lt; नमस्कार। &amp;lt;EOS&amp;gt;

&amp;gt; cows are sacred to many people in india .
= भारत में कई लोग गाय को पूज्य मानते हैं।
&amp;lt; भारत में कई लोग गाय को पूज्य मानते हैं। &amp;lt;EOS&amp;gt;

&amp;gt; what are you going to do with this money ?
= तुम इन पैसों के साथ क्या करोगे ?
&amp;lt; तुम इन पैसों के साथ क्या करोगे ? &amp;lt;EOS&amp;gt;

&amp;gt; will the weather be good tomorrow ?
= कल मौसम अच्छा होगा क्या ?
&amp;lt; कल मौसम अच्छा होगा क्या ? &amp;lt;EOS&amp;gt;

&amp;gt; he pressed me for a prompt reply .
= उसने मुझसे जल्द-से-जल्द उत्तर देने के लिए कहा।
&amp;lt; उसने मुझसे जल्द-से-जल्द उत्तर देने के लिए कहा। &amp;lt;EOS&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;#save the model
&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;torch&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;save&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encoder1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;state_dict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&apos;encoder@40kepoch-512-0,36err.pth&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;save&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;attn_decoder1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;state_dict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&apos;attndecoder@40kepoch-512-0,36err.pth&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;output_words&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;attentions&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;evaluate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;encoder1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;attn_decoder1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;i explained the rule to him .&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;matshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;attentions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;numpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;matplotlib.image.AxesImage at 0x7f1ba0c524e0&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/dO35Fh1.png&quot; alt=&quot;png&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;showAttention&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_sentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output_words&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;attentions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;# Set up figure with colorbar
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;fig&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;ax&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fig&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add_subplot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;111&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;cax&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;matshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;attentions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;numpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cmap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;bone&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;fig&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;colorbar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# Set up axes
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;ax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_xticklabels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input_sentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;
                       &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;&amp;lt;EOS&amp;gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rotation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;90&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;ax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_yticklabels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output_words&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# Show label at every tick
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;ax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xaxis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_major_locator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ticker&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MultipleLocator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;ax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;yaxis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_major_locator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ticker&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MultipleLocator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;evaluateAndShowAttention&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_sentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;output_words&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;attentions&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;evaluate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;encoder1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;attn_decoder1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input_sentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;input =&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input_sentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;output =&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output_words&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;showAttention&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_sentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output_words&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;attentions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;evaluateAndShowAttention&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;the thief cursed the police for finding him .&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;evaluateAndShowAttention&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;they gave us very little trouble .&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;evaluateAndShowAttention&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;the thief gave the police very little trouble .&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;input = the thief cursed the police for finding him .
output = चोर ने चोर को उसको पकड़ने के लिए गाली दी। &amp;lt;EOS&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/0OBjLCn.png&quot; alt=&quot;png&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;input = they gave us very little trouble .
output = उन्होंने हमको बहुत कम कष्ट दिया। &amp;lt;EOS&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/0RKWipZ.png&quot; alt=&quot;png&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;input = the thief gave the police very little trouble .
output = उस आदमी को बहुत कम दिया। &amp;lt;EOS&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/2XVjZew.png&quot; alt=&quot;png&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;Pytorch language translation tutorial.&lt;/li&gt;
  &lt;li&gt;Attention Network for NLP.&lt;/li&gt;
  &lt;li&gt;https://www.manythings.org/anki/&lt;/li&gt;
&lt;/ol&gt;
</description>
        <pubDate>Sun, 28 Apr 2019 00:00:00 +0000</pubDate>
        <link>https://ashutoshmishra.dev/tech/2019/04/28/EnglishtoHindi-with-attention-network.html</link>
        <guid isPermaLink="true">https://ashutoshmishra.dev/tech/2019/04/28/EnglishtoHindi-with-attention-network.html</guid>
        
        <category>Ashutosh</category>
        
        <category>Encoder</category>
        
        <category>Decoder</category>
        
        <category>NLP</category>
        
        <category>Pytorch</category>
        
        
        <category>tech</category>
        
      </item>
    
      <item>
        <title>Uncertainty-Quantification</title>
        <description>&lt;p&gt;&lt;img src=&quot;http://mlg.eng.cam.ac.uk/yarin/blog_images/reg_demo_small.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://ash1998.github.io/deep%20learning/python/machine%20learning/2018/12/25/Uncertainity-Quantification.html&quot;&gt;&lt;strong&gt;__This page works best with desktop site(the canvas graph below!)__&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Many a times Deep Neural Networks trained on large datasets have remarkable accuracy. But sometimes they can’t predict as accurate, these might be due to limited training data, poor generalization, or because of noise in data. In many such cases, models whose main goal is to predict something that will have a long term impact on decision making representing &lt;strong&gt;uncertainty&lt;/strong&gt; is important.&lt;/p&gt;

&lt;h2 id=&quot;uncertainty-in-deep-learning&quot;&gt;&lt;strong&gt;Uncertainty in Deep Learning&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;Understanding what a model does not know is a critical part of many machine learning systems. Unfortunately, today’s deep learning algorithms are usually unable to understand their uncertainty. These models are often taken blindly and assumed to be accurate, which is not always the case.&lt;/p&gt;

&lt;p&gt;For example : An image classification system erroneously identified two African American humans as gorillas, raising concerns of racial discrimination. &lt;a href=&quot;https://www.usatoday.com/story/tech/2015/07/01/google-apologizes-after-photos-identify-black-people-as-gorillas/29567465/&quot;&gt;Read the report here.&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;who-comes-to-the-rescue-&quot;&gt;&lt;strong&gt;Who comes to the rescue ?&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;BDL(Bayesian Deep Learning)&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most materials in this post have been taken from two papers below by &lt;a href=&quot;https://alexgkendall.com/&quot;&gt;Alex Kendal&lt;/a&gt; and &lt;a href=&quot;http://www.cs.ox.ac.uk/people/yarin.gal/website/&quot;&gt;Yarin Gal&lt;/a&gt;.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;What Uncertainties Do We Need in Bayesian Deep Learning for Computer Vision? Alex Kendall and Yarin Gal, 2017. &lt;a href=&quot;https://arxiv.org/pdf/1703.04977.pdf&quot;&gt;(.pdf)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Multi-Task Learning Using Uncertainty to Weigh Losses for Scene Geometry and Semantics. Alex Kendall, Yarin Gal and Roberto Cipolla, 2017. &lt;a href=&quot;https://arxiv.org/pdf/1705.07115.pdf&quot;&gt;(.pdf)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;types-of-uncertainty-&quot;&gt;&lt;strong&gt;Types of Uncertainty&lt;/strong&gt; :&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Mathematical model and experimental measurement&lt;/strong&gt;
    &lt;ul&gt;
      &lt;li&gt;Parameter&lt;/li&gt;
      &lt;li&gt;Structural&lt;/li&gt;
      &lt;li&gt;Algorithmic&lt;/li&gt;
      &lt;li&gt;Experminetal&lt;/li&gt;
      &lt;li&gt;Interpolation&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Model Generated&lt;/strong&gt;
    &lt;ul&gt;
      &lt;li&gt;Epistemic&lt;/li&gt;
      &lt;li&gt;Aleatoric&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We will discuss the later part of uncertainty i.e model generated in this blog.&lt;/p&gt;

&lt;h2 id=&quot;epistemic-uncertainty&quot;&gt;&lt;strong&gt;Epistemic Uncertainty&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Epistemic Uncertainty&lt;/em&gt;&lt;/strong&gt; is caused when model ignores certain effects or because a particular part of data is hidden. This happens mostly due to low variance in training samples.     &lt;br /&gt;
Useful in:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Safety critical applications&lt;/li&gt;
  &lt;li&gt;Small datasets.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;aleatoric-uncertainty&quot;&gt;&lt;strong&gt;Aleatoric Uncertainty&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Aleatoric Uncertainty&lt;/em&gt;&lt;/strong&gt; Aleatoric uncertainty captures the uncertainty with respect to information which our data cannot explain. For example, aleatoric uncertainty in images can be attributed to occlusions (because cameras can’t see through objects).   &lt;br /&gt;
Useful in :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Large data situations&lt;/li&gt;
  &lt;li&gt;Real-time applications, because we can form aleatoric models as a deterministic function of the input data, without expensive Monte Carlo sampling.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;image-from-what-uncertainties-do-we-need-in-bayesian-deep-learning-for-computer-vision&quot;&gt;Image from What Uncertainties Do We Need in Bayesian Deep Learning for Computer Vision?&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/yYWp3af.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Illustrating the difference between aleatoric and epistemic uncertainty for semantic segmentation. You can notice that aleatoric uncertainty captures object boundaries where labels are noisy. The bottom row shows a failure case of the segmentation model, when the model is unfamiliar with the footpath, and the corresponding increased epistemic uncertainty.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Bayesian deep learning is a field at the intersection between deep learning and Bayesian probability theory. Bayesian deep learning models typically form uncertainty estimates by either placing distributions over model weights, or by learning a direct mapping to probabilistic outputs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Heteroscedastic uncertainty model&lt;/strong&gt;
In this model we replace the Euclidean Loss (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Loss=||y−y^||2&lt;/code&gt;) with&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;                                       Loss=||y−y^||22σ2+12logσ2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The model predicts a mean y^ and variance σ2. As you can see from this equation, if the model predicts something very wrong, then it will be encouraged to attenuate the residual term, by increasing uncertainty σ2. However, the logσ2 prevents the uncertainty term growing infinitely large. This can be thought of as learned loss attenuation.&lt;/p&gt;

&lt;p&gt;Epistemic uncertainty is much harder to model. This requires us to model distributions over models and their parameters which is much harder to achieve at scale. A popular technique to model this is Monte Carlo dropout sampling which places a Bernoulli distribution over the network’s weights.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;example&quot;&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;Next an example to deal with model uncertainty on an ensemble model for SPY 500 prediction using keras backend.
Find the full notebook here : &lt;a href=&quot;https://github.com/ASH1998/MLAlgorithms/blob/master/NewMLSPY_(1).html&quot;&gt;MLSPY500.nb&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;`&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;def model_uncertainity2(model, x_test, y_test, B, confidence):
    
    MC_output = K.function([model.layers[0].input, K.learning_phase()], [model.layers[-1].output])
    learning_phase = True  # use dropout at test time
    MC_samples = [MC_output([x_test, learning_phase])[0] for _ in range(B)]
    MC_samples = np.array(MC_samples)
    eta1 = np.mean(MC_samples - (np.mean(MC_samples)**2))#model misspecification and model uncertainity 
    eta2 = mean_squared_error(model.predict(x_test), y_test) #inherent noise
    model_uncer = np.sqrt(eta1**2 + eta2**2)

    Merror = (st.norm.ppf((1+(confidence/100))/2))*model_uncer

    return Merror

    Parameters      
    &apos;&apos;&apos;     
    :param model: model class object; lstm or gru       
    :x_test: array, test X sample       
    :y_test: array, test y sample       
    :B: int, beta factor for number of iterations for Monte Carlo       
    :confidence: percent;int , percent factor of uncertainity       
    &apos;&apos;&apos; ` - Getting uncertainity in any model.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Theory:&lt;/p&gt;

    &lt;p&gt;p(yi/xi,Xtrain,Ytrain)=∫p(yi/xi,ω)   &lt;br /&gt;
p(ω/Xtrain,Ytrain)      &lt;br /&gt;
dω≈∫p(yi/xi,ω)qθ(ω)dω     &lt;br /&gt;
=:qθ(yi/xi)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;we have that yi is a draw from an approximation to the predictive distribution.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;This process is equivalent to drawing a new function for each test point, which results in extremely erratic depictions that have peaks at different locations&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Drawing a new function for each test point makes no difference if all we care about is obtaining the predictive mean and predictive variance, but this process does not result in draws from the induced distribution over functions&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The result is shown below.&lt;/p&gt;

&lt;p&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/p&gt;
&lt;html lang=&quot;en&quot;&gt;
    &lt;head&gt;
        &lt;meta charset=&quot;utf-8&quot; /&gt;
        &lt;link href=&quot;https://www.highcharts.com/highslide/highslide.css&quot; rel=&quot;stylesheet&quot; /&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;https://code.highcharts.com/stock/highstock.js&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;https://code.highcharts.com/stock/modules/exporting.js&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;https://code.highcharts.com/highcharts-more.js&quot;&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body style=&quot;margin:0;padding:0&quot;&gt;
                &lt;div id=&quot;container&quot; style=&quot;&quot;&gt;Loading....&lt;/div&gt;


    &lt;script&gt;
        $(function(){





            Highcharts.setOptions({&quot;global&quot;: {}, &quot;lang&quot;: {}});
            var option = {&quot;chart&quot;: {&quot;renderTo&quot;: &quot;container&quot;, &quot;backgroundColor&quot;: {&quot;linearGradient&quot;: {&quot;x1&quot;: 0, &quot;y1&quot;: 0, &quot;x2&quot;: 1, &quot;y2&quot;: 1}, &quot;stops&quot;: [[0, &quot;#2a2a2b&quot;], [1, &quot;#3e3e40&quot;]]}, &quot;style&quot;: {&quot;fontFamily&quot;: &quot;&apos;Unica One&apos;, sans-serif&quot;}, &quot;plotBorderColor&quot;: &quot;#606063&quot;}, &quot;colors&quot;: [&quot;#2b908f&quot;, &quot;#90ee7e&quot;, &quot;#f45b5b&quot;, &quot;#7798BF&quot;, &quot;#aaeeee&quot;, &quot;#ff0066&quot;, &quot;#eeaaee&quot;, &quot;#55BF3B&quot;, &quot;#DF5353&quot;, &quot;#7798BF&quot;, &quot;#aaeeee&quot;], &quot;credits&quot;: {&quot;enabled&quot;: false}, &quot;exporting&quot;: {}, &quot;labels&quot;: {}, &quot;legend&quot;: {}, &quot;loading&quot;: {}, &quot;navigation&quot;: {}, &quot;navigator&quot;: {}, &quot;plotOptions&quot;: {}, &quot;rangeSelector&quot;: {&quot;inputBoxBorderColor&quot;: &quot;#505053&quot;, &quot;inputStyle&quot;: {&quot;backgroundColor&quot;: &quot;#333&quot;, &quot;color&quot;: &quot;silver&quot;}, &quot;labelStyle&quot;: {&quot;color&quot;: &quot;silver&quot;}}, &quot;scrollbar&quot;: {}, &quot;series&quot;: {}, &quot;subtitle&quot;: {&quot;style&quot;: {&quot;color&quot;: &quot;#E0E0E3&quot;, &quot;textTransform&quot;: &quot;uppercase&quot;}}, &quot;title&quot;: {&quot;text&quot;: &quot;lead_10&quot;, &quot;style&quot;: {&quot;color&quot;: &quot;#E0E0E3&quot;, &quot;textTransform&quot;: &quot;uppercase&quot;, &quot;fontSize&quot;: &quot;20px&quot;}}, &quot;tooltip&quot;: {&quot;backgroundColor&quot;: &quot;rgba(0, 0, 0, 0.85)&quot;, &quot;style&quot;: {&quot;color&quot;: &quot;#F0F0F0&quot;}}, &quot;xAxis&quot;: {&quot;gridLineColor&quot;: &quot;#707073&quot;, &quot;labels&quot;: {&quot;style&quot;: {&quot;color&quot;: &quot;#E0E0E3&quot;}}, &quot;lineColor&quot;: &quot;#707073&quot;, &quot;minorGridLineColor&quot;: &quot;#505053&quot;, &quot;tickColor&quot;: &quot;#707073&quot;, &quot;title&quot;: {&quot;style&quot;: {&quot;color&quot;: &quot;#A0A0A3&quot;}}}, &quot;yAxis&quot;: {&quot;gridLineColor&quot;: &quot;#707073&quot;, &quot;labels&quot;: {&quot;style&quot;: {&quot;color&quot;: &quot;#E0E0E3&quot;}}, &quot;lineColor&quot;: &quot;#707073&quot;, &quot;minorGridLineColor&quot;: &quot;#505053&quot;, &quot;tickColor&quot;: &quot;#707073&quot;, &quot;tickWidth&quot;: 1, &quot;title&quot;: {&quot;style&quot;: {&quot;color&quot;: &quot;#A0A0A3&quot;}}}};


            var chart = new Highcharts.StockChart(option);



            var data = [{&quot;data&quot;: [[Date.UTC(2015,10,9,0,0,0,0.0), 205.99000549316406], [Date.UTC(2015,10,10,0,0,0,0.0), 207.07000732421875], [Date.UTC(2015,10,11,0,0,0,0.0), 206.60000610351562], [Date.UTC(2015,10,12,0,0,0,0.0), 203.80999755859375], [Date.UTC(2015,10,13,0,0,0,0.0), 202.2899932861328], [Date.UTC(2015,10,16,0,0,0,0.0), 203.92999267578125], [Date.UTC(2015,10,17,0,0,0,0.0), 204.1699981689453], [Date.UTC(2015,10,18,0,0,0,0.0), 206.42999267578125], [Date.UTC(2015,10,19,0,0,0,0.0), 206.91000366210938], [Date.UTC(2015,10,20,0,0,0,0.0), 207.39999389648438], [Date.UTC(2015,10,23,0,0,0,0.0), 207.80999755859375], [Date.UTC(2015,10,24,0,0,0,0.0), 207.22999572753906], [Date.UTC(2015,10,25,0,0,0,0.0), 208.33999633789062], [Date.UTC(2015,10,27,0,0,0,0.0), 208.8800048828125], [Date.UTC(2015,10,30,0,0,0,0.0), 206.7100067138672], [Date.UTC(2015,11,1,0,0,0,0.0), 208.4600067138672], [Date.UTC(2015,11,2,0,0,0,0.0), 206.6199951171875], [Date.UTC(2015,11,3,0,0,0,0.0), 204.3699951171875], [Date.UTC(2015,11,4,0,0,0,0.0), 206.64999389648438], [Date.UTC(2015,11,7,0,0,0,0.0), 206.47000122070312], [Date.UTC(2015,11,8,0,0,0,0.0), 205.25999450683594], [Date.UTC(2015,11,9,0,0,0,0.0), 204.0500030517578], [Date.UTC(2015,11,10,0,0,0,0.0), 204.3800048828125], [Date.UTC(2015,11,11,0,0,0,0.0), 202.25999450683594], [Date.UTC(2015,11,14,0,0,0,0.0), 202.2899932861328], [Date.UTC(2015,11,15,0,0,0,0.0), 203.64999389648438], [Date.UTC(2015,11,16,0,0,0,0.0), 205.6699981689453], [Date.UTC(2015,11,17,0,0,0,0.0), 203.9499969482422], [Date.UTC(2015,11,18,0,0,0,0.0), 201.8800048828125], [Date.UTC(2015,11,21,0,0,0,0.0), 201.8300018310547], [Date.UTC(2015,11,22,0,0,0,0.0), 202.8000030517578], [Date.UTC(2015,11,23,0,0,0,0.0), 204.4199981689453], [Date.UTC(2015,11,24,0,0,0,0.0), 205.47000122070312], [Date.UTC(2015,11,28,0,0,0,0.0), 204.58999633789062], [Date.UTC(2015,11,29,0,0,0,0.0), 205.77000427246094], [Date.UTC(2015,11,30,0,0,0,0.0), 205.4199981689453], [Date.UTC(2015,11,31,0,0,0,0.0), 203.30999755859375], [Date.UTC(2016,0,4,0,0,0,0.0), 201.64999389648438], [Date.UTC(2016,0,5,0,0,0,0.0), 201.55999755859375], [Date.UTC(2016,0,6,0,0,0,0.0), 200.02999877929688], [Date.UTC(2016,0,7,0,0,0,0.0), 198.5399932861328], [Date.UTC(2016,0,8,0,0,0,0.0), 197.5800018310547], [Date.UTC(2016,0,11,0,0,0,0.0), 197.24000549316406], [Date.UTC(2016,0,12,0,0,0,0.0), 197.67999267578125], [Date.UTC(2016,0,13,0,0,0,0.0), 196.83999633789062], [Date.UTC(2016,0,14,0,0,0,0.0), 197.4199981689453], [Date.UTC(2016,0,15,0,0,0,0.0), 197.42999267578125], [Date.UTC(2016,0,19,0,0,0,0.0), 195.74000549316406], [Date.UTC(2016,0,20,0,0,0,0.0), 195.74000549316406], [Date.UTC(2016,0,21,0,0,0,0.0), 195.02999877929688], [Date.UTC(2016,0,22,0,0,0,0.0), 196.3300018310547], [Date.UTC(2016,0,25,0,0,0,0.0), 195.75999450683594], [Date.UTC(2016,0,26,0,0,0,0.0), 196.16000366210938], [Date.UTC(2016,0,27,0,0,0,0.0), 195.80999755859375], [Date.UTC(2016,0,28,0,0,0,0.0), 195.97999572753906], [Date.UTC(2016,0,29,0,0,0,0.0), 197.60000610351562], [Date.UTC(2016,1,1,0,0,0,0.0), 197.6699981689453], [Date.UTC(2016,1,2,0,0,0,0.0), 196.5399932861328], [Date.UTC(2016,1,3,0,0,0,0.0), 196.9199981689453], [Date.UTC(2016,1,4,0,0,0,0.0), 196.8699951171875], [Date.UTC(2016,1,5,0,0,0,0.0), 195.88999938964844], [Date.UTC(2016,1,8,0,0,0,0.0), 194.49000549316406], [Date.UTC(2016,1,9,0,0,0,0.0), 194.35000610351562], [Date.UTC(2016,1,10,0,0,0,0.0), 194.74000549316406], [Date.UTC(2016,1,11,0,0,0,0.0), 193.7100067138672], [Date.UTC(2016,1,12,0,0,0,0.0), 194.75], [Date.UTC(2016,1,16,0,0,0,0.0), 196.1300048828125], [Date.UTC(2016,1,17,0,0,0,0.0), 197.27999877929688], [Date.UTC(2016,1,18,0,0,0,0.0), 197.50999450683594], [Date.UTC(2016,1,19,0,0,0,0.0), 197.08999633789062], [Date.UTC(2016,1,22,0,0,0,0.0), 198.39999389648438], [Date.UTC(2016,1,23,0,0,0,0.0), 197.66000366210938], [Date.UTC(2016,1,24,0,0,0,0.0), 197.27999877929688], [Date.UTC(2016,1,25,0,0,0,0.0), 198.47999572753906], [Date.UTC(2016,1,26,0,0,0,0.0), 198.6699981689453], [Date.UTC(2016,1,29,0,0,0,0.0), 198.07000732421875], [Date.UTC(2016,2,1,0,0,0,0.0), 199.30999755859375], [Date.UTC(2016,2,2,0,0,0,0.0), 200.3300018310547], [Date.UTC(2016,2,3,0,0,0,0.0), 200.7899932861328], [Date.UTC(2016,2,4,0,0,0,0.0), 200.8300018310547], [Date.UTC(2016,2,7,0,0,0,0.0), 201.1999969482422], [Date.UTC(2016,2,8,0,0,0,0.0), 200.10000610351562], [Date.UTC(2016,2,9,0,0,0,0.0), 200.82000732421875], [Date.UTC(2016,2,10,0,0,0,0.0), 200.4499969482422], [Date.UTC(2016,2,11,0,0,0,0.0), 202.02000427246094], [Date.UTC(2016,2,14,0,0,0,0.0), 202.7899932861328], [Date.UTC(2016,2,15,0,0,0,0.0), 202.22999572753906], [Date.UTC(2016,2,16,0,0,0,0.0), 202.49000549316406], [Date.UTC(2016,2,17,0,0,0,0.0), 203.36000061035156], [Date.UTC(2016,2,18,0,0,0,0.0), 203.27999877929688], [Date.UTC(2016,2,21,0,0,0,0.0), 204.1300048828125], [Date.UTC(2016,2,22,0,0,0,0.0), 203.6300048828125], [Date.UTC(2016,2,23,0,0,0,0.0), 203.22000122070312], [Date.UTC(2016,2,24,0,0,0,0.0), 202.91000366210938], [Date.UTC(2016,2,28,0,0,0,0.0), 203.5399932861328], [Date.UTC(2016,2,29,0,0,0,0.0), 203.89999389648438], [Date.UTC(2016,2,30,0,0,0,0.0), 204.9199981689453], [Date.UTC(2016,2,31,0,0,0,0.0), 204.5], [Date.UTC(2016,3,1,0,0,0,0.0), 204.9600067138672], [Date.UTC(2016,3,4,0,0,0,0.0), 205.49000549316406], [Date.UTC(2016,3,5,0,0,0,0.0), 203.6300048828125], [Date.UTC(2016,3,6,0,0,0,0.0), 204.8800048828125], [Date.UTC(2016,3,7,0,0,0,0.0), 203.35000610351562], [Date.UTC(2016,3,8,0,0,0,0.0), 203.75999450683594], [Date.UTC(2016,3,11,0,0,0,0.0), 203.75], [Date.UTC(2016,3,12,0,0,0,0.0), 204.2899932861328], [Date.UTC(2016,3,13,0,0,0,0.0), 206.1699981689453], [Date.UTC(2016,3,14,0,0,0,0.0), 206.9600067138672], [Date.UTC(2016,3,15,0,0,0,0.0), 206.4499969482422], [Date.UTC(2016,3,18,0,0,0,0.0), 207.57000732421875], [Date.UTC(2016,3,19,0,0,0,0.0), 208.0], [Date.UTC(2016,3,20,0,0,0,0.0), 208.47000122070312], [Date.UTC(2016,3,21,0,0,0,0.0), 207.42999267578125], [Date.UTC(2016,3,22,0,0,0,0.0), 207.02999877929688], [Date.UTC(2016,3,25,0,0,0,0.0), 207.41000366210938], [Date.UTC(2016,3,26,0,0,0,0.0), 207.4600067138672], [Date.UTC(2016,3,27,0,0,0,0.0), 207.77999877929688], [Date.UTC(2016,3,28,0,0,0,0.0), 205.89999389648438], [Date.UTC(2016,3,29,0,0,0,0.0), 204.61000061035156], [Date.UTC(2016,4,2,0,0,0,0.0), 206.82000732421875], [Date.UTC(2016,4,3,0,0,0,0.0), 204.6999969482422], [Date.UTC(2016,4,4,0,0,0,0.0), 204.08999633789062], [Date.UTC(2016,4,5,0,0,0,0.0), 204.5500030517578], [Date.UTC(2016,4,6,0,0,0,0.0), 204.5], [Date.UTC(2016,4,9,0,0,0,0.0), 205.05999755859375], [Date.UTC(2016,4,10,0,0,0,0.0), 206.8800048828125], [Date.UTC(2016,4,11,0,0,0,0.0), 205.47999572753906], [Date.UTC(2016,4,12,0,0,0,0.0), 205.2100067138672], [Date.UTC(2016,4,13,0,0,0,0.0), 203.97999572753906], [Date.UTC(2016,4,16,0,0,0,0.0), 205.47999572753906], [Date.UTC(2016,4,17,0,0,0,0.0), 203.86000061035156], [Date.UTC(2016,4,18,0,0,0,0.0), 203.6699981689453], [Date.UTC(2016,4,19,0,0,0,0.0), 203.1999969482422], [Date.UTC(2016,4,20,0,0,0,0.0), 204.1999969482422], [Date.UTC(2016,4,23,0,0,0,0.0), 204.8800048828125], [Date.UTC(2016,4,24,0,0,0,0.0), 206.08999633789062], [Date.UTC(2016,4,25,0,0,0,0.0), 207.6300048828125], [Date.UTC(2016,4,26,0,0,0,0.0), 208.2899932861328], [Date.UTC(2016,4,27,0,0,0,0.0), 208.91000366210938], [Date.UTC(2016,4,31,0,0,0,0.0), 207.6699981689453], [Date.UTC(2016,5,1,0,0,0,0.0), 208.72000122070312], [Date.UTC(2016,5,2,0,0,0,0.0), 209.4499969482422], [Date.UTC(2016,5,3,0,0,0,0.0), 208.08999633789062], [Date.UTC(2016,5,6,0,0,0,0.0), 209.8699951171875], [Date.UTC(2016,5,7,0,0,0,0.0), 210.36000061035156], [Date.UTC(2016,5,8,0,0,0,0.0), 210.80999755859375], [Date.UTC(2016,5,9,0,0,0,0.0), 210.27999877929688], [Date.UTC(2016,5,10,0,0,0,0.0), 207.8000030517578], [Date.UTC(2016,5,13,0,0,0,0.0), 206.50999450683594], [Date.UTC(2016,5,14,0,0,0,0.0), 205.92999267578125], [Date.UTC(2016,5,15,0,0,0,0.0), 205.97000122070312], [Date.UTC(2016,5,16,0,0,0,0.0), 205.92999267578125], [Date.UTC(2016,5,17,0,0,0,0.0), 204.86000061035156], [Date.UTC(2016,5,20,0,0,0,0.0), 206.47999572753906], [Date.UTC(2016,5,21,0,0,0,0.0), 207.0500030517578], [Date.UTC(2016,5,22,0,0,0,0.0), 206.3800048828125], [Date.UTC(2016,5,23,0,0,0,0.0), 208.58999633789062], [Date.UTC(2016,5,24,0,0,0,0.0), 205.32000732421875], [Date.UTC(2016,5,27,0,0,0,0.0), 201.41000366210938], [Date.UTC(2016,5,28,0,0,0,0.0), 202.3800048828125], [Date.UTC(2016,5,29,0,0,0,0.0), 204.6999969482422], [Date.UTC(2016,5,30,0,0,0,0.0), 206.67999267578125], [Date.UTC(2016,6,1,0,0,0,0.0), 207.77999877929688], [Date.UTC(2016,6,5,0,0,0,0.0), 206.38999938964844], [Date.UTC(2016,6,6,0,0,0,0.0), 207.52000427246094], [Date.UTC(2016,6,7,0,0,0,0.0), 207.7899932861328], [Date.UTC(2016,6,8,0,0,0,0.0), 209.77999877929688], [Date.UTC(2016,6,11,0,0,0,0.0), 211.5500030517578], [Date.UTC(2016,6,12,0,0,0,0.0), 212.50999450683594], [Date.UTC(2016,6,13,0,0,0,0.0), 212.72999572753906], [Date.UTC(2016,6,14,0,0,0,0.0), 213.7899932861328], [Date.UTC(2016,6,15,0,0,0,0.0), 213.3699951171875], [Date.UTC(2016,6,18,0,0,0,0.0), 214.74000549316406], [Date.UTC(2016,6,19,0,0,0,0.0), 214.6999969482422], [Date.UTC(2016,6,20,0,0,0,0.0), 215.3300018310547], [Date.UTC(2016,6,21,0,0,0,0.0), 214.41000366210938], [Date.UTC(2016,6,22,0,0,0,0.0), 215.42999267578125], [Date.UTC(2016,6,25,0,0,0,0.0), 214.97999572753906], [Date.UTC(2016,6,26,0,0,0,0.0), 214.77000427246094], [Date.UTC(2016,6,27,0,0,0,0.0), 214.3300018310547], [Date.UTC(2016,6,28,0,0,0,0.0), 214.88999938964844], [Date.UTC(2016,6,29,0,0,0,0.0), 214.9199981689453], [Date.UTC(2016,7,1,0,0,0,0.0), 214.9499969482422], [Date.UTC(2016,7,2,0,0,0,0.0), 213.24000549316406], [Date.UTC(2016,7,3,0,0,0,0.0), 214.6199951171875], [Date.UTC(2016,7,4,0,0,0,0.0), 214.97000122070312], [Date.UTC(2016,7,5,0,0,0,0.0), 216.0500030517578], [Date.UTC(2016,7,8,0,0,0,0.0), 216.6999969482422], [Date.UTC(2016,7,9,0,0,0,0.0), 216.52999877929688], [Date.UTC(2016,7,10,0,0,0,0.0), 215.9199981689453], [Date.UTC(2016,7,11,0,0,0,0.0), 216.57000732421875], [Date.UTC(2016,7,12,0,0,0,0.0), 216.72999572753906], [Date.UTC(2016,7,15,0,0,0,0.0), 217.42999267578125], [Date.UTC(2016,7,16,0,0,0,0.0), 216.32000732421875], [Date.UTC(2016,7,17,0,0,0,0.0), 216.22000122070312], [Date.UTC(2016,7,18,0,0,0,0.0), 217.1300048828125], [Date.UTC(2016,7,19,0,0,0,0.0), 216.3800048828125], [Date.UTC(2016,7,22,0,0,0,0.0), 216.63999938964844], [Date.UTC(2016,7,23,0,0,0,0.0), 217.25999450683594], [Date.UTC(2016,7,24,0,0,0,0.0), 215.86000061035156], [Date.UTC(2016,7,25,0,0,0,0.0), 215.7100067138672], [Date.UTC(2016,7,26,0,0,0,0.0), 214.35000610351562], [Date.UTC(2016,7,29,0,0,0,0.0), 216.27999877929688], [Date.UTC(2016,7,30,0,0,0,0.0), 216.27000427246094], [Date.UTC(2016,7,31,0,0,0,0.0), 215.10000610351562], [Date.UTC(2016,8,1,0,0,0,0.0), 214.88999938964844], [Date.UTC(2016,8,2,0,0,0,0.0), 216.13999938964844], [Date.UTC(2016,8,6,0,0,0,0.0), 217.27999877929688], [Date.UTC(2016,8,7,0,0,0,0.0), 216.8000030517578], [Date.UTC(2016,8,8,0,0,0,0.0), 216.3800048828125], [Date.UTC(2016,8,9,0,0,0,0.0), 209.9600067138672], [Date.UTC(2016,8,12,0,0,0,0.0), 212.44000244140625], [Date.UTC(2016,8,13,0,0,0,0.0), 209.82000732421875], [Date.UTC(2016,8,14,0,0,0,0.0), 210.3000030517578], [Date.UTC(2016,8,15,0,0,0,0.0), 212.05999755859375], [Date.UTC(2016,8,16,0,0,0,0.0), 210.19000244140625], [Date.UTC(2016,8,19,0,0,0,0.0), 211.4499969482422], [Date.UTC(2016,8,20,0,0,0,0.0), 211.72000122070312], [Date.UTC(2016,8,21,0,0,0,0.0), 213.02999877929688], [Date.UTC(2016,8,22,0,0,0,0.0), 215.0399932861328], [Date.UTC(2016,8,23,0,0,0,0.0), 214.05999755859375], [Date.UTC(2016,8,26,0,0,0,0.0), 212.05999755859375], [Date.UTC(2016,8,27,0,0,0,0.0), 213.49000549316406], [Date.UTC(2016,8,28,0,0,0,0.0), 214.2899932861328], [Date.UTC(2016,8,29,0,0,0,0.0), 211.8699951171875], [Date.UTC(2016,8,30,0,0,0,0.0), 213.61000061035156], [Date.UTC(2016,9,3,0,0,0,0.0), 213.57000732421875], [Date.UTC(2016,9,4,0,0,0,0.0), 211.9199981689453], [Date.UTC(2016,9,5,0,0,0,0.0), 213.66000366210938], [Date.UTC(2016,9,6,0,0,0,0.0), 213.99000549316406], [Date.UTC(2016,9,7,0,0,0,0.0), 212.7899932861328], [Date.UTC(2016,9,10,0,0,0,0.0), 214.6300048828125], [Date.UTC(2016,9,11,0,0,0,0.0), 210.64999389648438], [Date.UTC(2016,9,12,0,0,0,0.0), 211.82000732421875], [Date.UTC(2016,9,13,0,0,0,0.0), 210.60000610351562], [Date.UTC(2016,9,14,0,0,0,0.0), 211.0], [Date.UTC(2016,9,17,0,0,0,0.0), 211.0], [Date.UTC(2016,9,18,0,0,0,0.0), 211.8000030517578], [Date.UTC(2016,9,19,0,0,0,0.0), 212.52000427246094], [Date.UTC(2016,9,20,0,0,0,0.0), 211.99000549316406], [Date.UTC(2016,9,21,0,0,0,0.0), 211.77000427246094], [Date.UTC(2016,9,24,0,0,0,0.0), 213.25999450683594], [Date.UTC(2016,9,25,0,0,0,0.0), 212.49000549316406], [Date.UTC(2016,9,26,0,0,0,0.0), 211.7899932861328], [Date.UTC(2016,9,27,0,0,0,0.0), 211.32000732421875], [Date.UTC(2016,9,28,0,0,0,0.0), 209.63999938964844], [Date.UTC(2016,9,31,0,0,0,0.0), 211.08999633789062], [Date.UTC(2016,10,1,0,0,0,0.0), 208.5500030517578], [Date.UTC(2016,10,2,0,0,0,0.0), 207.63999938964844], [Date.UTC(2016,10,3,0,0,0,0.0), 207.05999755859375], [Date.UTC(2016,10,4,0,0,0,0.0), 206.58999633789062], [Date.UTC(2016,10,7,0,0,0,0.0), 210.50999450683594], [Date.UTC(2016,10,8,0,0,0,0.0), 211.55999755859375], [Date.UTC(2016,10,9,0,0,0,0.0), 212.02999877929688], [Date.UTC(2016,10,10,0,0,0,0.0), 213.08999633789062], [Date.UTC(2016,10,11,0,0,0,0.0), 213.9499969482422], [Date.UTC(2016,10,14,0,0,0,0.0), 214.17999267578125], [Date.UTC(2016,10,15,0,0,0,0.0), 215.83999633789062], [Date.UTC(2016,10,16,0,0,0,0.0), 215.9199981689453], [Date.UTC(2016,10,17,0,0,0,0.0), 216.89999389648438], [Date.UTC(2016,10,18,0,0,0,0.0), 216.19000244140625], [Date.UTC(2016,10,21,0,0,0,0.0), 217.97000122070312], [Date.UTC(2016,10,22,0,0,0,0.0), 218.5], [Date.UTC(2016,10,23,0,0,0,0.0), 218.80999755859375], [Date.UTC(2016,10,25,0,0,0,0.0), 219.9499969482422], [Date.UTC(2016,10,28,0,0,0,0.0), 218.35000610351562], [Date.UTC(2016,10,29,0,0,0,0.0), 218.77999877929688], [Date.UTC(2016,10,30,0,0,0,0.0), 217.72000122070312], [Date.UTC(2016,11,1,0,0,0,0.0), 217.35000610351562], [Date.UTC(2016,11,2,0,0,0,0.0), 217.5399932861328], [Date.UTC(2016,11,5,0,0,0,0.0), 218.89999389648438], [Date.UTC(2016,11,6,0,0,0,0.0), 219.7100067138672], [Date.UTC(2016,11,7,0,0,0,0.0), 221.49000549316406], [Date.UTC(2016,11,8,0,0,0,0.0), 222.41000366210938], [Date.UTC(2016,11,9,0,0,0,0.0), 223.8800048828125], [Date.UTC(2016,11,12,0,0,0,0.0), 223.5500030517578], [Date.UTC(2016,11,13,0,0,0,0.0), 224.6999969482422], [Date.UTC(2016,11,14,0,0,0,0.0), 222.2899932861328], [Date.UTC(2016,11,15,0,0,0,0.0), 223.49000549316406], [Date.UTC(2016,11,16,0,0,0,0.0), 221.32000732421875], [Date.UTC(2016,11,19,0,0,0,0.0), 222.8699951171875], [Date.UTC(2016,11,20,0,0,0,0.0), 223.72000122070312], [Date.UTC(2016,11,21,0,0,0,0.0), 223.6300048828125], [Date.UTC(2016,11,22,0,0,0,0.0), 223.3800048828125], [Date.UTC(2016,11,23,0,0,0,0.0), 223.97999572753906], [Date.UTC(2016,11,27,0,0,0,0.0), 224.44000244140625], [Date.UTC(2016,11,28,0,0,0,0.0), 222.3800048828125], [Date.UTC(2016,11,29,0,0,0,0.0), 222.47999572753906], [Date.UTC(2016,11,30,0,0,0,0.0), 220.6999969482422], [Date.UTC(2017,0,3,0,0,0,0.0), 222.50999450683594], [Date.UTC(2017,0,4,0,0,0,0.0), 224.0399932861328], [Date.UTC(2017,0,5,0,0,0,0.0), 223.8800048828125], [Date.UTC(2017,0,6,0,0,0,0.0), 224.7899932861328], [Date.UTC(2017,0,9,0,0,0,0.0), 224.5500030517578], [Date.UTC(2017,0,10,0,0,0,0.0), 224.27000427246094], [Date.UTC(2017,0,11,0,0,0,0.0), 224.63999938964844], [Date.UTC(2017,0,12,0,0,0,0.0), 224.1199951171875], [Date.UTC(2017,0,13,0,0,0,0.0), 224.80999755859375], [Date.UTC(2017,0,17,0,0,0,0.0), 224.08999633789062], [Date.UTC(2017,0,18,0,0,0,0.0), 224.6999969482422], [Date.UTC(2017,0,19,0,0,0,0.0), 223.67999267578125], [Date.UTC(2017,0,20,0,0,0,0.0), 223.47999572753906], [Date.UTC(2017,0,23,0,0,0,0.0), 223.75999450683594], [Date.UTC(2017,0,24,0,0,0,0.0), 224.77999877929688], [Date.UTC(2017,0,25,0,0,0,0.0), 226.85000610351562], [Date.UTC(2017,0,26,0,0,0,0.0), 227.08999633789062], [Date.UTC(2017,0,27,0,0,0,0.0), 226.7899932861328], [Date.UTC(2017,0,30,0,0,0,0.0), 225.05999755859375], [Date.UTC(2017,0,31,0,0,0,0.0), 225.05999755859375], [Date.UTC(2017,1,1,0,0,0,0.0), 225.1300048828125], [Date.UTC(2017,1,2,0,0,0,0.0), 225.3800048828125], [Date.UTC(2017,1,3,0,0,0,0.0), 226.6999969482422], [Date.UTC(2017,1,6,0,0,0,0.0), 226.74000549316406], [Date.UTC(2017,1,7,0,0,0,0.0), 226.8000030517578], [Date.UTC(2017,1,8,0,0,0,0.0), 227.1199951171875], [Date.UTC(2017,1,9,0,0,0,0.0), 228.1699981689453], [Date.UTC(2017,1,10,0,0,0,0.0), 229.0800018310547], [Date.UTC(2017,1,13,0,0,0,0.0), 230.47000122070312], [Date.UTC(2017,1,14,0,0,0,0.0), 231.10000610351562], [Date.UTC(2017,1,15,0,0,0,0.0), 232.0500030517578], [Date.UTC(2017,1,16,0,0,0,0.0), 231.89999389648438], [Date.UTC(2017,1,17,0,0,0,0.0), 232.41000366210938], [Date.UTC(2017,1,21,0,0,0,0.0), 233.6699981689453], [Date.UTC(2017,1,22,0,0,0,0.0), 233.77999877929688], [Date.UTC(2017,1,23,0,0,0,0.0), 233.77000427246094], [Date.UTC(2017,1,24,0,0,0,0.0), 233.88999938964844], [Date.UTC(2017,1,27,0,0,0,0.0), 234.6999969482422], [Date.UTC(2017,1,28,0,0,0,0.0), 233.74000549316406], [Date.UTC(2017,2,1,0,0,0,0.0), 235.9199981689453], [Date.UTC(2017,2,2,0,0,0,0.0), 235.6300048828125], [Date.UTC(2017,2,3,0,0,0,0.0), 235.72999572753906], [Date.UTC(2017,2,6,0,0,0,0.0), 235.25999450683594], [Date.UTC(2017,2,7,0,0,0,0.0), 234.52999877929688], [Date.UTC(2017,2,8,0,0,0,0.0), 233.9499969482422], [Date.UTC(2017,2,9,0,0,0,0.0), 233.88999938964844], [Date.UTC(2017,2,10,0,0,0,0.0), 234.88999938964844], [Date.UTC(2017,2,13,0,0,0,0.0), 235.3800048828125], [Date.UTC(2017,2,14,0,0,0,0.0), 234.44000244140625], [Date.UTC(2017,2,15,0,0,0,0.0), 235.86000061035156], [Date.UTC(2017,2,16,0,0,0,0.0), 235.69000244140625], [Date.UTC(2017,2,17,0,0,0,0.0), 234.27000427246094], [Date.UTC(2017,2,20,0,0,0,0.0), 234.4199981689453], [Date.UTC(2017,2,21,0,0,0,0.0), 230.25], [Date.UTC(2017,2,22,0,0,0,0.0), 231.25999450683594], [Date.UTC(2017,2,23,0,0,0,0.0), 230.94000244140625], [Date.UTC(2017,2,24,0,0,0,0.0), 230.5800018310547], [Date.UTC(2017,2,27,0,0,0,0.0), 230.66000366210938], [Date.UTC(2017,2,28,0,0,0,0.0), 232.30999755859375], [Date.UTC(2017,2,29,0,0,0,0.0), 233.14999389648438], [Date.UTC(2017,2,30,0,0,0,0.0), 233.83999633789062], [Date.UTC(2017,2,31,0,0,0,0.0), 233.1699981689453], [Date.UTC(2017,3,3,0,0,0,0.0), 232.47000122070312], [Date.UTC(2017,3,4,0,0,0,0.0), 233.11000061035156], [Date.UTC(2017,3,5,0,0,0,0.0), 231.61000061035156], [Date.UTC(2017,3,6,0,0,0,0.0), 232.86000061035156], [Date.UTC(2017,3,7,0,0,0,0.0), 232.58999633789062], [Date.UTC(2017,3,10,0,0,0,0.0), 232.82000732421875], [Date.UTC(2017,3,11,0,0,0,0.0), 232.11000061035156], [Date.UTC(2017,3,12,0,0,0,0.0), 231.35000610351562], [Date.UTC(2017,3,13,0,0,0,0.0), 229.77999877929688], [Date.UTC(2017,3,17,0,0,0,0.0), 232.0], [Date.UTC(2017,3,18,0,0,0,0.0), 231.0800018310547], [Date.UTC(2017,3,19,0,0,0,0.0), 230.97000122070312], [Date.UTC(2017,3,20,0,0,0,0.0), 232.30999755859375], [Date.UTC(2017,3,21,0,0,0,0.0), 231.42999267578125], [Date.UTC(2017,3,24,0,0,0,0.0), 233.57000732421875], [Date.UTC(2017,3,25,0,0,0,0.0), 235.77000427246094], [Date.UTC(2017,3,26,0,0,0,0.0), 235.49000549316406], [Date.UTC(2017,3,27,0,0,0,0.0), 236.13999938964844], [Date.UTC(2017,3,28,0,0,0,0.0), 235.6699981689453], [Date.UTC(2017,4,1,0,0,0,0.0), 236.25], [Date.UTC(2017,4,2,0,0,0,0.0), 236.27000427246094], [Date.UTC(2017,4,3,0,0,0,0.0), 235.80999755859375], [Date.UTC(2017,4,4,0,0,0,0.0), 236.16000366210938], [Date.UTC(2017,4,5,0,0,0,0.0), 237.10000610351562], [Date.UTC(2017,4,8,0,0,0,0.0), 237.25999450683594], [Date.UTC(2017,4,9,0,0,0,0.0), 237.02000427246094], [Date.UTC(2017,4,10,0,0,0,0.0), 237.3699951171875], [Date.UTC(2017,4,11,0,0,0,0.0), 236.75999450683594], [Date.UTC(2017,4,12,0,0,0,0.0), 236.5399932861328], [Date.UTC(2017,4,15,0,0,0,0.0), 237.6199951171875], [Date.UTC(2017,4,16,0,0,0,0.0), 237.6300048828125], [Date.UTC(2017,4,17,0,0,0,0.0), 244.4199981689453], [Date.UTC(2017,4,18,0,0,0,0.0), 233.38999938964844], [Date.UTC(2017,4,19,0,0,0,0.0), 234.72999572753906], [Date.UTC(2017,4,22,0,0,0,0.0), 237.02999877929688], [Date.UTC(2017,4,23,0,0,0,0.0), 237.6300048828125], [Date.UTC(2017,4,24,0,0,0,0.0), 238.14999389648438], [Date.UTC(2017,4,25,0,0,0,0.0), 239.02000427246094], [Date.UTC(2017,4,26,0,0,0,0.0), 239.27999877929688], [Date.UTC(2017,4,30,0,0,0,0.0), 239.25], [Date.UTC(2017,4,31,0,0,0,0.0), 238.3699951171875], [Date.UTC(2017,5,1,0,0,0,0.0), 240.47000122070312], [Date.UTC(2017,5,2,0,0,0,0.0), 240.99000549316406], [Date.UTC(2017,5,5,0,0,0,0.0), 241.5500030517578], [Date.UTC(2017,5,6,0,0,0,0.0), 240.6999969482422], [Date.UTC(2017,5,7,0,0,0,0.0), 241.07000732421875], [Date.UTC(2017,5,8,0,0,0,0.0), 241.0], [Date.UTC(2017,5,9,0,0,0,0.0), 239.52000427246094], [Date.UTC(2017,5,12,0,0,0,0.0), 240.22999572753906], [Date.UTC(2017,5,13,0,0,0,0.0), 241.8000030517578], [Date.UTC(2017,5,14,0,0,0,0.0), 241.25], [Date.UTC(2017,5,15,0,0,0,0.0), 240.94000244140625], [Date.UTC(2017,5,16,0,0,0,0.0), 239.6199951171875], [Date.UTC(2017,5,19,0,0,0,0.0), 241.83999633789062], [Date.UTC(2017,5,20,0,0,0,0.0), 240.44000244140625], [Date.UTC(2017,5,21,0,0,0,0.0), 240.35000610351562], [Date.UTC(2017,5,22,0,0,0,0.0), 240.44000244140625], [Date.UTC(2017,5,23,0,0,0,0.0), 240.3300018310547], [Date.UTC(2017,5,26,0,0,0,0.0), 240.6999969482422], [Date.UTC(2017,5,27,0,0,0,0.0), 238.4199981689453], [Date.UTC(2017,5,28,0,0,0,0.0), 240.60000610351562], [Date.UTC(2017,5,29,0,0,0,0.0), 238.02000427246094], [Date.UTC(2017,5,30,0,0,0,0.0), 238.74000549316406], [Date.UTC(2017,6,3,0,0,0,0.0), 239.91000366210938], [Date.UTC(2017,6,5,0,0,0,0.0), 240.1699981689453], [Date.UTC(2017,6,6,0,0,0,0.0), 237.88999938964844], [Date.UTC(2017,6,7,0,0,0,0.0), 239.4499969482422], [Date.UTC(2017,6,10,0,0,0,0.0), 240.07000732421875], [Date.UTC(2017,6,11,0,0,0,0.0), 239.66000366210938], [Date.UTC(2017,6,12,0,0,0,0.0), 241.27999877929688], [Date.UTC(2017,6,13,0,0,0,0.0), 242.02999877929688], [Date.UTC(2017,6,14,0,0,0,0.0), 242.77999877929688], [Date.UTC(2017,6,17,0,0,0,0.0), 243.25], [Date.UTC(2017,6,18,0,0,0,0.0), 243.1699981689453], [Date.UTC(2017,6,19,0,0,0,0.0), 244.32000732421875], [Date.UTC(2017,6,20,0,0,0,0.0), 244.5399932861328], [Date.UTC(2017,6,21,0,0,0,0.0), 243.6999969482422], [Date.UTC(2017,6,24,0,0,0,0.0), 244.25999450683594], [Date.UTC(2017,6,25,0,0,0,0.0), 244.75], [Date.UTC(2017,6,26,0,0,0,0.0), 244.86000061035156], [Date.UTC(2017,6,27,0,0,0,0.0), 244.25999450683594], [Date.UTC(2017,6,28,0,0,0,0.0), 244.30999755859375], [Date.UTC(2017,6,31,0,0,0,0.0), 243.92999267578125], [Date.UTC(2017,7,1,0,0,0,0.0), 244.61000061035156], [Date.UTC(2017,7,2,0,0,0,0.0), 244.8800048828125], [Date.UTC(2017,7,3,0,0,0,0.0), 244.52000427246094], [Date.UTC(2017,7,4,0,0,0,0.0), 244.6199951171875], [Date.UTC(2017,7,7,0,0,0,0.0), 245.5], [Date.UTC(2017,7,8,0,0,0,0.0), 244.47999572753906], [Date.UTC(2017,7,9,0,0,0,0.0), 244.3800048828125], [Date.UTC(2017,7,10,0,0,0,0.0), 240.24000549316406], [Date.UTC(2017,7,11,0,0,0,0.0), 241.1699981689453], [Date.UTC(2017,7,14,0,0,0,0.0), 243.5399932861328], [Date.UTC(2017,7,15,0,0,0,0.0), 243.8800048828125], [Date.UTC(2017,7,16,0,0,0,0.0), 244.25], [Date.UTC(2017,7,17,0,0,0,0.0), 239.11000061035156], [Date.UTC(2017,7,18,0,0,0,0.0), 238.75], [Date.UTC(2017,7,21,0,0,0,0.0), 240.1699981689453], [Date.UTC(2017,7,22,0,0,0,0.0), 242.5800018310547], [Date.UTC(2017,7,23,0,0,0,0.0), 242.02000427246094], [Date.UTC(2017,7,24,0,0,0,0.0), 241.49000549316406], [Date.UTC(2017,7,25,0,0,0,0.0), 241.86000061035156], [Date.UTC(2017,7,28,0,0,0,0.0), 242.24000549316406], [Date.UTC(2017,7,29,0,0,0,0.0), 242.19000244140625], [Date.UTC(2017,7,30,0,0,0,0.0), 243.22000122070312], [Date.UTC(2017,7,31,0,0,0,0.0), 244.16000366210938], [Date.UTC(2017,8,1,0,0,0,0.0), 245.07000732421875], [Date.UTC(2017,8,5,0,0,0,0.0), 244.7100067138672], [Date.UTC(2017,8,6,0,0,0,0.0), 244.14999389648438], [Date.UTC(2017,8,7,0,0,0,0.0), 244.13999938964844], [Date.UTC(2017,8,8,0,0,0,0.0), 243.77999877929688], [Date.UTC(2017,8,11,0,0,0,0.0), 246.1699981689453], [Date.UTC(2017,8,12,0,0,0,0.0), 247.24000549316406], [Date.UTC(2017,8,13,0,0,0,0.0), 247.32000732421875], [Date.UTC(2017,8,14,0,0,0,0.0), 246.83999633789062], [Date.UTC(2017,8,15,0,0,0,0.0), 245.91000366210938], [Date.UTC(2017,8,18,0,0,0,0.0), 247.11000061035156], [Date.UTC(2017,8,19,0,0,0,0.0), 247.33999633789062], [Date.UTC(2017,8,20,0,0,0,0.0), 247.2100067138672], [Date.UTC(2017,8,21,0,0,0,0.0), 246.77999877929688], [Date.UTC(2017,8,22,0,0,0,0.0), 246.74000549316406], [Date.UTC(2017,8,25,0,0,0,0.0), 246.16000366210938], [Date.UTC(2017,8,26,0,0,0,0.0), 246.3699951171875], [Date.UTC(2017,8,27,0,0,0,0.0), 246.85000610351562], [Date.UTC(2017,8,28,0,0,0,0.0), 247.72000122070312], [Date.UTC(2017,8,29,0,0,0,0.0), 247.9499969482422], [Date.UTC(2017,9,2,0,0,0,0.0), 249.47000122070312], [Date.UTC(2017,9,3,0,0,0,0.0), 249.89999389648438], [Date.UTC(2017,9,4,0,0,0,0.0), 250.41000366210938], [Date.UTC(2017,9,5,0,0,0,0.0), 251.64999389648438], [Date.UTC(2017,9,6,0,0,0,0.0), 251.19000244140625], [Date.UTC(2017,9,9,0,0,0,0.0), 251.47999572753906], [Date.UTC(2017,9,10,0,0,0,0.0), 251.99000549316406], [Date.UTC(2017,9,11,0,0,0,0.0), 252.3300018310547], [Date.UTC(2017,9,12,0,0,0,0.0), 251.9499969482422], [Date.UTC(2017,9,13,0,0,0,0.0), 252.14999389648438], [Date.UTC(2017,9,16,0,0,0,0.0), 252.72000122070312], [Date.UTC(2017,9,17,0,0,0,0.0), 253.0], [Date.UTC(2017,9,18,0,0,0,0.0), 253.1300048828125], [Date.UTC(2017,9,19,0,0,0,0.0), 252.7899932861328], [Date.UTC(2017,9,20,0,0,0,0.0), 253.66000366210938], [Date.UTC(2017,9,23,0,0,0,0.0), 253.19000244140625], [Date.UTC(2017,9,24,0,0,0,0.0), 253.60000610351562], [Date.UTC(2017,9,25,0,0,0,0.0), 251.72999572753906], [Date.UTC(2017,9,26,0,0,0,0.0), 252.5800018310547], [Date.UTC(2017,9,27,0,0,0,0.0), 254.2899932861328], [Date.UTC(2017,9,30,0,0,0,0.0), 253.94000244140625], [Date.UTC(2017,9,31,0,0,0,0.0), 254.25], [Date.UTC(2017,10,1,0,0,0,0.0), 254.69000244140625], [Date.UTC(2017,10,2,0,0,0,0.0), 254.6999969482422], [Date.UTC(2017,10,3,0,0,0,0.0), 255.47000122070312], [Date.UTC(2017,10,6,0,0,0,0.0), 256.04998779296875], [Date.UTC(2017,10,7,0,0,0,0.0), 255.77999877929688], [Date.UTC(2017,10,8,0,0,0,0.0), 256.2900085449219], [Date.UTC(2017,10,9,0,0,0,0.0), 254.6199951171875], [Date.UTC(2017,10,10,0,0,0,0.0), 255.1300048828125], [Date.UTC(2017,10,13,0,0,0,0.0), 255.5], [Date.UTC(2017,10,14,0,0,0,0.0), 254.75999450683594], [Date.UTC(2017,10,15,0,0,0,0.0), 253.19000244140625], [Date.UTC(2017,10,16,0,0,0,0.0), 255.5], [Date.UTC(2017,10,17,0,0,0,0.0), 254.69000244140625], [Date.UTC(2017,10,20,0,0,0,0.0), 255.5399932861328], [Date.UTC(2017,10,21,0,0,0,0.0), 256.8299865722656], [Date.UTC(2017,10,22,0,0,0,0.0), 257.05999755859375], [Date.UTC(2017,10,24,0,0,0,0.0), 257.9100036621094], [Date.UTC(2017,10,27,0,0,0,0.0), 257.4100036621094], [Date.UTC(2017,10,28,0,0,0,0.0), 259.1700134277344], [Date.UTC(2017,10,29,0,0,0,0.0), 259.4800109863281], [Date.UTC(2017,10,30,0,0,0,0.0), 260.95001220703125], [Date.UTC(2017,11,1,0,0,0,0.0), 259.8800048828125], [Date.UTC(2017,11,4,0,0,0,0.0), 260.7099914550781], [Date.UTC(2017,11,5,0,0,0,0.0), 259.989990234375], [Date.UTC(2017,11,6,0,0,0,0.0), 259.989990234375], [Date.UTC(2017,11,7,0,0,0,0.0), 260.7699890136719], [Date.UTC(2017,11,8,0,0,0,0.0), 262.2300109863281], [Date.UTC(2017,11,11,0,0,0,0.0), 262.9800109863281], [Date.UTC(2017,11,12,0,0,0,0.0), 263.3900146484375], [Date.UTC(2017,11,13,0,0,0,0.0), 263.1000061035156], [Date.UTC(2017,11,14,0,0,0,0.0), 262.1099853515625], [Date.UTC(2017,11,15,0,0,0,0.0), 262.2200012207031], [Date.UTC(2017,11,18,0,0,0,0.0), 264.8800048828125], [Date.UTC(2017,11,19,0,0,0,0.0), 263.95001220703125], [Date.UTC(2017,11,20,0,0,0,0.0), 263.82000732421875], [Date.UTC(2017,11,21,0,0,0,0.0), 264.54998779296875], [Date.UTC(2017,11,22,0,0,0,0.0), 264.2099914550781], [Date.UTC(2017,11,26,0,0,0,0.0), 264.44000244140625], [Date.UTC(2017,11,27,0,0,0,0.0), 264.3699951171875], [Date.UTC(2017,11,28,0,0,0,0.0), 265.1300048828125], [Date.UTC(2017,11,29,0,0,0,0.0), 263.3599853515625], [Date.UTC(2018,0,2,0,0,0,0.0), 265.489990234375], [Date.UTC(2018,0,3,0,0,0,0.0), 266.9599914550781], [Date.UTC(2018,0,4,0,0,0,0.0), 268.2799987792969], [Date.UTC(2018,0,5,0,0,0,0.0), 270.04998779296875], [Date.UTC(2018,0,8,0,0,0,0.0), 270.9599914550781], [Date.UTC(2018,0,9,0,0,0,0.0), 271.6300048828125], [Date.UTC(2018,0,10,0,0,0,0.0), 270.9700012207031], [Date.UTC(2018,0,11,0,0,0,0.0), 273.05999755859375], [Date.UTC(2018,0,12,0,0,0,0.0), 274.489990234375], [Date.UTC(2018,0,16,0,0,0,0.0), 273.4800109863281], [Date.UTC(2018,0,17,0,0,0,0.0), 275.95001220703125], [Date.UTC(2018,0,18,0,0,0,0.0), 275.739990234375], [Date.UTC(2018,0,19,0,0,0,0.0), 276.4700012207031], [Date.UTC(2018,0,22,0,0,0,0.0), 279.54998779296875], [Date.UTC(2018,0,23,0,0,0,0.0), 280.1400146484375], [Date.UTC(2018,0,24,0,0,0,0.0), 279.5199890136719], [Date.UTC(2018,0,25,0,0,0,0.0), 280.2799987792969], [Date.UTC(2018,0,26,0,0,0,0.0), 283.3500061035156], [Date.UTC(2018,0,29,0,0,0,0.0), 281.70001220703125], [Date.UTC(2018,0,30,0,0,0,0.0), 278.1499938964844], [Date.UTC(2018,0,31,0,0,0,0.0), 278.489990234375], [Date.UTC(2018,1,1,0,0,0,0.0), 278.4100036621094], [Date.UTC(2018,1,2,0,0,0,0.0), 271.17999267578125], [Date.UTC(2018,1,5,0,0,0,0.0), 258.510009765625], [Date.UTC(2018,1,6,0,0,0,0.0), 263.32000732421875], [Date.UTC(2018,1,7,0,0,0,0.0), 263.19000244140625], [Date.UTC(2018,1,8,0,0,0,0.0), 252.38999938964844], [Date.UTC(2018,1,9,0,0,0,0.0), 255.80999755859375], [Date.UTC(2018,1,12,0,0,0,0.0), 261.0400085449219], [Date.UTC(2018,1,13,0,0,0,0.0), 262.5899963378906], [Date.UTC(2018,1,14,0,0,0,0.0), 265.4599914550781], [Date.UTC(2018,1,15,0,0,0,0.0), 269.20001220703125], [Date.UTC(2018,1,16,0,0,0,0.0), 268.7799987792969], [Date.UTC(2018,1,20,0,0,0,0.0), 268.07000732421875], [Date.UTC(2018,1,21,0,0,0,0.0), 266.5899963378906], [Date.UTC(2018,1,22,0,0,0,0.0), 266.7099914550781], [Date.UTC(2018,1,23,0,0,0,0.0), 271.1499938964844], [Date.UTC(2018,1,26,0,0,0,0.0), 274.489990234375], [Date.UTC(2018,1,27,0,0,0,0.0), 271.0299987792969], [Date.UTC(2018,1,28,0,0,0,0.0), 267.9100036621094], [Date.UTC(2018,2,1,0,0,0,0.0), 263.1400146484375], [Date.UTC(2018,2,2,0,0,0,0.0), 264.7699890136719], [Date.UTC(2018,2,5,0,0,0,0.0), 268.44000244140625], [Date.UTC(2018,2,6,0,0,0,0.0), 269.67999267578125], [Date.UTC(2018,2,7,0,0,0,0.0), 269.260009765625], [Date.UTC(2018,2,8,0,0,0,0.0), 270.9800109863281], [Date.UTC(2018,2,9,0,0,0,0.0), 275.1000061035156], [Date.UTC(2018,2,12,0,0,0,0.0), 275.5199890136719], [Date.UTC(2018,2,13,0,0,0,0.0), 273.4599914550781], [Date.UTC(2018,2,14,0,0,0,0.0), 271.7699890136719], [Date.UTC(2018,2,15,0,0,0,0.0), 271.739990234375], [Date.UTC(2018,2,19,0,0,0,0.0), 266.8399963378906], [Date.UTC(2018,2,20,0,0,0,0.0), 267.9800109863281], [Date.UTC(2018,2,21,0,0,0,0.0), 267.20001220703125], [Date.UTC(2018,2,22,0,0,0,0.0), 259.5199890136719], [Date.UTC(2018,2,23,0,0,0,0.0), 253.3699951171875], [Date.UTC(2018,2,26,0,0,0,0.0), 260.7200012207031], [Date.UTC(2018,2,27,0,0,0,0.0), 256.7200012207031], [Date.UTC(2018,2,28,0,0,0,0.0), 255.52999877929688], [Date.UTC(2018,2,29,0,0,0,0.0), 259.07000732421875], [Date.UTC(2018,3,2,0,0,0,0.0), 252.69000244140625], [Date.UTC(2018,3,3,0,0,0,0.0), 256.7099914550781], [Date.UTC(2018,3,4,0,0,0,0.0), 259.2900085449219], [Date.UTC(2018,3,5,0,0,0,0.0), 262.29998779296875], [Date.UTC(2018,3,6,0,0,0,0.0), 254.97000122070312], [Date.UTC(2018,3,9,0,0,0,0.0), 257.3500061035156], [Date.UTC(2018,3,10,0,0,0,0.0), 261.3900146484375], [Date.UTC(2018,3,11,0,0,0,0.0), 260.2900085449219], [Date.UTC(2018,3,12,0,0,0,0.0), 262.7900085449219], [Date.UTC(2018,3,13,0,0,0,0.0), 261.8399963378906], [Date.UTC(2018,3,16,0,0,0,0.0), 264.2799987792969], [Date.UTC(2018,3,17,0,0,0,0.0), 267.1000061035156], [Date.UTC(2018,3,18,0,0,0,0.0), 267.4700012207031], [Date.UTC(2018,3,19,0,0,0,0.0), 265.6300048828125], [Date.UTC(2018,3,20,0,0,0,0.0), 263.1000061035156], [Date.UTC(2018,3,23,0,0,0,0.0), 263.510009765625], [Date.UTC(2018,3,24,0,0,0,0.0), 259.32000732421875], [Date.UTC(2018,3,25,0,0,0,0.0), 259.8800048828125], [Date.UTC(2018,3,26,0,0,0,0.0), 263.1300048828125], [Date.UTC(2018,3,27,0,0,0,0.0), 263.6300048828125], [Date.UTC(2018,3,30,0,0,0,0.0), 261.3299865722656], [Date.UTC(2018,4,1,0,0,0,0.0), 261.6400146484375], [Date.UTC(2018,4,2,0,0,0,0.0), 259.8800048828125], [Date.UTC(2018,4,3,0,0,0,0.0), 258.3800048828125], [Date.UTC(2018,4,4,0,0,0,0.0), 262.3699951171875], [Date.UTC(2018,4,7,0,0,0,0.0), 264.010009765625], [Date.UTC(2018,4,8,0,0,0,0.0), 263.7699890136719], [Date.UTC(2018,4,9,0,0,0,0.0), 266.4200134277344], [Date.UTC(2018,4,10,0,0,0,0.0), 268.7799987792969], [Date.UTC(2018,4,11,0,0,0,0.0), 269.8399963378906], [Date.UTC(2018,4,14,0,0,0,0.0), 270.1099853515625], [Date.UTC(2018,4,15,0,0,0,0.0), 267.69000244140625], [Date.UTC(2018,4,16,0,0,0,0.0), 269.3299865722656], [Date.UTC(2018,4,17,0,0,0,0.0), 269.0899963378906], [Date.UTC(2018,4,18,0,0,0,0.0), 268.29998779296875], [Date.UTC(2018,4,21,0,0,0,0.0), 270.3900146484375], [Date.UTC(2018,4,22,0,0,0,0.0), 269.80999755859375], [Date.UTC(2018,4,23,0,0,0,0.0), 270.20001220703125], [Date.UTC(2018,4,24,0,0,0,0.0), 269.54998779296875], [Date.UTC(2018,4,25,0,0,0,0.0), 269.2300109863281], [Date.UTC(2018,4,29,0,0,0,0.0), 265.2099914550781], [Date.UTC(2018,4,30,0,0,0,0.0), 269.3900146484375], [Date.UTC(2018,4,31,0,0,0,0.0), 267.510009765625], [Date.UTC(2018,5,1,0,0,0,0.0), 270.4100036621094], [Date.UTC(2018,5,4,0,0,0,0.0), 272.1700134277344], [Date.UTC(2018,5,5,0,0,0,0.0), 272.2799987792969], [Date.UTC(2018,5,6,0,0,0,0.0), 274.3500061035156], [Date.UTC(2018,5,7,0,0,0,0.0), 274.2699890136719], [Date.UTC(2018,5,8,0,0,0,0.0), 275.04998779296875], [Date.UTC(2018,5,11,0,0,0,0.0), 275.7200012207031], [Date.UTC(2018,5,12,0,0,0,0.0), 275.8699951171875], [Date.UTC(2018,5,13,0,0,0,0.0), 274.8999938964844], [Date.UTC(2018,5,14,0,0,0,0.0), 275.7099914550781], [Date.UTC(2018,5,15,0,0,0,0.0), 273.3999938964844], [Date.UTC(2018,5,18,0,0,0,0.0), 273.67999267578125], [Date.UTC(2018,5,19,0,0,0,0.0), 271.9100036621094], [Date.UTC(2018,5,20,0,0,0,0.0), 273.1400146484375], [Date.UTC(2018,5,21,0,0,0,0.0), 271.1700134277344], [Date.UTC(2018,5,22,0,0,0,0.0), 271.8900146484375], [Date.UTC(2018,5,25,0,0,0,0.0), 266.95001220703125], [Date.UTC(2018,5,26,0,0,0,0.0), 268.4800109863281], [Date.UTC(2018,5,27,0,0,0,0.0), 265.7900085449219], [Date.UTC(2018,5,28,0,0,0,0.0), 267.55999755859375], [Date.UTC(2018,5,29,0,0,0,0.0), 267.760009765625], [Date.UTC(2018,6,2,0,0,0,0.0), 268.7099914550781], [Date.UTC(2018,6,3,0,0,0,0.0), 268.2900085449219], [Date.UTC(2018,6,5,0,0,0,0.0), 270.1300048828125], [Date.UTC(2018,6,6,0,0,0,0.0), 272.260009765625], [Date.UTC(2018,6,9,0,0,0,0.0), 275.1000061035156], [Date.UTC(2018,6,10,0,0,0,0.0), 276.1600036621094], [Date.UTC(2018,6,11,0,0,0,0.0), 273.70001220703125], [Date.UTC(2018,6,12,0,0,0,0.0), 276.4599914550781], [Date.UTC(2018,6,13,0,0,0,0.0), 276.9200134277344], [Date.UTC(2018,6,16,0,0,0,0.0), 276.70001220703125], [Date.UTC(2018,6,17,0,0,0,0.0), 277.69000244140625], [Date.UTC(2018,6,18,0,0,0,0.0), 278.5], [Date.UTC(2018,6,19,0,0,0,0.0), 277.17999267578125], [Date.UTC(2018,6,24,0,0,0,0.0), 278.7300109863281], [Date.UTC(2018,6,25,0,0,0,0.0), 280.9800109863281], [Date.UTC(2018,6,26,0,0,0,0.0), 280.70001220703125], [Date.UTC(2018,6,27,0,0,0,0.0), 278.489990234375], [Date.UTC(2018,6,30,0,0,0,0.0), 277.1499938964844], [Date.UTC(2018,6,31,0,0,0,0.0), 278.42999267578125], [Date.UTC(2018,7,1,0,0,0,0.0), 278.2099914550781], [Date.UTC(2018,7,2,0,0,0,0.0), 279.44000244140625], [Date.UTC(2018,7,3,0,0,0,0.0), 280.9599914550781], [Date.UTC(2018,7,4,0,0,0,0.0), 279.5400085449219]], &quot;type&quot;: &quot;line&quot;, &quot;marker&quot;: {&quot;fillColor&quot;: &quot;white&quot;, &quot;lineWidth&quot;: 2, &quot;lineColor&quot;: Highcharts.getOptions().colors[0]}, &quot;name&quot;: &quot;predicted&quot;, &quot;tooltip&quot;: {&quot;valueDecimals&quot;: 4}, &quot;zIndex&quot;: 1}, {&quot;data&quot;: [[Date.UTC(2015,10,9,0,0,0,0.0), 223.37471359902784, 188.60529738730028], [Date.UTC(2015,10,10,0,0,0,0.0), 224.54586313669932, 189.59415151173818], [Date.UTC(2015,10,11,0,0,0,0.0), 224.03619574864132, 189.16381645838993], [Date.UTC(2015,10,12,0,0,0,0.0), 221.01072197301465, 186.60927314417285], [Date.UTC(2015,10,13,0,0,0,0.0), 219.36243560000648, 185.21755097225915], [Date.UTC(2015,10,16,0,0,0,0.0), 221.1408441838999, 186.7191411676626], [Date.UTC(2015,10,17,0,0,0,0.0), 221.40110515223847, 186.93889118565215], [Date.UTC(2015,10,18,0,0,0,0.0), 223.85183388779652, 189.00815146376598], [Date.UTC(2015,10,19,0,0,0,0.0), 224.37235582447363, 189.44765149974512], [Date.UTC(2015,10,20,0,0,0,0.0), 224.9036992166338, 189.89628857633494], [Date.UTC(2015,10,23,0,0,0,0.0), 225.3483054992492, 190.2716896179383], [Date.UTC(2015,10,24,0,0,0,0.0), 224.71935390235703, 189.7406375527211], [Date.UTC(2015,10,25,0,0,0,0.0), 225.92303399274982, 190.75695868303143], [Date.UTC(2015,10,27,0,0,0,0.0), 226.5086170348696, 191.2513927307554], [Date.UTC(2015,10,30,0,0,0,0.0), 224.1554799574755, 189.26453347025887], [Date.UTC(2015,11,1,0,0,0,0.0), 226.05317275020312, 190.86684067753126], [Date.UTC(2015,11,2,0,0,0,0.0), 224.05787175274352, 189.18211848163148], [Date.UTC(2015,11,3,0,0,0,0.0), 221.6179810192366, 187.1220092151384], [Date.UTC(2015,11,4,0,0,0,0.0), 224.09040230546483, 189.20958548750392], [Date.UTC(2015,11,7,0,0,0,0.0), 223.89521898913694, 189.04478345226931], [Date.UTC(2015,11,8,0,0,0,0.0), 222.58309269196107, 187.9368963217108], [Date.UTC(2015,11,9,0,0,0,0.0), 221.2709829413532, 186.82902316216243], [Date.UTC(2015,11,10,0,0,0,0.0), 221.62883556785573, 187.13117419776927], [Date.UTC(2015,11,11,0,0,0,0.0), 219.32990504728517, 185.1900839663867], [Date.UTC(2015,11,14,0,0,0,0.0), 219.36243560000648, 185.21755097225915], [Date.UTC(2015,11,15,0,0,0,0.0), 220.83721466078893, 186.46277313217982], [Date.UTC(2015,11,16,0,0,0,0.0), 223.02769897457642, 188.3122973633142], [Date.UTC(2015,11,17,0,0,0,0.0), 221.16253673457012, 186.73745716191425], [Date.UTC(2015,11,18,0,0,0,0.0), 218.91784586395912, 184.84216390166588], [Date.UTC(2015,11,21,0,0,0,0.0), 218.86362276056758, 184.7963809015418], [Date.UTC(2015,11,22,0,0,0,0.0), 219.9154880894049, 185.68451801411072], [Date.UTC(2015,11,23,0,0,0,0.0), 221.67220412262813, 187.1677922152625], [Date.UTC(2015,11,24,0,0,0,0.0), 222.8108231075783, 188.12917933382795], [Date.UTC(2015,11,28,0,0,0,0.0), 221.85654943690494, 187.3234432388763], [Date.UTC(2015,11,29,0,0,0,0.0), 223.1361451813595, 188.40386336356238], [Date.UTC(2015,11,30,0,0,0,0.0), 222.75660000418677, 188.08339633370386], [Date.UTC(2015,11,31,0,0,0,0.0), 220.46852403223534, 186.15147108495216], [Date.UTC(2016,0,4,0,0,0,0.0), 218.66842289767166, 184.6315648952971], [Date.UTC(2016,0,5,0,0,0,0.0), 218.57083123950773, 184.54916387767977], [Date.UTC(2016,0,6,0,0,0,0.0), 216.91170686444843, 183.14829069414532], [Date.UTC(2016,0,7,0,0,0,0.0), 215.2959510441616, 181.78403552810403], [Date.UTC(2016,0,8,0,0,0,0.0), 214.25494026394338, 180.905063398166], [Date.UTC(2016,0,11,0,0,0,0.0), 213.8862496353898, 180.59376135093834], [Date.UTC(2016,0,12,0,0,0,0.0), 214.36336992415843, 180.99661542740407], [Date.UTC(2016,0,13,0,0,0,0.0), 213.45248135482552, 180.22751132095573], [Date.UTC(2016,0,14,0,0,0,0.0), 214.0814329517177, 180.75856338617294], [Date.UTC(2016,0,15,0,0,0,0.0), 214.09227095376878, 180.76771439779372], [Date.UTC(2016,0,19,0,0,0,0.0), 212.25965581305184, 179.2203551732763], [Date.UTC(2016,0,20,0,0,0,0.0), 212.25965581305184, 179.2203551732763], [Date.UTC(2016,0,21,0,0,0,0.0), 211.48972745665526, 178.5702701019385], [Date.UTC(2016,0,22,0,0,0,0.0), 212.8994454119951, 179.7605582501143], [Date.UTC(2016,0,25,0,0,0,0.0), 212.281331817154, 179.23865719651786], [Date.UTC(2016,0,26,0,0,0,0.0), 212.71510009771828, 179.60490722650047], [Date.UTC(2016,0,27,0,0,0,0.0), 212.33555492054558, 179.28444019664192], [Date.UTC(2016,0,28,0,0,0,0.0), 212.51990023482236, 179.44009122025577], [Date.UTC(2016,0,29,0,0,0,0.0), 214.2766328146136, 180.92337939241764], [Date.UTC(2016,1,1,0,0,0,0.0), 214.35253192210735, 180.98746441578328], [Date.UTC(2016,1,2,0,0,0,0.0), 213.12715928104433, 179.9528272912213], [Date.UTC(2016,1,3,0,0,0,0.0), 213.53923501093837, 180.30076132695226], [Date.UTC(2016,1,4,0,0,0,0.0), 213.48501190754683, 180.25497832682817], [Date.UTC(2016,1,5,0,0,0,0.0), 212.42230857665842, 179.35769020263845], [Date.UTC(2016,1,8,0,0,0,0.0), 210.9041609611035, 178.0758500252246], [Date.UTC(2016,1,9,0,0,0,0.0), 210.75234619954804, 177.9476660074832], [Date.UTC(2016,1,10,0,0,0,0.0), 211.1752599314932, 178.30475105483492], [Date.UTC(2016,1,11,0,0,0,0.0), 210.05833349721323, 177.36167993052115], [Date.UTC(2016,1,12,0,0,0,0.0), 211.1860979335443, 178.3139020664557], [Date.UTC(2016,1,16,0,0,0,0.0), 212.68256954499697, 179.57744022062803], [Date.UTC(2016,1,17,0,0,0,0.0), 213.9296181901622, 180.63037936843156], [Date.UTC(2016,1,18,0,0,0,0.0), 214.17902460988165, 180.84096440379022], [Date.UTC(2016,1,19,0,0,0,0.0), 213.72358032521518, 180.45641235056607], [Date.UTC(2016,1,22,0,0,0,0.0), 215.1441362826061, 181.65585151036265], [Date.UTC(2016,1,23,0,0,0,0.0), 214.34169392005623, 180.97831340416252], [Date.UTC(2016,1,24,0,0,0,0.0), 213.9296181901622, 180.63037936843156], [Date.UTC(2016,1,25,0,0,0,0.0), 215.23088993871895, 181.72910151635918], [Date.UTC(2016,1,26,0,0,0,0.0), 215.43692780366598, 181.90306853422464], [Date.UTC(2016,1,29,0,0,0,0.0), 214.7863002026716, 181.3537144457659], [Date.UTC(2016,2,1,0,0,0,0.0), 216.1309405060008, 182.4890546111867], [Date.UTC(2016,2,2,0,0,0,0.0), 217.23702893822963, 183.42297472387975], [Date.UTC(2016,2,3,0,0,0,0.0), 217.73584177766853, 183.8441447945971], [Date.UTC(2016,2,4,0,0,0,0.0), 217.77922687900895, 183.88077678310043], [Date.UTC(2016,2,7,0,0,0,0.0), 218.18044806028388, 184.2195458362005], [Date.UTC(2016,2,8,0,0,0,0.0), 216.9876225185102, 183.21238968852106], [Date.UTC(2016,2,9,0,0,0,0.0), 217.76838887695786, 183.87162577147964], [Date.UTC(2016,2,10,0,0,0,0.0), 217.3671511491149, 183.53284274736947], [Date.UTC(2016,2,11,0,0,0,0.0), 219.06966062551462, 184.97034791940726], [Date.UTC(2016,2,14,0,0,0,0.0), 219.9046335407858, 185.67535303147983], [Date.UTC(2016,2,15,0,0,0,0.0), 219.29737449456383, 185.1626169605143], [Date.UTC(2016,2,16,0,0,0,0.0), 219.57932801357262, 185.4006829727555], [Date.UTC(2016,2,17,0,0,0,0.0), 220.52274713562687, 186.19725408507625], [Date.UTC(2016,2,18,0,0,0,0.0), 220.43599347951402, 186.12400407907973], [Date.UTC(2016,2,21,0,0,0,0.0), 221.35773659746604, 186.90227316815896], [Date.UTC(2016,2,22,0,0,0,0.0), 220.81553865668673, 186.44447110893827], [Date.UTC(2016,2,23,0,0,0,0.0), 220.37093237407137, 186.06907006733488], [Date.UTC(2016,2,24,0,0,0,0.0), 220.0347722982391, 185.78523502597966], [Date.UTC(2016,2,28,0,0,0,0.0), 220.71793045195477, 186.36205612031085], [Date.UTC(2016,2,29,0,0,0,0.0), 221.1083136311786, 186.69167416179016], [Date.UTC(2016,2,30,0,0,0,0.0), 222.21440206340745, 187.62559427448318], [Date.UTC(2016,2,31,0,0,0,0.0), 221.75895777874098, 187.24104222125902], [Date.UTC(2016,3,1,0,0,0,0.0), 222.2577871647479, 187.66222626298648], [Date.UTC(2016,3,4,0,0,0,0.0), 222.83251565824852, 188.1474953280796], [Date.UTC(2016,3,5,0,0,0,0.0), 220.81553865668673, 186.44447110893827], [Date.UTC(2016,3,6,0,0,0,0.0), 222.17103350863505, 187.58897625698995], [Date.UTC(2016,3,7,0,0,0,0.0), 220.51190913357576, 186.1881030734555], [Date.UTC(2016,3,8,0,0,0,0.0), 220.95649886962312, 186.56349014404876], [Date.UTC(2016,3,11,0,0,0,0.0), 220.945660867572, 186.554339132428], [Date.UTC(2016,3,12,0,0,0,0.0), 221.53122736312375, 187.04875920914188], [Date.UTC(2016,3,13,0,0,0,0.0), 223.56989691535574, 188.77009942253488], [Date.UTC(2016,3,14,0,0,0,0.0), 224.42657892786517, 189.4934344998692], [Date.UTC(2016,3,15,0,0,0,0.0), 223.8735264384667, 189.02646745801766], [Date.UTC(2016,3,18,0,0,0,0.0), 225.08806107747864, 190.05195357095886], [Date.UTC(2016,3,19,0,0,0,0.0), 225.5543433641962, 190.4456566358038], [Date.UTC(2016,3,20,0,0,0,0.0), 226.0640107522542, 190.87599168915204], [Date.UTC(2016,3,21,0,0,0,0.0), 224.93622976935515, 189.92375558220735], [Date.UTC(2016,3,22,0,0,0,0.0), 224.5024780353589, 189.55751952323484], [Date.UTC(2016,3,25,0,0,0,0.0), 224.91455376525295, 189.9054535589658], [Date.UTC(2016,3,26,0,0,0,0.0), 224.96877686864448, 189.9512365590899], [Date.UTC(2016,3,27,0,0,0,0.0), 225.31577494652788, 190.24422261206587], [Date.UTC(2016,3,28,0,0,0,0.0), 223.27710539429586, 188.5228823986729], [Date.UTC(2016,3,29,0,0,0,0.0), 221.87824198757517, 187.34175923312796], [Date.UTC(2016,4,2,0,0,0,0.0), 224.27476416630967, 189.36525048212783], [Date.UTC(2016,4,3,0,0,0,0.0), 221.9758336457391, 187.42416025074527], [Date.UTC(2016,4,4,0,0,0,0.0), 221.31435149612562, 186.86564117965563], [Date.UTC(2016,4,5,0,0,0,0.0), 221.8131808821325, 187.2868252213831], [Date.UTC(2016,4,6,0,0,0,0.0), 221.75895777874098, 187.24104222125902], [Date.UTC(2016,4,9,0,0,0,0.0), 222.36621682496295, 187.75377829222455], [Date.UTC(2016,4,10,0,0,0,0.0), 224.33982527175232, 189.42018449387268], [Date.UTC(2016,4,11,0,0,0,0.0), 222.82166110962942, 188.1383303454487], [Date.UTC(2016,4,12,0,0,0,0.0), 222.52888613513755, 187.89112729259682], [Date.UTC(2016,4,13,0,0,0,0.0), 221.19506728729147, 186.76492416778666], [Date.UTC(2016,4,16,0,0,0,0.0), 222.82166110962942, 188.1383303454487], [Date.UTC(2016,4,17,0,0,0,0.0), 221.0649450764062, 186.65505614429694], [Date.UTC(2016,4,18,0,0,0,0.0), 220.85890721145915, 186.48108912643147], [Date.UTC(2016,4,19,0,0,0,0.0), 220.34923982340115, 186.05075407308323], [Date.UTC(2016,4,20,0,0,0,0.0), 221.43363570495978, 186.9663581915246], [Date.UTC(2016,4,23,0,0,0,0.0), 222.17103350863505, 187.58897625698995], [Date.UTC(2016,4,24,0,0,0,0.0), 223.4831432592429, 188.69684941653836], [Date.UTC(2016,4,25,0,0,0,0.0), 225.15312218292127, 190.10688758270373], [Date.UTC(2016,4,26,0,0,0,0.0), 225.8688108893583, 190.71117568290734], [Date.UTC(2016,4,27,0,0,0,0.0), 226.5411475875909, 191.27885973662785], [Date.UTC(2016,4,31,0,0,0,0.0), 225.1964907376937, 190.14350560019693], [Date.UTC(2016,5,1,0,0,0,0.0), 226.33510972264386, 191.1048927187624], [Date.UTC(2016,5,2,0,0,0,0.0), 227.12671408314264, 191.77327981334173], [Date.UTC(2016,5,3,0,0,0,0.0), 225.65193502236016, 190.5280576534211], [Date.UTC(2016,5,6,0,0,0,0.0), 227.5821583678091, 192.1578318665659], [Date.UTC(2016,5,7,0,0,0,0.0), 228.11351830653732, 192.6064829141658], [Date.UTC(2016,5,8,0,0,0,0.0), 228.6014931439251, 193.0185019732624], [Date.UTC(2016,5,9,0,0,0,0.0), 228.02676465042447, 192.53323290816928], [Date.UTC(2016,5,10,0,0,0,0.0), 225.33746749719808, 190.26253860631755], [Date.UTC(2016,5,13,0,0,0,0.0), 223.93858754390936, 189.0814014697625], [Date.UTC(2016,5,14,0,0,0,0.0), 223.3096359470172, 188.5503494045453], [Date.UTC(2016,5,15,0,0,0,0.0), 223.35302104835762, 188.58698139304863], [Date.UTC(2016,5,16,0,0,0,0.0), 223.3096359470172, 188.5503494045453], [Date.UTC(2016,5,17,0,0,0,0.0), 222.14934095796482, 187.5706602627383], [Date.UTC(2016,5,20,0,0,0,0.0), 223.90605699118805, 189.05393446389007], [Date.UTC(2016,5,21,0,0,0,0.0), 224.5241705860291, 189.57583551748652], [Date.UTC(2016,5,22,0,0,0,0.0), 223.797627330973, 188.962382434652], [Date.UTC(2016,5,23,0,0,0,0.0), 226.19413296313948, 190.98585971264177], [Date.UTC(2016,5,24,0,0,0,0.0), 222.6481703439717, 187.9918443044658], [Date.UTC(2016,5,27,0,0,0,0.0), 218.40817847590114, 184.4118288483176], [Date.UTC(2016,5,28,0,0,0,0.0), 219.46004380473843, 185.29996596088657], [Date.UTC(2016,5,29,0,0,0,0.0), 221.9758336457391, 187.42416025074527], [Date.UTC(2016,5,30,0,0,0,0.0), 224.12293285818618, 189.23705249337632], [Date.UTC(2016,6,1,0,0,0,0.0), 225.31577494652788, 190.24422261206587], [Date.UTC(2016,6,5,0,0,0,0.0), 223.8084653330241, 188.9715334462728], [Date.UTC(2016,6,6,0,0,0,0.0), 225.0338379740871, 190.00617057083477], [Date.UTC(2016,6,7,0,0,0,0.0), 225.32661294857897, 190.25337362368666], [Date.UTC(2016,6,8,0,0,0,0.0), 227.48456670964515, 192.0754308489486], [Date.UTC(2016,6,11,0,0,0,0.0), 229.40395205304299, 193.69605405047264], [Date.UTC(2016,6,12,0,0,0,0.0), 230.44496283326117, 194.5750261804107], [Date.UTC(2016,6,13,0,0,0,0.0), 230.68353125092952, 194.7764602041486], [Date.UTC(2016,6,14,0,0,0,0.0), 231.83298823793078, 195.74699833433485], [Date.UTC(2016,6,15,0,0,0,0.0), 231.3775439532643, 195.3624462811107], [Date.UTC(2016,6,18,0,0,0,0.0), 232.8631775626659, 196.61683342366223], [Date.UTC(2016,6,19,0,0,0,0.0), 232.81979246132548, 196.5802014351589], [Date.UTC(2016,6,20,0,0,0,0.0), 233.50296716160918, 197.1570365005002], [Date.UTC(2016,6,21,0,0,0,0.0), 232.5053249361634, 196.31468238805536], [Date.UTC(2016,6,22,0,0,0,0.0), 233.61139682182423, 197.24858852973827], [Date.UTC(2016,6,25,0,0,0,0.0), 233.12342198443645, 196.83656947064168], [Date.UTC(2016,6,26,0,0,0,0.0), 232.8957081153872, 196.64430042953467], [Date.UTC(2016,6,27,0,0,0,0.0), 232.41857128005054, 196.24143238205883], [Date.UTC(2016,6,28,0,0,0,0.0), 233.02583032627248, 196.7541684530244], [Date.UTC(2016,6,29,0,0,0,0.0), 233.0583608789938, 196.78163545889683], [Date.UTC(2016,7,1,0,0,0,0.0), 233.09089143171514, 196.80910246476924], [Date.UTC(2016,7,2,0,0,0,0.0), 231.23658374032794, 195.24342724600018], [Date.UTC(2016,7,3,0,0,0,0.0), 232.7330388052126, 196.5069514291624], [Date.UTC(2016,7,4,0,0,0,0.0), 233.11258398238533, 196.82741845902092], [Date.UTC(2016,7,5,0,0,0,0.0), 234.28373352005684, 197.81627258345878], [Date.UTC(2016,7,8,0,0,0,0.0), 234.98858422444275, 198.41140967204163], [Date.UTC(2016,7,9,0,0,0,0.0), 234.80423891016594, 198.25575864842781], [Date.UTC(2016,7,10,0,0,0,0.0), 234.14275676055246, 197.69723957733817], [Date.UTC(2016,7,11,0,0,0,0.0), 234.84762401150635, 198.29239063693115], [Date.UTC(2016,7,12,0,0,0,0.0), 235.02111477716406, 198.43887667791407], [Date.UTC(2016,7,15,0,0,0,0.0), 235.7801885849415, 199.079796766621], [Date.UTC(2016,7,16,0,0,0,0.0), 234.5765250411167, 198.0634896073208], [Date.UTC(2016,7,17,0,0,0,0.0), 234.46807883433365, 197.9719236070726], [Date.UTC(2016,7,18,0,0,0,0.0), 235.45488305772832, 198.80512670789668], [Date.UTC(2016,7,19,0,0,0,0.0), 234.64158614655935, 198.11842361906565], [Date.UTC(2016,7,22,0,0,0,0.0), 234.9235231190001, 198.35647566029678], [Date.UTC(2016,7,23,0,0,0,0.0), 235.5958432706647, 198.9241457430072], [Date.UTC(2016,7,24,0,0,0,0.0), 234.0776956551098, 197.64230556559332], [Date.UTC(2016,7,25,0,0,0,0.0), 233.91504289150322, 197.50497053623116], [Date.UTC(2016,7,26,0,0,0,0.0), 232.44026383072077, 196.25974837631048], [Date.UTC(2016,7,29,0,0,0,0.0), 234.53313993977628, 198.02685761881747], [Date.UTC(2016,7,30,0,0,0,0.0), 234.52230193772516, 198.01770660719671], [Date.UTC(2016,7,31,0,0,0,0.0), 233.25356074188974, 196.9464514651415], [Date.UTC(2016,8,1,0,0,0,0.0), 233.02583032627248, 196.7541684530244], [Date.UTC(2016,8,2,0,0,0,0.0), 234.38132517822078, 197.8986736010761], [Date.UTC(2016,8,6,0,0,0,0.0), 235.6175358213349, 198.94246173725884], [Date.UTC(2016,8,7,0,0,0,0.0), 235.09703043122582, 198.5029756722898], [Date.UTC(2016,8,8,0,0,0,0.0), 234.64158614655935, 198.11842361906565], [Date.UTC(2016,8,9,0,0,0,0.0), 227.67976657254107, 192.2402468551933], [Date.UTC(2016,8,12,0,0,0,0.0), 230.36906372576743, 194.51094115704507], [Date.UTC(2016,8,13,0,0,0,0.0), 227.52795181098557, 192.11206283745193], [Date.UTC(2016,8,14,0,0,0,0.0), 228.04845720109466, 192.55154890242096], [Date.UTC(2016,8,15,0,0,0,0.0), 229.9569879958734, 194.1630071213141], [Date.UTC(2016,8,16,0,0,0,0.0), 227.9291729922605, 192.450831890552], [Date.UTC(2016,8,19,0,0,0,0.0), 229.2955058462599, 193.60448805022446], [Date.UTC(2016,8,20,0,0,0,0.0), 229.58829736731977, 193.85170507408648], [Date.UTC(2016,8,21,0,0,0,0.0), 231.0088533247107, 195.05114423388304], [Date.UTC(2016,8,22,0,0,0,0.0), 233.18848308987907, 196.89150348238655], [Date.UTC(2016,8,23,0,0,0,0.0), 232.12577975899066, 195.99421535819684], [Date.UTC(2016,8,26,0,0,0,0.0), 229.9569879958734, 194.1630071213141], [Date.UTC(2016,8,27,0,0,0,0.0), 231.5076827107176, 195.47232827561052], [Date.UTC(2016,8,28,0,0,0,0.0), 232.3751861787101, 196.20480039355553], [Date.UTC(2016,8,29,0,0,0,0.0), 229.75095013092636, 193.98904010344864], [Date.UTC(2016,8,30,0,0,0,0.0), 231.63780492160288, 195.58219629910025], [Date.UTC(2016,9,3,0,0,0,0.0), 231.59443636683045, 195.54557828160705], [Date.UTC(2016,9,4,0,0,0,0.0), 229.8051732343179, 194.03482310357273], [Date.UTC(2016,9,5,0,0,0,0.0), 231.6920280249944, 195.62797929922434], [Date.UTC(2016,9,6,0,0,0,0.0), 232.04988065149692, 195.9301303348312], [Date.UTC(2016,9,7,0,0,0,0.0), 230.74859235637214, 194.83139421589348], [Date.UTC(2016,9,10,0,0,0,0.0), 232.74389335383174, 196.51611641179326], [Date.UTC(2016,9,11,0,0,0,0.0), 228.4279858316994, 192.87200196126935], [Date.UTC(2016,9,12,0,0,0,0.0), 229.69674357410284, 193.94327107433466], [Date.UTC(2016,9,13,0,0,0,0.0), 228.37377927487586, 192.8262329321554], [Date.UTC(2016,9,14,0,0,0,0.0), 228.8075310088721, 193.1924689911279], [Date.UTC(2016,9,17,0,0,0,0.0), 228.8075310088721, 193.1924689911279], [Date.UTC(2016,9,18,0,0,0,0.0), 229.67505102343262, 193.924955080083], [Date.UTC(2016,9,19,0,0,0,0.0), 230.45581738188028, 194.5841911630416], [Date.UTC(2016,9,20,0,0,0,0.0), 229.88108888837965, 194.09892209794847], [Date.UTC(2016,9,21,0,0,0,0.0), 229.6425204707113, 193.89748807421057], [Date.UTC(2016,9,24,0,0,0,0.0), 231.25825974443015, 195.26172926924173], [Date.UTC(2016,9,25,0,0,0,0.0), 230.42328682915897, 194.55672415716916], [Date.UTC(2016,9,26,0,0,0,0.0), 229.6641964748135, 193.91579009745212], [Date.UTC(2016,9,27,0,0,0,0.0), 229.15454563332352, 193.48546901511398], [Date.UTC(2016,9,28,0,0,0,0.0), 227.33275194808965, 191.94724683120722], [Date.UTC(2016,9,31,0,0,0,0.0), 228.90512266703607, 193.27487000874518], [Date.UTC(2016,10,1,0,0,0,0.0), 226.15076440836705, 190.94924169514857], [Date.UTC(2016,10,2,0,0,0,0.0), 225.16396018497238, 190.1160385943245], [Date.UTC(2016,10,3,0,0,0,0.0), 224.53500858808022, 189.58498652910728], [Date.UTC(2016,10,4,0,0,0,0.0), 224.0253412000222, 189.15465147575904], [Date.UTC(2016,10,7,0,0,0,0.0), 228.2761710701439, 192.74381794352797], [Date.UTC(2016,10,8,0,0,0,0.0), 229.41479005509407, 193.70520506209343], [Date.UTC(2016,10,9,0,0,0,0.0), 229.92445744315208, 194.13554011544167], [Date.UTC(2016,10,10,0,0,0,0.0), 231.07391443015334, 195.1060782456279], [Date.UTC(2016,10,11,0,0,0,0.0), 232.0064955501565, 195.89349834632787], [Date.UTC(2016,10,14,0,0,0,0.0), 232.25590196987594, 196.10408338168656], [Date.UTC(2016,10,15,0,0,0,0.0), 234.05600310443958, 197.62398957134167], [Date.UTC(2016,10,16,0,0,0,0.0), 234.14275676055246, 197.69723957733817], [Date.UTC(2016,10,17,0,0,0,0.0), 235.20546009144087, 198.59452770152788], [Date.UTC(2016,10,18,0,0,0,0.0), 234.4355482816123, 197.9444566012002], [Date.UTC(2016,10,21,0,0,0,0.0), 236.36577162706124, 199.57423081434501], [Date.UTC(2016,10,22,0,0,0,0.0), 236.9405001205619, 200.0594998794381], [Date.UTC(2016,10,23,0,0,0,0.0), 237.27666019639418, 200.34333492079332], [Date.UTC(2016,10,25,0,0,0,0.0), 238.5128708395083, 201.38712305697607], [Date.UTC(2016,10,28,0,0,0,0.0), 236.7778473569553, 199.92216485007594], [Date.UTC(2016,10,29,0,0,0,0.0), 237.24412964367286, 200.3158679149209], [Date.UTC(2016,10,30,0,0,0,0.0), 236.0946726566716, 199.34532978473464], [Date.UTC(2016,11,1,0,0,0,0.0), 235.69345147539667, 199.00656073163458], [Date.UTC(2016,11,2,0,0,0,0.0), 235.89947279377566, 199.18051377848997], [Date.UTC(2016,11,5,0,0,0,0.0), 237.37425185455814, 200.4257359384106], [Date.UTC(2016,11,6,0,0,0,0.0), 238.25262641773776, 201.16738700999662], [Date.UTC(2016,11,7,0,0,0,0.0), 240.18284976318668, 202.79716122314144], [Date.UTC(2016,11,8,0,0,0,0.0), 241.18049198863247, 203.63951533558628], [Date.UTC(2016,11,9,0,0,0,0.0), 242.7745552582491, 204.9854545073759], [Date.UTC(2016,11,12,0,0,0,0.0), 242.4167026317466, 204.68330347176902], [Date.UTC(2016,11,13,0,0,0,0.0), 243.66375127691182, 205.73624261957255], [Date.UTC(2016,11,14,0,0,0,0.0), 241.0503532311792, 203.52963334108642], [Date.UTC(2016,11,15,0,0,0,0.0), 242.35164152630398, 204.62836946002415], [Date.UTC(2016,11,16,0,0,0,0.0), 239.9985044489099, 202.6415101995276], [Date.UTC(2016,11,19,0,0,0,0.0), 241.67930482807137, 204.06068540630363], [Date.UTC(2016,11,20,0,0,0,0.0), 242.6010479460234, 204.83895449538284], [Date.UTC(2016,11,21,0,0,0,0.0), 242.50345628785945, 204.75655347776555], [Date.UTC(2016,11,22,0,0,0,0.0), 242.2323573174698, 204.5276524481552], [Date.UTC(2016,11,23,0,0,0,0.0), 242.88298491846416, 205.07700653661396], [Date.UTC(2016,11,27,0,0,0,0.0), 243.38181430447105, 205.49819057834145], [Date.UTC(2016,11,28,0,0,0,0.0), 241.14796143591116, 203.61204832971384], [Date.UTC(2016,11,29,0,0,0,0.0), 241.2563910961262, 203.70360035895192], [Date.UTC(2016,11,30,0,0,0,0.0), 239.32616775067729, 202.0738261458071], [Date.UTC(2017,0,3,0,0,0,0.0), 241.28892164884752, 203.73106736482436], [Date.UTC(2017,0,4,0,0,0,0.0), 242.94804602390678, 205.13194054835884], [Date.UTC(2017,0,5,0,0,0,0.0), 242.7745552582491, 204.9854545073759], [Date.UTC(2017,0,6,0,0,0,0.0), 243.7613429350758, 205.81864363718984], [Date.UTC(2017,0,9,0,0,0,0.0), 243.50109851330524, 205.5989075902104], [Date.UTC(2017,0,10,0,0,0,0.0), 243.19746899019427, 205.3425395547276], [Date.UTC(2017,0,11,0,0,0,0.0), 243.59869017146917, 205.6813086078277], [Date.UTC(2017,0,12,0,0,0,0.0), 243.03479968001966, 205.20519055435534], [Date.UTC(2017,0,13,0,0,0,0.0), 243.78303548574598, 205.83695963144152], [Date.UTC(2017,0,17,0,0,0,0.0), 243.00226912729835, 205.1777235484829], [Date.UTC(2017,0,18,0,0,0,0.0), 243.66375127691182, 205.73624261957255], [Date.UTC(2017,0,19,0,0,0,0.0), 242.55766284468297, 204.80232250687953], [Date.UTC(2017,0,20,0,0,0,0.0), 242.34078697768484, 204.61920447739328], [Date.UTC(2017,0,23,0,0,0,0.0), 242.6444165007958, 204.87557251287606], [Date.UTC(2017,0,24,0,0,0,0.0), 243.75050493302467, 205.80949262556908], [Date.UTC(2017,0,25,0,0,0,0.0), 245.9952123502037, 207.70479985682755], [Date.UTC(2017,0,26,0,0,0,0.0), 246.25545677197425, 207.924535903807], [Date.UTC(2017,0,27,0,0,0,0.0), 245.93013469819306, 207.64985187407257], [Date.UTC(2017,0,30,0,0,0,0.0), 244.05413445613564, 206.06586066105186], [Date.UTC(2017,0,31,0,0,0,0.0), 244.05413445613564, 206.06586066105186], [Date.UTC(2017,1,1,0,0,0,0.0), 244.1300501101974, 206.1299596554276], [Date.UTC(2017,1,2,0,0,0,0.0), 244.40114908058706, 206.35886068503794], [Date.UTC(2017,1,3,0,0,0,0.0), 245.8325430400291, 207.56745085645528], [Date.UTC(2017,1,6,0,0,0,0.0), 245.8759281413695, 207.6040828449586], [Date.UTC(2017,1,7,0,0,0,0.0), 245.94098924681217, 207.65901685670346], [Date.UTC(2017,1,8,0,0,0,0.0), 246.28798732469556, 207.95200290967944], [Date.UTC(2017,1,9,0,0,0,0.0), 247.42660630964573, 208.9133900282449], [Date.UTC(2017,1,10,0,0,0,0.0), 248.4134105330404, 209.74659312906897], [Date.UTC(2017,1,13,0,0,0,0.0), 249.9207201465442, 211.01928229486205], [Date.UTC(2017,1,14,0,0,0,0.0), 250.6038948468279, 211.59611736020335], [Date.UTC(2017,1,15,0,0,0,0.0), 251.634067624995, 212.46593847852063], [Date.UTC(2017,1,16,0,0,0,0.0), 251.4713983148204, 212.32858947814836], [Date.UTC(2017,1,17,0,0,0,0.0), 252.02445080421882, 212.79555651999993], [Date.UTC(2017,1,21,0,0,0,0.0), 253.39078365821823, 213.9492126796724], [Date.UTC(2017,1,22,0,0,0,0.0), 253.51006786705238, 214.04992969154137], [Date.UTC(2017,1,23,0,0,0,0.0), 253.4992298650013, 214.04077867992058], [Date.UTC(2017,1,24,0,0,0,0.0), 253.62935207588657, 214.1506467034103], [Date.UTC(2017,1,27,0,0,0,0.0), 254.50771009249817, 214.8922838039862], [Date.UTC(2017,1,28,0,0,0,0.0), 253.46669931227999, 214.01331167404814], [Date.UTC(2017,2,1,0,0,0,0.0), 255.83067439172515, 216.00932194616547], [Date.UTC(2017,2,2,0,0,0,0.0), 255.51620686656307, 215.74380289906193], [Date.UTC(2017,2,3,0,0,0,0.0), 255.62463652677815, 215.83535492829998], [Date.UTC(2017,2,6,0,0,0,0.0), 255.11496913872014, 215.40501987495173], [Date.UTC(2017,2,7,0,0,0,0.0), 254.32336477822136, 214.7366327803724], [Date.UTC(2017,2,8,0,0,0,0.0), 253.6944131813292, 214.20558071515518], [Date.UTC(2017,2,9,0,0,0,0.0), 253.62935207588657, 214.1506467034103], [Date.UTC(2017,2,10,0,0,0,0.0), 254.7137479574452, 215.06625082185167], [Date.UTC(2017,2,13,0,0,0,0.0), 255.2451078961734, 215.5149018694516], [Date.UTC(2017,2,14,0,0,0,0.0), 254.22577312005743, 214.65423176275507], [Date.UTC(2017,2,15,0,0,0,0.0), 255.76561328628253, 215.9543879344206], [Date.UTC(2017,2,16,0,0,0,0.0), 255.58126797200572, 215.79873691080678], [Date.UTC(2017,2,17,0,0,0,0.0), 254.04142780578061, 214.49858073914126], [Date.UTC(2017,2,20,0,0,0,0.0), 254.2040805693872, 214.63591576850342], [Date.UTC(2017,2,21,0,0,0,0.0), 249.68215172887585, 210.81784827112415], [Date.UTC(2017,2,22,0,0,0,0.0), 250.7773856124856, 211.74260340118627], [Date.UTC(2017,2,23,0,0,0,0.0), 250.4303875346022, 211.4496173482103], [Date.UTC(2017,2,24,0,0,0,0.0), 250.04000435537836, 211.11999930673102], [Date.UTC(2017,2,27,0,0,0,0.0), 250.12675801149123, 211.19324931272752], [Date.UTC(2017,2,28,0,0,0,0.0), 251.91600459743574, 212.70399051975176], [Date.UTC(2017,2,29,0,0,0,0.0), 252.82689316676868, 213.47309462620007], [Date.UTC(2017,2,30,0,0,0,0.0), 253.57512897249504, 214.1048637032862], [Date.UTC(2017,2,31,0,0,0,0.0), 252.8485857174389, 213.49141062045172], [Date.UTC(2017,3,3,0,0,0,0.0), 252.08951190966147, 212.85049053174478], [Date.UTC(2017,3,4,0,0,0,0.0), 252.78352461199628, 213.43647660870684], [Date.UTC(2017,3,5,0,0,0,0.0), 251.1569307896583, 212.06307043104482], [Date.UTC(2017,3,6,0,0,0,0.0), 252.51242564160663, 213.2075755790965], [Date.UTC(2017,3,7,0,0,0,0.0), 252.21963412054674, 212.9603585552345], [Date.UTC(2017,3,10,0,0,0,0.0), 252.4690570868342, 213.1709575616033], [Date.UTC(2017,3,11,0,0,0,0.0), 251.69912873043762, 212.5208724902655], [Date.UTC(2017,3,12,0,0,0,0.0), 250.87499381721756, 211.8250183898137], [Date.UTC(2017,3,13,0,0,0,0.0), 249.17248434081785, 210.3875132177759], [Date.UTC(2017,3,17,0,0,0,0.0), 251.57984452160346, 212.42015547839654], [Date.UTC(2017,3,18,0,0,0,0.0), 250.58220229615767, 211.5778013659517], [Date.UTC(2017,3,19,0,0,0,0.0), 250.46291808732352, 211.47708435408273], [Date.UTC(2017,3,20,0,0,0,0.0), 251.91600459743574, 212.70399051975176], [Date.UTC(2017,3,21,0,0,0,0.0), 250.96173092676239, 211.89825442480011], [Date.UTC(2017,3,24,0,0,0,0.0), 253.28235399800317, 213.85766065043433], [Date.UTC(2017,3,25,0,0,0,0.0), 255.66802162811857, 215.8719869168033], [Date.UTC(2017,3,26,0,0,0,0.0), 255.3643921050076, 215.61561888132053], [Date.UTC(2017,3,27,0,0,0,0.0), 256.0692428093935, 216.21075596990337], [Date.UTC(2017,3,28,0,0,0,0.0), 255.5595754213355, 215.78042091655513], [Date.UTC(2017,4,1,0,0,0,0.0), 256.18852701822766, 216.31147298177234], [Date.UTC(2017,4,2,0,0,0,0.0), 256.21021956889786, 216.329788976024], [Date.UTC(2017,4,3,0,0,0,0.0), 255.711390182891, 215.9086049342965], [Date.UTC(2017,4,4,0,0,0,0.0), 256.0909353600637, 216.22907196415503], [Date.UTC(2017,4,5,0,0,0,0.0), 257.11027013617974, 217.08974207085154], [Date.UTC(2017,4,8,0,0,0,0.0), 257.2837609018374, 217.23622811183446], [Date.UTC(2017,4,9,0,0,0,0.0), 257.02351648006686, 217.01649206485502], [Date.UTC(2017,4,10,0,0,0,0.0), 257.4030451106716, 217.33694512370343], [Date.UTC(2017,4,11,0,0,0,0.0), 256.7415629610581, 216.77842605261378], [Date.UTC(2017,4,12,0,0,0,0.0), 256.5029945433897, 216.57699202887588], [Date.UTC(2017,4,15,0,0,0,0.0), 257.67414408106123, 217.56584615331377], [Date.UTC(2017,4,16,0,0,0,0.0), 257.68499862968036, 217.57501113594464], [Date.UTC(2017,4,17,0,0,0,0.0), 265.04803938497355, 223.79195695291708], [Date.UTC(2017,4,18,0,0,0,0.0), 253.08715413510726, 213.69284464418962], [Date.UTC(2017,4,19,0,0,0,0.0), 254.5402406452195, 214.9197508098586], [Date.UTC(2017,4,22,0,0,0,0.0), 257.034354482118, 217.02564307647577], [Date.UTC(2017,4,23,0,0,0,0.0), 257.68499862968036, 217.57501113594464], [Date.UTC(2017,4,24,0,0,0,0.0), 258.24887257456186, 218.0511152184069], [Date.UTC(2017,4,25,0,0,0,0.0), 259.19230824318413, 218.84770030173775], [Date.UTC(2017,4,26,0,0,0,0.0), 259.4742452156249, 219.08575234296885], [Date.UTC(2017,4,30,0,0,0,0.0), 259.44171466290356, 219.05828533709644], [Date.UTC(2017,4,31,0,0,0,0.0), 258.48744099223023, 218.2525492421448], [Date.UTC(2017,5,1,0,0,0,0.0), 260.7646789621306, 220.1753234792757], [Date.UTC(2017,5,2,0,0,0,0.0), 261.3285694535801, 220.65144153274804], [Date.UTC(2017,5,5,0,0,0,0.0), 261.935828499802, 221.1641776037136], [Date.UTC(2017,5,6,0,0,0,0.0), 261.01408538185, 220.3859085146344], [Date.UTC(2017,5,7,0,0,0,0.0), 261.41532310969296, 220.72469153874457], [Date.UTC(2017,5,8,0,0,0,0.0), 261.3394074556312, 220.66059254436882], [Date.UTC(2017,5,9,0,0,0,0.0), 259.73450618396345, 219.30550236095843], [Date.UTC(2017,5,12,0,0,0,0.0), 260.504417993792, 219.95557346128612], [Date.UTC(2017,5,13,0,0,0,0.0), 262.2069274701917, 221.39307863332394], [Date.UTC(2017,5,14,0,0,0,0.0), 261.61050642602083, 220.88949357397917], [Date.UTC(2017,5,15,0,0,0,0.0), 261.2743463501886, 220.60565853262395], [Date.UTC(2017,5,16,0,0,0,0.0), 259.8429358441785, 219.3970543901965], [Date.UTC(2017,5,19,0,0,0,0.0), 262.25029602496414, 221.42969665081714], [Date.UTC(2017,5,20,0,0,0,0.0), 260.7321484094092, 220.14785647340327], [Date.UTC(2017,5,21,0,0,0,0.0), 260.63455675124527, 220.06545545578598], [Date.UTC(2017,5,22,0,0,0,0.0), 260.7321484094092, 220.14785647340327], [Date.UTC(2017,5,23,0,0,0,0.0), 260.6128642005751, 220.0471394615343], [Date.UTC(2017,5,26,0,0,0,0.0), 261.01408538185, 220.3859085146344], [Date.UTC(2017,5,27,0,0,0,0.0), 258.54166409562174, 218.29833224226888], [Date.UTC(2017,5,28,0,0,0,0.0), 260.90565572163496, 220.29435648539632], [Date.UTC(2017,5,29,0,0,0,0.0), 258.1079123616255, 217.93209618329638], [Date.UTC(2017,5,30,0,0,0,0.0), 258.88867872007313, 218.59133226625497], [Date.UTC(2017,6,3,0,0,0,0.0), 260.1574199159086, 219.66258740831015], [Date.UTC(2017,6,5,0,0,0,0.0), 260.4393568883494, 219.90063944954127], [Date.UTC(2017,6,6,0,0,0,0.0), 257.9669356021211, 217.81306317717576], [Date.UTC(2017,6,7,0,0,0,0.0), 259.6585905299017, 219.2414033665827], [Date.UTC(2017,6,10,0,0,0,0.0), 260.3309272281343, 219.8090874203032], [Date.UTC(2017,6,11,0,0,0,0.0), 259.88632094551895, 219.4336863786998], [Date.UTC(2017,6,12,0,0,0,0.0), 261.64303697874215, 220.91696057985158], [Date.UTC(2017,6,13,0,0,0,0.0), 262.45633388991115, 221.6036636686826], [Date.UTC(2017,6,14,0,0,0,0.0), 263.2696308010801, 222.29036675751362], [Date.UTC(2017,6,17,0,0,0,0.0), 263.7792981891381, 222.7207018108619], [Date.UTC(2017,6,18,0,0,0,0.0), 263.6925445330253, 222.64745180486537], [Date.UTC(2017,6,19,0,0,0,0.0), 264.9396097247585, 223.700404923679], [Date.UTC(2017,6,20,0,0,0,0.0), 265.17816159585885, 223.9018249764068], [Date.UTC(2017,6,21,0,0,0,0.0), 264.2672730265259, 223.13272086995846], [Date.UTC(2017,6,24,0,0,0,0.0), 264.87453207274785, 223.64545694092402], [Date.UTC(2017,6,25,0,0,0,0.0), 265.40589201147606, 224.09410798852394], [Date.UTC(2017,6,26,0,0,0,0.0), 265.52517622031024, 224.19482500039288], [Date.UTC(2017,6,27,0,0,0,0.0), 264.87453207274785, 223.64545694092402], [Date.UTC(2017,6,28,0,0,0,0.0), 264.92875517613936, 223.6912399410481], [Date.UTC(2017,6,31,0,0,0,0.0), 264.51667944624535, 223.34330590531715], [Date.UTC(2017,7,1,0,0,0,0.0), 265.25407724992056, 223.96592397078254], [Date.UTC(2017,7,2,0,0,0,0.0), 265.54686877098044, 224.21314099464453], [Date.UTC(2017,7,3,0,0,0,0.0), 265.1564855917566, 223.88352295316525], [Date.UTC(2017,7,4,0,0,0,0.0), 265.2649152519717, 223.97507498240333], [Date.UTC(2017,7,7,0,0,0,0.0), 266.21918892264506, 224.78081107735494], [Date.UTC(2017,7,8,0,0,0,0.0), 265.1131004904162, 223.84689096466192], [Date.UTC(2017,7,9,0,0,0,0.0), 265.0046708302011, 223.75533893542385], [Date.UTC(2017,7,10,0,0,0,0.0), 260.51527254241114, 219.964738443917], [Date.UTC(2017,7,11,0,0,0,0.0), 261.523752769908, 220.81624356798264], [Date.UTC(2017,7,14,0,0,0,0.0), 264.0937657143002, 222.98622085796544], [Date.UTC(2017,7,15,0,0,0,0.0), 264.4624728894218, 223.29753687620317], [Date.UTC(2017,7,16,0,0,0,0.0), 264.86369407069674, 223.63630592930326], [Date.UTC(2017,7,17,0,0,0,0.0), 259.28989990134806, 218.93010131935503], [Date.UTC(2017,7,18,0,0,0,0.0), 258.89951672212425, 218.60048327787575], [Date.UTC(2017,7,21,0,0,0,0.0), 260.4393568883494, 219.90063944954127], [Date.UTC(2017,7,22,0,0,0,0.0), 263.052754934082, 222.10724872802737], [Date.UTC(2017,7,23,0,0,0,0.0), 262.44549588786003, 221.59451265706184], [Date.UTC(2017,7,24,0,0,0,0.0), 261.8707673943594, 221.10924359196872], [Date.UTC(2017,7,25,0,0,0,0.0), 262.27198857563434, 221.4480126450688], [Date.UTC(2017,7,28,0,0,0,0.0), 262.6840643055284, 221.79594668079974], [Date.UTC(2017,7,29,0,0,0,0.0), 262.62984120213684, 221.75016368067566], [Date.UTC(2017,7,30,0,0,0,0.0), 263.7467676364168, 222.69323480498946], [Date.UTC(2017,7,31,0,0,0,0.0), 264.7661024125328, 223.55390491168595], [Date.UTC(2017,8,1,0,0,0,0.0), 265.7529066359275, 224.38710801251003], [Date.UTC(2017,8,5,0,0,0,0.0), 265.3625234567036, 224.05748997103072], [Date.UTC(2017,8,6,0,0,0,0.0), 264.75524786391367, 223.54473992905508], [Date.UTC(2017,8,7,0,0,0,0.0), 264.7444098618626, 223.5355889174343], [Date.UTC(2017,8,8,0,0,0,0.0), 264.35402668263873, 223.205970875955], [Date.UTC(2017,8,11,0,0,0,0.0), 266.9457321777012, 225.39426416018946], [Date.UTC(2017,8,12,0,0,0,0.0), 268.1060437133216, 226.37396727300657], [Date.UTC(2017,8,13,0,0,0,0.0), 268.1927973694344, 226.4472172790031], [Date.UTC(2017,8,14,0,0,0,0.0), 267.6722754327573, 226.00771724302396], [Date.UTC(2017,8,15,0,0,0,0.0), 266.6637952052604, 225.15621211895834], [Date.UTC(2017,8,18,0,0,0,0.0), 267.9650669538172, 226.25493426688595], [Date.UTC(2017,8,19,0,0,0,0.0), 268.21447337353663, 226.46551930224464], [Date.UTC(2017,8,20,0,0,0,0.0), 268.0735131606002, 226.34650026713413], [Date.UTC(2017,8,21,0,0,0,0.0), 267.60721432731464, 225.95278323127908], [Date.UTC(2017,8,22,0,0,0,0.0), 267.56384577254227, 225.9161652137859], [Date.UTC(2017,8,25,0,0,0,0.0), 266.9348941756501, 225.38511314856868], [Date.UTC(2017,8,26,0,0,0,0.0), 267.1626080446993, 225.57738218967572], [Date.UTC(2017,8,27,0,0,0,0.0), 267.6831299813764, 226.01688222565485], [Date.UTC(2017,8,28,0,0,0,0.0), 268.62654910343065, 226.8134533379756], [Date.UTC(2017,8,29,0,0,0,0.0), 268.8759555231501, 227.02403837333426], [Date.UTC(2017,9,2,0,0,0,0.0), 270.5242418961583, 228.41576054524796], [Date.UTC(2017,9,3,0,0,0,0.0), 270.99052418287584, 228.8094636100929], [Date.UTC(2017,9,4,0,0,0,0.0), 271.5435766722743, 229.27643065194448], [Date.UTC(2017,9,5,0,0,0,0.0), 272.8882169756034, 230.4117708173653], [Date.UTC(2017,9,6,0,0,0,0.0), 272.38940413616456, 229.99060074664794], [Date.UTC(2017,9,9,0,0,0,0.0), 272.7038716613266, 230.25611979375148], [Date.UTC(2017,9,10,0,0,0,0.0), 273.25692415072507, 230.72308683560306], [Date.UTC(2017,9,11,0,0,0,0.0), 273.6256147792787, 231.03438888283068], [Date.UTC(2017,9,12,0,0,0,0.0), 273.2135390493846, 230.68645484709972], [Date.UTC(2017,9,13,0,0,0,0.0), 273.43041491638274, 230.86957287658598], [Date.UTC(2017,9,16,0,0,0,0.0), 274.0485285112238, 231.3914739301824], [Date.UTC(2017,9,17,0,0,0,0.0), 274.3521580343348, 231.64784196566518], [Date.UTC(2017,9,18,0,0,0,0.0), 274.4931347938392, 231.7668749717858], [Date.UTC(2017,9,19,0,0,0,0.0), 274.12442761871756, 231.45555895354806], [Date.UTC(2017,9,20,0,0,0,0.0), 275.06786328733983, 232.25214403687892], [Date.UTC(2017,9,23,0,0,0,0.0), 274.5581958992818, 231.82180898353067], [Date.UTC(2017,9,24,0,0,0,0.0), 275.0028021818972, 232.19721002513404], [Date.UTC(2017,9,25,0,0,0,0.0), 272.9749706317163, 230.48502082336182], [Date.UTC(2017,9,26,0,0,0,0.0), 273.8967137496684, 231.26328991244102], [Date.UTC(2017,9,27,0,0,0,0.0), 275.7510214410555, 232.8289651312101], [Date.UTC(2017,9,30,0,0,0,0.0), 275.37149281045083, 232.5085120723617], [Date.UTC(2017,9,31,0,0,0,0.0), 275.7076528862831, 232.7923471137169], [Date.UTC(2017,10,1,0,0,0,0.0), 276.1847897216198, 233.19521516119272], [Date.UTC(2017,10,2,0,0,0,0.0), 276.1956277236709, 233.20436617281348], [Date.UTC(2017,10,3,0,0,0,0.0), 277.0306171855101, 233.90938525589615], [Date.UTC(2017,10,6,0,0,0,0.0), 277.6595522358342, 234.44042335010326], [Date.UTC(2017,10,7,0,0,0,0.0), 277.3667772613424, 234.19322029725137], [Date.UTC(2017,10,8,0,0,0,0.0), 277.9198297507408, 234.66018733910295], [Date.UTC(2017,10,9,0,0,0,0.0), 276.108874067558, 233.13111616681695], [Date.UTC(2017,10,10,0,0,0,0.0), 276.6619265569565, 233.59808320866853], [Date.UTC(2017,10,13,0,0,0,0.0), 277.0631477382314, 233.9368522617686], [Date.UTC(2017,10,14,0,0,0,0.0), 276.2606888291135, 233.25930018455836], [Date.UTC(2017,10,15,0,0,0,0.0), 274.5581958992818, 231.82180898353067], [Date.UTC(2017,10,16,0,0,0,0.0), 277.0631477382314, 233.9368522617686], [Date.UTC(2017,10,17,0,0,0,0.0), 276.1847897216198, 233.19521516119272], [Date.UTC(2017,10,20,0,0,0,0.0), 277.10651629300384, 233.9734702792618], [Date.UTC(2017,10,21,0,0,0,0.0), 278.50537969972453, 235.15459344480672], [Date.UTC(2017,10,22,0,0,0,0.0), 278.754802666012, 235.36519245117552], [Date.UTC(2017,10,24,0,0,0,0.0), 279.67654578396406, 236.14346154025472], [Date.UTC(2017,10,27,0,0,0,0.0), 279.13434784318474, 235.68565948103404], [Date.UTC(2017,10,28,0,0,0,0.0), 281.04289518453146, 237.2971316709373], [Date.UTC(2017,10,29,0,0,0,0.0), 281.37905526036377, 237.5809667122925], [Date.UTC(2017,10,30,0,0,0,0.0), 282.9731185299804, 238.92690588408212], [Date.UTC(2017,11,1,0,0,0,0.0), 281.81280699436, 237.947202771265], [Date.UTC(2017,11,4,0,0,0,0.0), 282.7128410150738, 238.70714189508243], [Date.UTC(2017,11,5,0,0,0,0.0), 281.9320746566261, 238.04790581212384], [Date.UTC(2017,11,6,0,0,0,0.0), 281.9320746566261, 238.04790581212384], [Date.UTC(2017,11,7,0,0,0,0.0), 282.77790212051644, 238.7620759068273], [Date.UTC(2017,11,8,0,0,0,0.0), 284.36114393465, 240.09887803800626], [Date.UTC(2017,11,11,0,0,0,0.0), 285.174440845819, 240.7855811268373], [Date.UTC(2017,11,12,0,0,0,0.0), 285.6190471284343, 241.16098216844065], [Date.UTC(2017,11,13,0,0,0,0.0), 285.30456305670424, 240.895449150327], [Date.UTC(2017,11,14,0,0,0,0.0), 284.2309886306287, 239.9889820724963], [Date.UTC(2017,11,15,0,0,0,0.0), 284.35028938603085, 240.08971305537537], [Date.UTC(2017,11,18,0,0,0,0.0), 287.2347864021532, 242.52522336347184], [Date.UTC(2017,11,19,0,0,0,0.0), 286.2263061746563, 241.6737182394062], [Date.UTC(2017,11,20,0,0,0,0.0), 286.0853294151519, 241.5546852332856], [Date.UTC(2017,11,21,0,0,0,0.0), 286.87691722908266, 242.22305835685486], [Date.UTC(2017,11,22,0,0,0,0.0), 286.50822660052904, 241.9117563096272], [Date.UTC(2017,11,26,0,0,0,0.0), 286.7576495668165, 242.122355315996], [Date.UTC(2017,11,27,0,0,0,0.0), 286.68173391275474, 242.05825632162026], [Date.UTC(2017,11,28,0,0,0,0.0), 287.5058853725428, 242.75412439308218], [Date.UTC(2017,11,29,0,0,0,0.0), 285.58648348257697, 241.133487220548], [Date.UTC(2018,0,2,0,0,0,0.0), 287.8962520051986, 243.08372846355135], [Date.UTC(2018,0,3,0,0,0,0.0), 289.49031527481526, 244.42966763534096], [Date.UTC(2018,0,4,0,0,0,0.0), 290.92172578082534, 245.6382717777684], [Date.UTC(2018,0,5,0,0,0,0.0), 292.84109457765516, 247.25888100828237], [Date.UTC(2018,0,8,0,0,0,0.0), 293.8278988010498, 248.09208410910642], [Date.UTC(2018,0,9,0,0,0,0.0), 294.55445860267395, 248.70555116295105], [Date.UTC(2018,0,10,0,0,0,0.0), 293.83875334966893, 248.10124909173732], [Date.UTC(2018,0,11,0,0,0,0.0), 296.10513677095014, 250.01485834623733], [Date.UTC(2018,0,12,0,0,0,0.0), 297.6558149392264, 251.32416552952364], [Date.UTC(2018,0,16,0,0,0,0.0), 296.56059760218466, 250.3994243704716], [Date.UTC(2018,0,17,0,0,0,0.0), 299.23905675335993, 252.6609676607026], [Date.UTC(2018,0,18,0,0,0,0.0), 299.01130979117465, 252.46867067757535], [Date.UTC(2018,0,19,0,0,0,0.0), 299.8029306982414, 253.13707174316482], [Date.UTC(2018,0,22,0,0,0,0.0), 303.1428554524622, 255.9571201334753], [Date.UTC(2018,0,23,0,0,0,0.0), 303.7826781445415, 256.4973511523335], [Date.UTC(2018,0,24,0,0,0,0.0), 303.1103248997409, 255.92965312760288], [Date.UTC(2018,0,25,0,0,0,0.0), 303.93447635952896, 256.6255211990648], [Date.UTC(2018,0,26,0,0,0,0.0), 307.2635796582666, 259.4364325487646], [Date.UTC(2018,0,29,0,0,0,0.0), 305.47433307232205, 257.92569134174045], [Date.UTC(2018,0,30,0,0,0,0.0), 301.6247078369073, 254.67527995606144], [Date.UTC(2018,0,31,0,0,0,0.0), 301.9933984654609, 254.9865820032891], [Date.UTC(2018,1,1,0,0,0,0.0), 301.90666135591607, 254.91334596830268], [Date.UTC(2018,1,2,0,0,0,0.0), 294.0664672187182, 248.29351813284433], [Date.UTC(2018,1,5,0,0,0,0.0), 280.32718993152645, 236.69282959972358], [Date.UTC(2018,1,6,0,0,0,0.0), 285.54313147437256, 241.0968831740649], [Date.UTC(2018,1,7,0,0,0,0.0), 285.4021547148682, 240.9778501679443], [Date.UTC(2018,1,8,0,0,0,0.0), 273.6906758847213, 231.08932289457556], [Date.UTC(2018,1,9,0,0,0,0.0), 277.3993078140637, 234.2206873031238], [Date.UTC(2018,1,12,0,0,0,0.0), 283.07071018814435, 239.0093069016994], [Date.UTC(2018,1,13,0,0,0,0.0), 284.7515105673058, 240.42848210847544], [Date.UTC(2018,1,14,0,0,0,0.0), 287.8637214524773, 243.05626145767891], [Date.UTC(2018,1,15,0,0,0,0.0), 291.9193845528391, 246.48063986122338], [Date.UTC(2018,1,16,0,0,0,0.0), 291.46392372160466, 246.0960738369891], [Date.UTC(2018,1,20,0,0,0,0.0), 290.6940119117761, 245.4460027366614], [Date.UTC(2018,1,21,0,0,0,0.0), 289.0890940935403, 244.0908985822409], [Date.UTC(2018,1,22,0,0,0,0.0), 289.21921630442563, 244.20076660573062], [Date.UTC(2018,1,23,0,0,0,0.0), 294.03393666599686, 248.26605112697192], [Date.UTC(2018,1,26,0,0,0,0.0), 297.6558149392264, 251.32416552952364], [Date.UTC(2018,1,27,0,0,0,0.0), 293.90381445511156, 248.1561831034822], [Date.UTC(2018,1,28,0,0,0,0.0), 290.5205045995504, 245.29950272466834], [Date.UTC(2018,2,1,0,0,0,0.0), 285.3479481580447, 240.9320811388303], [Date.UTC(2018,2,2,0,0,0,0.0), 287.115485646751, 242.42449238059277], [Date.UTC(2018,2,5,0,0,0,0.0), 291.09523309305104, 245.78477178976146], [Date.UTC(2018,2,6,0,0,0,0.0), 292.4398733963802, 246.92011195518228], [Date.UTC(2018,2,7,0,0,0,0.0), 291.98444565828174, 246.53557387296823], [Date.UTC(2018,2,8,0,0,0,0.0), 293.84960789828807, 248.11041407436818], [Date.UTC(2018,2,9,0,0,0,0.0), 298.31731363540786, 251.8826985716234], [Date.UTC(2018,2,12,0,0,0,0.0), 298.77274137350634, 252.26723665383744], [Date.UTC(2018,2,13,0,0,0,0.0), 296.5388885049464, 250.38109440520984], [Date.UTC(2018,2,14,0,0,0,0.0), 294.7062568176614, 248.83372120968232], [Date.UTC(2018,2,15,0,0,0,0.0), 294.6737262649401, 248.80625420380989], [Date.UTC(2018,2,19,0,0,0,0.0), 289.36019306393, 244.31979961185124], [Date.UTC(2018,2,20,0,0,0,0.0), 290.59642025361217, 245.3636017190441], [Date.UTC(2018,2,21,0,0,0,0.0), 289.75059278972185, 244.64943162434065], [Date.UTC(2018,2,22,0,0,0,0.0), 281.4224072685681, 237.6175707587756], [Date.UTC(2018,2,23,0,0,0,0.0), 274.75337921560975, 231.98661101876525], [Date.UTC(2018,2,26,0,0,0,0.0), 282.7236955636929, 238.71630687771332], [Date.UTC(2018,2,27,0,0,0,0.0), 278.38611203745836, 235.05389040394786], [Date.UTC(2018,2,28,0,0,0,0.0), 277.0956782909527, 233.96431926764103], [Date.UTC(2018,2,29,0,0,0,0.0), 280.9344489777484, 237.2055656706891], [Date.UTC(2018,3,2,0,0,0,0.0), 274.0159979585025, 231.36400692431], [Date.UTC(2018,3,3,0,0,0,0.0), 278.3752574888393, 235.044725421317], [Date.UTC(2018,3,4,0,0,0,0.0), 281.1730173954167, 237.40699969442704], [Date.UTC(2018,3,5,0,0,0,0.0), 284.4370264955757, 240.1629490903618], [Date.UTC(2018,3,6,0,0,0,0.0), 276.4884192447308, 233.45158319667547], [Date.UTC(2018,3,9,0,0,0,0.0), 279.06928673774206, 235.63072546928916], [Date.UTC(2018,3,10,0,0,0,0.0), 283.45025536531705, 239.32977393155795], [Date.UTC(2018,3,11,0,0,0,0.0), 282.25741327697534, 238.3226038128684], [Date.UTC(2018,3,12,0,0,0,0.0), 284.96840298087193, 240.6116141089718], [Date.UTC(2018,3,13,0,0,0,0.0), 283.93821365613684, 239.7417790196444], [Date.UTC(2018,3,16,0,0,0,0.0), 286.5841422545908, 241.97585530400298], [Date.UTC(2018,3,17,0,0,0,0.0), 289.6421465829388, 244.55786562409247], [Date.UTC(2018,3,18,0,0,0,0.0), 290.0433677642137, 244.89663467719254], [Date.UTC(2018,3,19,0,0,0,0.0), 288.04808331332214, 243.21192645230286], [Date.UTC(2018,3,20,0,0,0,0.0), 285.30456305670424, 240.895449150327], [Date.UTC(2018,3,23,0,0,0,0.0), 285.7491693393196, 241.27085019193038], [Date.UTC(2018,3,24,0,0,0,0.0), 281.205547948138, 237.43446670029945], [Date.UTC(2018,3,25,0,0,0,0.0), 281.81280699436, 237.947202771265], [Date.UTC(2018,3,26,0,0,0,0.0), 285.33709360942555, 240.92291615619945], [Date.UTC(2018,3,27,0,0,0,0.0), 285.87929155020487, 241.38071821542013], [Date.UTC(2018,3,30,0,0,0,0.0), 283.3851611667384, 239.27481197779287], [Date.UTC(2018,4,1,0,0,0,0.0), 283.72135433570674, 239.55867496116826], [Date.UTC(2018,4,2,0,0,0,0.0), 281.81280699436, 237.947202771265], [Date.UTC(2018,4,3,0,0,0,0.0), 280.18621317202206, 236.57379659360296], [Date.UTC(2018,4,4,0,0,0,0.0), 284.51294214963747, 240.22704808473753], [Date.UTC(2018,4,7,0,0,0,0.0), 286.29136728009894, 241.72865225115106], [Date.UTC(2018,4,8,0,0,0,0.0), 286.03108976519235, 241.5088882621514], [Date.UTC(2018,4,9,0,0,0,0.0), 288.90476532583153, 243.9352615296372], [Date.UTC(2018,4,10,0,0,0,0.0), 291.46392372160466, 246.0960738369891], [Date.UTC(2018,4,11,0,0,0,0.0), 292.6133807086059, 247.06661196717533], [Date.UTC(2018,4,14,0,0,0,0.0), 292.9061556830978, 247.31381502002722], [Date.UTC(2018,4,15,0,0,0,0.0), 290.28193618188203, 245.09806870093044], [Date.UTC(2018,4,16,0,0,0,0.0), 292.06032821920746, 246.59964492532376], [Date.UTC(2018,4,17,0,0,0,0.0), 291.8000837974369, 246.3799088783443], [Date.UTC(2018,4,18,0,0,0,0.0), 290.9434017849275, 245.65657380100998], [Date.UTC(2018,4,21,0,0,0,0.0), 293.20981829934476, 247.5702109975302], [Date.UTC(2018,4,22,0,0,0,0.0), 292.5808501558846, 247.0391449613029], [Date.UTC(2018,4,23,0,0,0,0.0), 293.00378043439775, 247.39624397966475], [Date.UTC(2018,4,24,0,0,0,0.0), 292.29889663687584, 246.8010789490617], [Date.UTC(2018,4,25,0,0,0,0.0), 291.95191510556043, 246.50810686709582], [Date.UTC(2018,4,29,0,0,0,0.0), 287.5926224820877, 242.82736042806857], [Date.UTC(2018,4,30,0,0,0,0.0), 292.1254224177861, 246.65460687908885], [Date.UTC(2018,4,31,0,0,0,0.0), 290.08675286555416, 244.93326666569584], [Date.UTC(2018,5,1,0,0,0,0.0), 293.231494303447, 247.58851302077176], [Date.UTC(2018,5,4,0,0,0,0.0), 295.1400416447937, 249.19998521067504], [Date.UTC(2018,5,5,0,0,0,0.0), 295.2593093070599, 249.30068825153387], [Date.UTC(2018,5,6,0,0,0,0.0), 297.5040167242389, 251.19599548279237], [Date.UTC(2018,5,7,0,0,0,0.0), 297.417246521558, 251.12273150578574], [Date.UTC(2018,5,8,0,0,0,0.0), 298.26307398544833, 251.83690160048917], [Date.UTC(2018,5,11,0,0,0,0.0), 298.9896337870725, 252.4503686543338], [Date.UTC(2018,5,12,0,0,0,0.0), 299.15228655067904, 252.58770368369596], [Date.UTC(2018,5,13,0,0,0,0.0), 298.1004212218417, 251.69956657112704], [Date.UTC(2018,5,14,0,0,0,0.0), 298.97877923845334, 252.4412036717029], [Date.UTC(2018,5,15,0,0,0,0.0), 296.47382739950376, 250.326160393465], [Date.UTC(2018,5,18,0,0,0,0.0), 296.77745692261476, 250.58252842894774], [Date.UTC(2018,5,19,0,0,0,0.0), 294.85808812578495, 248.9619191984338], [Date.UTC(2018,5,20,0,0,0,0.0), 296.19190697363103, 250.08812232324397], [Date.UTC(2018,5,21,0,0,0,0.0), 294.0556457632351, 248.28438109223367], [Date.UTC(2018,5,22,0,0,0,0.0), 294.8364121216827, 248.94361717519226], [Date.UTC(2018,5,25,0,0,0,0.0), 289.4794938193322, 244.4205305947303], [Date.UTC(2018,5,26,0,0,0,0.0), 291.1386181943915, 245.8214037782648], [Date.UTC(2018,5,27,0,0,0,0.0), 288.22159062554783, 243.3584264642959], [Date.UTC(2018,5,28,0,0,0,0.0), 290.14095942237765, 244.97903569480982], [Date.UTC(2018,5,29,0,0,0,0.0), 290.3578518359438, 245.16216769530618], [Date.UTC(2018,6,2,0,0,0,0.0), 291.3880080675429, 246.03197484261335], [Date.UTC(2018,6,3,0,0,0,0.0), 290.9325803294444, 245.6474367603993], [Date.UTC(2018,6,5,0,0,0,0.0), 292.927864780336, 247.332144985289], [Date.UTC(2018,6,6,0,0,0,0.0), 295.23763330295765, 249.28238622829232], [Date.UTC(2018,6,9,0,0,0,0.0), 298.31731363540786, 251.8826985716234], [Date.UTC(2018,6,10,0,0,0,0.0), 299.4667706224091, 252.8532367018096], [Date.UTC(2018,6,11,0,0,0,0.0), 296.799166019853, 250.60085839420952], [Date.UTC(2018,6,12,0,0,0,0.0), 299.7920761496223, 253.12790676053393], [Date.UTC(2018,6,13,0,0,0,0.0), 300.29092208219726, 253.54910477327152], [Date.UTC(2018,6,16,0,0,0,0.0), 300.0523536645289, 253.34767074953362], [Date.UTC(2018,6,17,0,0,0,0.0), 301.12589499746844, 254.2541098853441], [Date.UTC(2018,6,18,0,0,0,0.0), 302.00425301408, 254.99574698591996], [Date.UTC(2018,6,19,0,0,0,0.0), 300.57284250807, 253.78714284349252], [Date.UTC(2018,6,24,0,0,0,0.0), 302.25367598036746, 255.20634599228876], [Date.UTC(2018,6,25,0,0,0,0.0), 304.6935667138744, 257.26645525878183], [Date.UTC(2018,6,26,0,0,0,0.0), 304.3899371907634, 257.0100872232991], [Date.UTC(2018,6,27,0,0,0,0.0), 301.9933984654609, 254.9865820032891], [Date.UTC(2018,6,30,0,0,0,0.0), 300.54031195534867, 253.75967583762008], [Date.UTC(2018,6,31,0,0,0,0.0), 301.92833736001825, 254.93164799154422], [Date.UTC(2018,7,1,0,0,0,0.0), 301.68976894234993, 254.73021396780632], [Date.UTC(2018,7,2,0,0,0,0.0), 303.023587790196, 255.85641709261648], [Date.UTC(2018,7,3,0,0,0,0.0), 304.6718576166362, 257.24812529352005], [Date.UTC(2018,7,4,0,0,0,0.0), 303.1320339969791, 255.94798309286466]], &quot;type&quot;: &quot;arearange&quot;, &quot;color&quot;: Highcharts.getOptions().colors[4], &quot;marker&quot;: {&quot;enabled&quot;: false}, &quot;name&quot;: &quot;Range with 75% prob&quot;, &quot;tooltip&quot;: {&quot;valueDecimals&quot;: 4}, &quot;lineWidth&quot;: 0, &quot;linkedTo&quot;: &quot;:previous&quot;, &quot;fillOpacity&quot;: 0.3, &quot;zIndex&quot;: 0}];
            var dataLen = data.length;
            for (var ix = 0; ix &lt; dataLen; ix++) {
                chart.addSeries(data[ix]);
            }

 





        
    });
        &lt;/script&gt;

        
    &lt;/body&gt;
&lt;/html&gt;

&lt;p&gt;Here we get a unceratinty rate of 75% as input and the output follows.&lt;/p&gt;

&lt;h2 id=&quot;summary&quot;&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;To get uncertainty intervals you either:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;add a prior to the model, approximate the posterior via variational inference, and then sample from the posterior.&lt;/li&gt;
  &lt;li&gt;run existing model a bunch of times with dropout layers turned on.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;References&lt;/strong&gt; :&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/1705.07832&quot;&gt;Concrete Dropout&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;What Uncertainties Do We Need in Bayesian Deep Learning for Computer Vision? Alex Kendall and Yarin Gal, 2017. &lt;a href=&quot;https://arxiv.org/pdf/1703.04977.pdf&quot;&gt;(.pdf)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Multi-Task Learning Using Uncertainty to Weigh Losses for Scene Geometry and Semantics. Alex Kendall, Yarin Gal and Roberto Cipolla, 2017. &lt;a href=&quot;https://arxiv.org/pdf/1705.07115.pdf&quot;&gt;(.pdf)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/pmorerio/dl-uncertainty&quot;&gt;Github : Code for the uncertainty paper&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://mlg.eng.cam.ac.uk/yarin/blog_2248.html&quot;&gt;Yarin Gal Blog&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
</description>
        <pubDate>Tue, 25 Dec 2018 00:00:00 +0000</pubDate>
        <link>https://ashutoshmishra.dev/deep%20learning/python/machine%20learning/2018/12/25/Uncertainity-Quantification.html</link>
        <guid isPermaLink="true">https://ashutoshmishra.dev/deep%20learning/python/machine%20learning/2018/12/25/Uncertainity-Quantification.html</guid>
        
        <category>Geo-loc</category>
        
        <category>Python</category>
        
        <category>Deep-Learning</category>
        
        
        <category>Deep Learning</category>
        
        <category>Python</category>
        
        <category>Machine Learning</category>
        
      </item>
    
      <item>
        <title>Pytorch Mnist CNN</title>
        <description>&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;torch&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;torch.nn&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;torch.nn.functional&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;F&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;torch.optim&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;optim&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;torchvision&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;torchvision.transforms&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;transforms&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;gzip&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;os&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;argparse&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;tqdm&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_printoptions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;linewidth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;load_mnist&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;kind&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;train&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;

    &lt;span class=&quot;s&quot;&gt;&quot;&quot;&quot;Load MNIST data from `path`&quot;&quot;&quot;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;labels_path&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                               &lt;span class=&quot;s&quot;&gt;&apos;%s-labels-idx1-ubyte.gz&apos;&lt;/span&gt;
                               &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;kind&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;images_path&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                               &lt;span class=&quot;s&quot;&gt;&apos;%s-images-idx3-ubyte.gz&apos;&lt;/span&gt;
                               &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;kind&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;gzip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;labels_path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&apos;rb&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lbpath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;labels&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;frombuffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lbpath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dtype&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uint8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                               &lt;span class=&quot;n&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;gzip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;images_path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&apos;rb&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;imgpath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;images&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;frombuffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imgpath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dtype&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uint8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                               &lt;span class=&quot;n&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reshape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;784&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;images&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;labels&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;train_images&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;train_labels&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;load_mnist&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;E:\DATA SETS &amp;amp; compressed\fashion data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;train_images&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;train_labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;((60000, 784), (60000,))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;test_images&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;test_labels&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;load_mnist&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;E:\DATA SETS &amp;amp; compressed\fashion data&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;kind&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;t10k&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;test_images&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;test_labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;((10000, 784), (10000,))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;train_images&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;train_images&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reshape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;60000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;test_images&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;test_images&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reshape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;train_images&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4545&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;(28, 28)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;output_9_0.png&quot; alt=&quot;png&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;train_data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;test_data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;train_images&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;train_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;train_images&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;train_labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]])&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;test_images&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;test_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;test_images&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;test_labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;trainloader&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;utils&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DataLoader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;train_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shuffle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;batch_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;testloader&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;utils&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DataLoader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;test_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shuffle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;batch_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;i1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;l1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;iter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;trainloader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;i2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;l2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;iter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;testloader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;55&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;l1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;tensor(5, dtype=torch.uint8)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;output_13_1.png&quot; alt=&quot;png&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;s&quot;&gt;&apos;&apos;&apos;
0 - tshirt
1 - trouser
2 - pullover
3 - dress
4 - coat
5 - sandal
6 - shirt
7 - sneakers
8 - bag
9 - ankle boot
&apos;&apos;&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&apos;\n0 - tshirt\n1 - trouser\n2 - pullover\n3 - dress\n4 - coat\n5 - sandal\n6 - shirt\n7 - sneakers\n8 - bag\n9 - ankle boot\n&apos;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;l1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;tensor([5, 9, 3, 1, 5, 7, 5, 5, 9, 7, 4, 9, 9, 4, 8, 4, 0, 6, 4, 1, 9, 4, 7, 3, 0, 5, 6, 8, 3, 2, 5,
        8, 7, 9, 5, 3, 9, 8, 5, 6, 3, 5, 4, 3, 2, 3, 3, 3, 8, 4, 2, 6, 1, 6, 6, 5, 1, 0, 0, 7, 7, 6,
        4, 2, 1, 7, 7, 8, 5, 3, 4, 7, 2, 6, 2, 8, 2, 3, 1, 1, 3, 9, 6, 2, 1, 4, 1, 1, 3, 9, 0, 7, 0,
        0, 4, 6, 7, 8, 7, 9], dtype=torch.uint8)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;i1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;torch.Size([100, 28, 28])
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;#start the model.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Thu, 18 Oct 2018 00:00:00 +0000</pubDate>
        <link>https://ashutoshmishra.dev/tech/2018/10/18/FashionMnist_Pytorch.html</link>
        <guid isPermaLink="true">https://ashutoshmishra.dev/tech/2018/10/18/FashionMnist_Pytorch.html</guid>
        
        <category>Ashutosh</category>
        
        <category>Life</category>
        
        <category>resume</category>
        
        <category>Pytorch</category>
        
        <category>Mnist</category>
        
        
        <category>tech</category>
        
      </item>
    
      <item>
        <title>Doodle GAN</title>
        <description>&lt;h1 id=&quot;doodle-gan&quot;&gt;Doodle-gan&lt;/h1&gt;
&lt;p&gt;Generate doodle of certain things using GANs&lt;/p&gt;
&lt;h2 id=&quot;visit--httpsash1998githubiodoodle-gan-to-see-tensorflow-graph&quot;&gt;visit : https://ash1998.github.io/Doodle-gan/ to see tensorflow graph!!!&lt;/h2&gt;

&lt;h2 id=&quot;jupyter-notebook-&quot;&gt;Jupyter NOTEBOOK :&lt;/h2&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;err&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pip&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tqdm&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Requirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (4.26.0)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;err&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;wget&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;https&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;storage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;googleapis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;quickdraw_dataset&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;full&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;numpy_bitmap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hand&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;npy&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Redirecting output to ‘wget-log’.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;tqdm&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tqdm&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sklearn.model_selection&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;train_test_split&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;tensorflow&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pickle&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pkl&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;time&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;  &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;hand.npy&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;(291773, 784)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;fig&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;rows&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rows&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;44&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reshape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;fig&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add_subplot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rows&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/kRQ5hW7.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;model_inputs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;real_dims&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;z_dims&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;inputs_real&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;placeholder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;real_dims&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;input_real&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;inputs_z&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;placeholder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;z_dims&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;input_z&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;inputs_real&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;inputs_z&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;tqdm&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;trange&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;get_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

            &lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;trange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]):&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

            &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;train_test_split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;x_train&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;astype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;255&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;x_train&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reshape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;784&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  

        &lt;span class=&quot;k&quot;&gt;except&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Exception&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;            
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;x_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_test&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;get_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;hand.npy&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;100%|██████████| 291773/291773 [00:00&amp;lt;00:00, 395182.40it/s]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;x_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;(218829, 784)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;generator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;out_dims&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n_units&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;128&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reuse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.01&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;variable_scope&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;generator&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reuse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reuse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    
    &lt;span class=&quot;c1&quot;&gt;#hidden layer
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;h1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;layers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dense&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_units&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;activation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,)&lt;/span&gt;
    
    &lt;span class=&quot;c1&quot;&gt;#leaky relu implementation
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;h1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;maximum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    
    &lt;span class=&quot;c1&quot;&gt;#tanh 
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;logits&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;layers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dense&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;out_dims&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    
    &lt;span class=&quot;n&quot;&gt;out&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tanh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;logits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;discriminator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n_units&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;128&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reuse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.01&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;variable_scope&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;discriminator&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reuse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reuse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    
    &lt;span class=&quot;c1&quot;&gt;#hidden layer
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;h1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;layers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dense&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n_units&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;activation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;#leaky_relu
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;h1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;maximum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    
    &lt;span class=&quot;c1&quot;&gt;#sigmoid
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;logits&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;layers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dense&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;activation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;out&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sigmoid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;logits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;logits&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;#hyperparams
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;r_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;784&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;z_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;g_units&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;128&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;d_units&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;128&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.01&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;smooth&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reset_default_graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;inputs_real&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;inputs_z&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;model_inputs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;r_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;z_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;g_out&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;generator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inputs_z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;g_units&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;d_out_real&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;real_logit&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;discriminator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inputs_real&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;d_out_fake&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fake_logits&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;discriminator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;g_out&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reuse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;d_loss_real&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reduce_mean&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sigmoid_cross_entropy_with_logits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;logits&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;real_logit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;labels&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ones_like&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;real_logit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;smooth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;d_loss_fake&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reduce_mean&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sigmoid_cross_entropy_with_logits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;logits&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fake_logits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;labels&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zeros_like&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fake_logits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;d_loss&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d_loss_fake&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d_loss_real&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;g_loss&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reduce_mean&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sigmoid_cross_entropy_with_logits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;logits&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fake_logits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;labels&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ones_like&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fake_logits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;lr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.002&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;tvar&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;trainable_variables&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;gvar&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tvar&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;startswith&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;generator&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;dvar&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tvar&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;startswith&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;discriminator&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;d_opt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AdamOptimizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;learning_rate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;minimize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d_loss&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;var_list&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dvar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;g_opt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AdamOptimizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;minimize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;g_loss&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;var_list&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gvar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;batch_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;epochs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;500&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;samples&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;losses&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# Only save generator variables
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;saver&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Saver&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;var_list&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gvar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Session&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sess&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;sess&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;global_variables_initializer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;epochs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ii&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;batch_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;batch&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;randint&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;batch_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
            
            &lt;span class=&quot;n&quot;&gt;batch_images&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;batch&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
            
            &lt;span class=&quot;c1&quot;&gt;# Sample random noise for G
&lt;/span&gt;            &lt;span class=&quot;n&quot;&gt;batch_z&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uniform&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;batch_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;z_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
            
            &lt;span class=&quot;c1&quot;&gt;# Run optimizers
&lt;/span&gt;            &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sess&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d_opt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;feed_dict&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inputs_real&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;batch_images&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;inputs_z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;batch_z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sess&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;g_opt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;feed_dict&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inputs_z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;batch_z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
        
        &lt;span class=&quot;c1&quot;&gt;# At the end of each epoch, get the losses and print them out
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;train_loss_d&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sess&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d_loss&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inputs_z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;batch_z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;inputs_real&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;batch_images&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;train_loss_g&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;g_loss&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;eval&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inputs_z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;batch_z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;    
          &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Epoch {}/{}...&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;epochs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                &lt;span class=&quot;s&quot;&gt;&quot;Discriminator Loss: {:.4f}...&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;train_loss_d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                &lt;span class=&quot;s&quot;&gt;&quot;Generator Loss: {:.4f}&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;train_loss_g&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;    
        &lt;span class=&quot;c1&quot;&gt;# Save losses to view after training
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;losses&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;train_loss_d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;train_loss_g&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
        
        &lt;span class=&quot;c1&quot;&gt;# Sample from generator as we&apos;re training for viewing afterwards
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;sample_z&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uniform&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;z_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;gen_samples&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sess&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
                       &lt;span class=&quot;n&quot;&gt;generator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inputs_z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n_units&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;g_units&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reuse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                       &lt;span class=&quot;n&quot;&gt;feed_dict&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inputs_z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sample_z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;samples&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gen_samples&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;saver&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;save&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sess&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&apos;./checkpoints/generator.ckpt&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Save training generator samples
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;train_samples.pkl&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&apos;wb&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;pkl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dump&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;samples&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;Time elapsed : &apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;60&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&apos; mins.&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Epoch 0/500... Discriminator Loss: 1.6707... Generator Loss: 1.4493
Epoch 10/500... Discriminator Loss: 0.9074... Generator Loss: 2.4779
Epoch 20/500... Discriminator Loss: 1.1374... Generator Loss: 2.0511
Epoch 30/500... Discriminator Loss: 0.9474... Generator Loss: 1.7452
Epoch 40/500... Discriminator Loss: 0.8880... Generator Loss: 2.4058
Epoch 50/500... Discriminator Loss: 0.8076... Generator Loss: 1.9397
Epoch 60/500... Discriminator Loss: 1.1116... Generator Loss: 2.3747
Epoch 70/500... Discriminator Loss: 1.1073... Generator Loss: 1.9609
Epoch 80/500... Discriminator Loss: 0.6991... Generator Loss: 2.5973
Epoch 90/500... Discriminator Loss: 0.7232... Generator Loss: 2.5385
Epoch 100/500... Discriminator Loss: 0.9148... Generator Loss: 2.5839
Epoch 110/500... Discriminator Loss: 0.8684... Generator Loss: 2.0452
Epoch 120/500... Discriminator Loss: 0.8051... Generator Loss: 2.4832
Epoch 130/500... Discriminator Loss: 0.7279... Generator Loss: 2.3884
Epoch 140/500... Discriminator Loss: 0.7729... Generator Loss: 2.6445
Epoch 150/500... Discriminator Loss: 0.9274... Generator Loss: 2.0117
Epoch 160/500... Discriminator Loss: 0.8559... Generator Loss: 2.1539
Epoch 170/500... Discriminator Loss: 0.8468... Generator Loss: 2.6925
Epoch 180/500... Discriminator Loss: 0.9560... Generator Loss: 2.1045
Epoch 190/500... Discriminator Loss: 0.7690... Generator Loss: 2.5542
Epoch 200/500... Discriminator Loss: 0.7464... Generator Loss: 2.2122
Epoch 210/500... Discriminator Loss: 0.9038... Generator Loss: 2.2893
Epoch 220/500... Discriminator Loss: 0.8363... Generator Loss: 2.3467
Epoch 230/500... Discriminator Loss: 0.8801... Generator Loss: 2.4203
Epoch 240/500... Discriminator Loss: 0.7290... Generator Loss: 2.4522
Epoch 250/500... Discriminator Loss: 0.9505... Generator Loss: 2.9067
Epoch 260/500... Discriminator Loss: 0.7524... Generator Loss: 2.7188
Epoch 270/500... Discriminator Loss: 0.6982... Generator Loss: 2.9462
Epoch 280/500... Discriminator Loss: 0.6907... Generator Loss: 3.1297
Epoch 290/500... Discriminator Loss: 0.9001... Generator Loss: 2.6899
Epoch 300/500... Discriminator Loss: 0.8052... Generator Loss: 2.6376
Epoch 310/500... Discriminator Loss: 0.7071... Generator Loss: 2.7365
Epoch 320/500... Discriminator Loss: 0.7122... Generator Loss: 2.1293
Epoch 330/500... Discriminator Loss: 0.6925... Generator Loss: 2.7369
Epoch 340/500... Discriminator Loss: 0.6606... Generator Loss: 2.7011
Epoch 350/500... Discriminator Loss: 0.8017... Generator Loss: 2.7372
Epoch 360/500... Discriminator Loss: 0.7386... Generator Loss: 2.5534
Epoch 370/500... Discriminator Loss: 0.7761... Generator Loss: 2.6640
Epoch 380/500... Discriminator Loss: 0.8729... Generator Loss: 2.5655
Epoch 390/500... Discriminator Loss: 0.7941... Generator Loss: 2.4595
Epoch 400/500... Discriminator Loss: 0.7133... Generator Loss: 2.6706
Epoch 410/500... Discriminator Loss: 0.8759... Generator Loss: 2.2614
Epoch 420/500... Discriminator Loss: 0.8227... Generator Loss: 2.6058
Epoch 430/500... Discriminator Loss: 0.7340... Generator Loss: 2.5549
Epoch 440/500... Discriminator Loss: 0.8911... Generator Loss: 2.1466
Epoch 450/500... Discriminator Loss: 0.8063... Generator Loss: 2.6061
Epoch 460/500... Discriminator Loss: 0.7884... Generator Loss: 2.8062
Epoch 470/500... Discriminator Loss: 0.8174... Generator Loss: 2.7951
Epoch 480/500... Discriminator Loss: 0.8458... Generator Loss: 2.4348
Epoch 490/500... Discriminator Loss: 0.8786... Generator Loss: 2.3088
Time elapsed :  100.79581373929977  mins.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;fig&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ax&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;subplots&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;losses&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;losses&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;losses&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;Discriminator&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;losses&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;Generator&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Training Losses&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;legend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/k811hGp.png&quot; alt=&quot;png&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;view_samples&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;epoch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;samples&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;fig&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;axes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;subplots&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nrows&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ncols&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sharey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sharex&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;zip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;axes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;samples&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;epoch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;ax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xaxis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_visible&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;ax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;yaxis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_visible&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;im&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reshape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cmap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;Greys&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fig&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;axes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Load samples from generator taken while training
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;train_samples.pkl&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&apos;rb&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;samples&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pkl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;_&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;view_samples&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;299&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;samples&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/3laMedt.png&quot; alt=&quot;png&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;rows&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cols&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;fig&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;axes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;subplots&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nrows&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rows&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ncols&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cols&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sharex&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sharey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sample&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ax_row&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;zip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;samples&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[::&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;samples&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rows&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;axes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ax&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;zip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sample&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[::&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sample&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cols&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ax_row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;ax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reshape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cmap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;Greys&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;ax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xaxis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_visible&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;ax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;yaxis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_visible&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/PQ0ieQ5.png&quot; alt=&quot;png&quot; /&gt;&lt;/p&gt;

</description>
        <pubDate>Thu, 18 Oct 2018 00:00:00 +0000</pubDate>
        <link>https://ashutoshmishra.dev/deep%20learning/2018/10/18/Doodle-GAN.html</link>
        <guid isPermaLink="true">https://ashutoshmishra.dev/deep%20learning/2018/10/18/Doodle-GAN.html</guid>
        
        <category>Doodle</category>
        
        <category>GAN</category>
        
        <category>Python</category>
        
        <category>Deep-Learning</category>
        
        
        <category>Deep Learning</category>
        
      </item>
    
      <item>
        <title>Deep Representation of Visual Decriptions</title>
        <description>&lt;h1 id=&quot;deep-representation-of-visual-descriptions&quot;&gt;Deep-Representation-of-Visual-Descriptions&lt;/h1&gt;
&lt;p&gt;&lt;a href=&quot;http://hits.dwyl.io/ASH1998/Deep-Representation-of-Visual-Descriptions&quot;&gt;&lt;img src=&quot;http://hits.dwyl.io/ASH1998/Deep-Representation-of-Visual-Descriptions.svg&quot; alt=&quot;HitCount&quot; /&gt;&lt;/a&gt;    &lt;a href=&quot;https://github.com/ASH1998/Deep-Representation-of-Visual-Descriptions/&quot;&gt;&lt;img src=&quot;https://img.shields.io/github/last-commit/google/skia.svg?style=popout&quot; alt=&quot;GitHub last commit&quot; /&gt;&lt;/a&gt;  &lt;img src=&quot;https://img.shields.io/jenkins/s/https/jenkins.qa.ubuntu.com/view/Precise/view/All%20Precise/job/precise-desktop-amd64_default.svg&quot; alt=&quot;&quot; /&gt;&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;The project is ongoing, so changes will be frequent!!&lt;/code&gt;&lt;/p&gt;

&lt;h2 id=&quot;why-&quot;&gt;Why? &lt;a href=&quot;https://ash1998.github.io/Deep-Representation-of-Visual-Descriptions/&quot;&gt;&lt;img src=&quot;https://img.shields.io/badge/start%20with-why%3F-brightgreen.svg?style=flat&quot; alt=&quot;start with why&quot; /&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;h2 id=&quot;documentation-&quot;&gt;Documentation &lt;a href=&quot;https://github.com/ASH1998/Deep-Representation-of-Visual-Descriptions/wiki&quot;&gt;&lt;img src=&quot;https://img.shields.io/badge/Wiki-GO-brightgreen.svg&quot; alt=&quot;wiki&quot; /&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h2 id=&quot;dependencies-&quot;&gt;Dependencies &lt;img src=&quot;https://img.shields.io/depfu/depfu/example-ruby.svg&quot; alt=&quot;&quot; /&gt;&lt;/h2&gt;
&lt;ol&gt;
  &lt;li&gt;Python&lt;/li&gt;
  &lt;li&gt;Pytorch&lt;/li&gt;
  &lt;li&gt;torchfile&lt;/li&gt;
  &lt;li&gt;nltk- (‘punkt’)&lt;/li&gt;
  &lt;li&gt;pandas&lt;/li&gt;
  &lt;li&gt;scikit-learn&lt;/li&gt;
  &lt;li&gt;python-dateutil&lt;/li&gt;
  &lt;li&gt;easydict&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;data-download&quot;&gt;Data Download&lt;/h2&gt;
&lt;h3 id=&quot;repo--&quot;&gt;Repo : &lt;a href=&quot;https://github.com/ASH1998/Deep-Representation-of-Visual-Descriptions/archive/master.zip&quot;&gt;&lt;img src=&quot;https://img.shields.io/badge/download%20repo:-273.93MiB-blue.svg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/h3&gt;

&lt;h2 id=&quot;models-&quot;&gt;Models :&lt;/h2&gt;
&lt;h3 id=&quot;trained-models&quot;&gt;Trained models:&lt;/h3&gt;
&lt;h3 id=&quot;eval-models&quot;&gt;Eval models&lt;/h3&gt;

&lt;h2 id=&quot;current-outputs&quot;&gt;Current Outputs&lt;/h2&gt;

&lt;h5 id=&quot;text--flat-screen-television-on-top-of-an-old-tv-console&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Text : flat screen television on top of an old tv console&lt;/code&gt;&lt;/h5&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/6Z5FTeq.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Attention :&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/RBRnYQy.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h5 id=&quot;text--a-large-red-and-white-boat-floating-on-top-of-a-lake&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Text : a large red and white boat floating on top of a lake&lt;/code&gt;&lt;/h5&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/ASH1998/Deep-Representation-of-Visual-Descriptionsmodels/coco_AttnGAN2/example_captions/0_s_3_g2.png&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://github.com/ASH1998/Deep-Representation-of-Visual-Descriptionsmodels/coco_AttnGAN2/example_captions/0_s_3_a1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h5 id=&quot;text-this-bird-is-red-and-white-in-color-with-a-stubby-beak-and-red-eye-rings&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;TEXT :this bird is red and white in color with a stubby beak and red eye rings&lt;/code&gt;&lt;/h5&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/cxWaEID.png&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://i.imgur.com/jPDXxc2.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h5 id=&quot;text--this-bird-is-yellow-with-black-on-its-head-and-has-a-very-short-beak&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Text : this bird is yellow with black on its head and has a very short beak&lt;/code&gt;&lt;/h5&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/bivvojr.png&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://github.com/ASH1998/Deep-Representation-of-Visual-Descriptions/blob/master/models/bird_AttnGAN2/next/0_s_0_a1.png&quot; /&gt;&lt;/p&gt;

&lt;h5 id=&quot;caption-generation-with-attention&quot;&gt;Caption Generation with Attention&lt;/h5&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/ASH1998/Deep-Representation-of-Visual-Descriptions/output/coco_DAMSM_2018_10_10_04_42_55/Image/attention_maps0.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;contributors&quot;&gt;Contributors&lt;/h2&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Team Members&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Github&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;LinkedIN&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;Ashutosh Mishra &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LEAD&lt;/code&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;&lt;a href=&quot;https://github.com/ASH1998/&quot;&gt;ASH1998&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;&lt;a href=&quot;https://www.linkedin.com/in/ashutosh-mishra-a1ba01142/&quot;&gt;Ashutosh’s LinkedIN&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;V. Praveen&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;&lt;a href=&quot;https://github.com/praveenvoonna&quot;&gt;praveenvoona&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;&lt;a href=&quot;https://www.linkedin.com/in/praveenv-17&quot;&gt;Praveen’s LinkedIN&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;Deepak Kumar Behera&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;&lt;a href=&quot;&quot;&gt;Github&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;&lt;a href=&quot;&quot;&gt;LinkedIN&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;Madan Mohan Mohapatra&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;&lt;a href=&quot;&quot;&gt;Github&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;&lt;a href=&quot;&quot;&gt;LinkedIN&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;contributing-&quot;&gt;Contributing :&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/ASH1998/Deep-Representation-of-Visual-Descriptions/issues&quot;&gt;&lt;img src=&quot;https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat&quot; alt=&quot;contributions welcome&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;website-&quot;&gt;Website :&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://ash1998.github.io/Deep-Representation-of-Visual-Descriptions/&quot;&gt;https://ash1998.github.io/Deep-Representation-of-Visual-Descriptions/&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Thu, 18 Oct 2018 00:00:00 +0000</pubDate>
        <link>https://ashutoshmishra.dev/deep%20learning/2018/10/18/Deep-Representation-of-visual-descriptions.html</link>
        <guid isPermaLink="true">https://ashutoshmishra.dev/deep%20learning/2018/10/18/Deep-Representation-of-visual-descriptions.html</guid>
        
        <category>AttnGAN</category>
        
        <category>text-to-image</category>
        
        <category>StackGAN</category>
        
        <category>GAN</category>
        
        <category>Python</category>
        
        <category>Deep-Learning</category>
        
        
        <category>Deep Learning</category>
        
      </item>
    
      <item>
        <title>Emotion Detection</title>
        <description>&lt;h1 id=&quot;emotion-detection&quot;&gt;Emotion-detection&lt;/h1&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/dwyl/esta/issues&quot;&gt;&lt;img src=&quot;https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat&quot; alt=&quot;contributions welcome&quot; /&gt;&lt;/a&gt;  &lt;a href=&quot;http://hits.dwyl.io/ASH1998/Emotion-detection&quot;&gt;&lt;img src=&quot;http://hits.dwyl.io/ASH1998/Emotion-detection.svg&quot; alt=&quot;HitCount&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Emotion Detection using deep unbaised CONV-net!!&lt;/p&gt;
&lt;h2 id=&quot;website--httpsash1998githubioemotion-detection&quot;&gt;Website : &lt;a href=&quot;https://ash1998.github.io/Emotion-detection/&quot;&gt;https://ash1998.github.io/Emotion-detection/&lt;/a&gt;&lt;/h2&gt;

&lt;h2 id=&quot;getting-data&quot;&gt;Getting Data&lt;/h2&gt;
&lt;p&gt;The dataset used here is the famous &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FER2013 dataset&lt;/code&gt; from kaggle’s &lt;a href=&quot;https://www.kaggle.com/c/challenges-in-representation-learning-facial-expression-recognition-challenge&quot;&gt;FER challenge of 2013&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;download&quot;&gt;Download&lt;/h3&gt;
&lt;h5 id=&quot;zip-file--from-here-92mb&quot;&gt;Zip File : &lt;a href=&quot;https://www.kaggle.com/c/3364/download-all&quot;&gt;from here 92MB&lt;/a&gt;&lt;/h5&gt;

&lt;h5 id=&quot;using-api-&quot;&gt;Using API :&lt;/h5&gt;
&lt;p&gt;1.Install Kaggle from &lt;a href=&quot;https://github.com/Kaggle/kaggle-api&quot;&gt;github&lt;/a&gt; &lt;br /&gt;
2.Use the command in terminal &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kaggle competitions download -c challenges-in-representation-learning-facial-expression-recognition-challenge&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Docs on Kaggle API usage :
&lt;a href=&quot;https://github.com/Kaggle/kaggle-api&quot;&gt;github&lt;/a&gt; | &lt;a href=&quot;https://www.kaggle.com/docs/api&quot;&gt;kaggle&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;dependencies&quot;&gt;Dependencies&lt;/h2&gt;
&lt;ol&gt;
  &lt;li&gt;Python&lt;/li&gt;
  &lt;li&gt;Jupyter&lt;/li&gt;
  &lt;li&gt;Keras&lt;/li&gt;
  &lt;li&gt;Tensorflow&lt;/li&gt;
  &lt;li&gt;Matplotlib&lt;/li&gt;
  &lt;li&gt;Pandas&lt;/li&gt;
  &lt;li&gt;Numpy&lt;/li&gt;
  &lt;li&gt;tqdm&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;usage&quot;&gt;Usage&lt;/h2&gt;
&lt;h3 id=&quot;for-model1&quot;&gt;For model1:&lt;/h3&gt;
&lt;ol&gt;
  &lt;li&gt;Download the data and unzip it as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FER2013&lt;/code&gt; dir.&lt;/li&gt;
  &lt;li&gt;Clone this repo.&lt;/li&gt;
  &lt;li&gt;Add the full path of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fer2013.csv&lt;/code&gt; into &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cell 3&lt;/code&gt; of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FER2013-model1.ipynb&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Run the file or use the pretrained model weights.
    &lt;h3 id=&quot;using-pre-trained-weights&quot;&gt;Using pre-trained weights:&lt;/h3&gt;
    &lt;p&gt;The Layers for the network :&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;https://github.com/ASH1998/Emotion-detection/blob/master/Images/4.PNG&quot; alt=&quot;name4&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;for-eda-notebook-&quot;&gt;For EDA notebook :&lt;/h3&gt;
&lt;ol&gt;
  &lt;li&gt;Change the path to weights folder in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cell3&lt;/code&gt;.
    &lt;h2 id=&quot;images&quot;&gt;Images&lt;/h2&gt;
    &lt;p&gt;Testset Accuracy :&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;https://github.com/ASH1998/Emotion-detection/blob/master/Images/2.PNG&quot; alt=&quot;image2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Some Images prediction :&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://github.com/ASH1998/Emotion-detection/blob/master/Images/5.PNG&quot; alt=&quot;image5&quot; /&gt; &lt;br /&gt;
&lt;img src=&quot;https://github.com/ASH1998/Emotion-detection/blob/master/Images/1.PNG&quot; alt=&quot;image1&quot; /&gt;     &lt;br /&gt;
&lt;img src=&quot;https://github.com/ASH1998/Emotion-detection/blob/master/Images/3.PNG&quot; alt=&quot;image3&quot; /&gt;         &lt;br /&gt;
&lt;img src=&quot;https://github.com/ASH1998/Emotion-detection/blob/master/Images/6.PNG&quot; alt=&quot;image6&quot; /&gt; &lt;br /&gt;
&lt;img src=&quot;https://github.com/ASH1998/Emotion-detection/blob/master/Images/7.PNG&quot; alt=&quot;image7&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;eda-confusion-matrix-and-scores&quot;&gt;EDA confusion Matrix and Scores:&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/ASH1998/Emotion-detection/blob/master/Images/811.PNG&quot; alt=&quot;image8&quot; /&gt;    &lt;br /&gt;
&lt;img src=&quot;https://github.com/ASH1998/Emotion-detection/blob/master/Images/9.PNG&quot; alt=&quot;image9&quot; /&gt;       &lt;br /&gt;
&lt;img src=&quot;https://github.com/ASH1998/Emotion-detection/blob/master/Images/10.PNG&quot; alt=&quot;image10&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;ed-analysis&quot;&gt;ED Analysis:&lt;/h3&gt;
&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Happy&lt;/code&gt; Emotion is the most detected, as it has most number of examples&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Sad&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Surprise&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Neutral&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Anger&lt;/code&gt; are also good in detecting due to enough examples.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Fear&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Disgust&lt;/code&gt; perform worse, possible reasons : Less training examples and for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;disgust&lt;/code&gt;: pretty similar to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anger&lt;/code&gt; features.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Sad&lt;/code&gt; emotions are also closely detected as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;neutral&lt;/code&gt;, cuz its hard to distinguish them with just this much data.&lt;/li&gt;
&lt;/ol&gt;
</description>
        <pubDate>Tue, 25 Sep 2018 00:00:00 +0000</pubDate>
        <link>https://ashutoshmishra.dev/deep%20learning/2018/09/25/Emotion-Detection.html</link>
        <guid isPermaLink="true">https://ashutoshmishra.dev/deep%20learning/2018/09/25/Emotion-Detection.html</guid>
        
        <category>Emotion</category>
        
        <category>CNN</category>
        
        <category>Python</category>
        
        <category>Deep-Learning</category>
        
        
        <category>Deep Learning</category>
        
      </item>
    
      <item>
        <title>The-BOT</title>
        <description>&lt;p&gt;&lt;img src=&quot;https://img.shields.io/pypi/pyversions/goodreads.svg&quot; alt=&quot;alt text&quot; /&gt;
&lt;img src=&quot;https://png.icons8.com/api/color/37/000000&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;the-bot-&quot;&gt;THE-BOT &lt;a href=&quot;https://github.com/ASH1998/THE-BOT&quot;&gt;&lt;img src=&quot;https://png.icons8.com/robot-2/color/100/000000&quot; alt=&quot;THE-BOT&quot; /&gt;&lt;/a&gt;&lt;/h1&gt;

&lt;p&gt;=============&lt;/p&gt;

&lt;p&gt;The AI “THE-BOT” which is build using flask and Restful Api responsive, which gives you a Weather, Distance and Your_IP…(lot more coming up….)&lt;/p&gt;

&lt;h2 id=&quot;getting-started&quot;&gt;Getting Started&lt;/h2&gt;

&lt;p&gt;These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.&lt;/p&gt;

&lt;p&gt;for more bleeding edge developement check out the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/test&lt;/code&gt; directory&lt;/p&gt;

&lt;h3 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Requires python2.6+, or python3.0 +&lt;/li&gt;
  &lt;li&gt;Required python packages: Flask,Flask-Restful, Requests , Geopy&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;installing&quot;&gt;Installing&lt;/h3&gt;

&lt;p&gt;A step by step series of examples that tell you have to get a development env running&lt;/p&gt;

&lt;p&gt;Say what the step will be&lt;/p&gt;

&lt;p&gt;The instruction helps you install in local machine&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Install Virtualenv (Virtual Environment)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~$ pip install virtualenv&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Create a project file&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~$ mkdir project&lt;/code&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~$ cd project&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Create Virtual Environment&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~$ virtualenv The_Bot&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~$ source The_Bot/bin/activate&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now your into the vrtual envirment and proceed with installing dependencies&lt;/p&gt;

&lt;p&gt;4.Clone the THE-BOT project&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~$ git clone https://github.com/ASH1998/THE-BOT&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Change directory into “THE-BOT” file&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~$ cd THE-BOT&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(THE_BOT)THE-BOT~$ pip install -r requirements.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Which intern download all Modules&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Finally Run the app&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~$ python runserver.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The bot is running into 5000 local port&lt;/p&gt;

&lt;h2 id=&quot;examples&quot;&gt;Examples&lt;/h2&gt;

&lt;p&gt;The bot as multiple modules&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;weather 
To run an weather app&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;curl http://127.0.0.1:5000/api/v1.0/w/&amp;lt;city_name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The city_name could be any city&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Distance 
This module finds an distance between two point&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To check the distance&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;curl http://127.0.0.1:5000/api/v1.0/d/&amp;lt;source&amp;gt;/&amp;lt;destination&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;3.For Wikipedia Search&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;curl http://127.0.0.1:5000/api/v1.0/wiki/&amp;lt;query&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h2 id=&quot;deployment&quot;&gt;Deployment&lt;/h2&gt;

&lt;p&gt;Add additional notes about how to deploy this on a live system&lt;/p&gt;

&lt;h2 id=&quot;contributing&quot;&gt;Contributing&lt;/h2&gt;

&lt;p&gt;Please read &lt;a href=&quot;CONTRIBUTING.md&quot;&gt;CONTRIBUTING.md&lt;/a&gt; for details on our code of conduct, and the process for submitting pull requests to us.&lt;/p&gt;

&lt;h2 id=&quot;pull-requests&quot;&gt;Pull Requests&lt;/h2&gt;

&lt;p&gt;We :heart: pull requests! We even :sparkling_heart: them if they contain well written commit messages!&lt;/p&gt;

&lt;p&gt;Please write the first line of your commit message in the following style:&lt;/p&gt;

&lt;p&gt;exercise-name: Change some things&lt;/p&gt;

&lt;p&gt;Please try to follow the The seven rules of a great Git commit message like to capitalize the subject line and use the imperative mood. If there are more details to add, put those into the body of the commit message.&lt;/p&gt;

&lt;p&gt;If you’re interested, Tim Pope even has an entire blog post on good commit messages.&lt;/p&gt;

&lt;p&gt;If you’re new to Git, take a look at this short guide.&lt;/p&gt;

&lt;h2 id=&quot;versioning&quot;&gt;Versioning&lt;/h2&gt;

&lt;h2 id=&quot;authors&quot;&gt;Authors&lt;/h2&gt;

&lt;h2 id=&quot;license&quot;&gt;License&lt;/h2&gt;

&lt;p&gt;This project is licensed under the MIT License - see the &lt;a href=&quot;LICENSE.md&quot;&gt;LICENSE.md&lt;/a&gt; file for details&lt;/p&gt;

&lt;h2 id=&quot;acknowledgments&quot;&gt;Acknowledgments&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Hat tip to anyone who’s code was used&lt;/li&gt;
  &lt;li&gt;Inspiration&lt;/li&gt;
  &lt;li&gt;etc&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;irc&quot;&gt;IRC&lt;/h2&gt;

&lt;p&gt;Anyquery find us in&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://join.slack.com/t/wemakethebot/shared_invite/enQtMjc1NzY1NjM2MTE5LTg4Mzc2MGE3MTZlMDZhNTExOGFiOTQ1MDY5MDJkNzU2NWM1ZDRiOTdiYmM5NDQzY2EyODJkMzdmZmU2ZTU0NGM&quot;&gt;&lt;img src=&quot;https://png.icons8.com/slack/color/91/000000&quot; alt=&quot;alt text&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://png.icons8.com/stack-overflow/color/91/000000&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;

</description>
        <pubDate>Mon, 27 Nov 2017 00:00:00 +0000</pubDate>
        <link>https://ashutoshmishra.dev/deep%20learning/geo-loc/2017/11/27/THE-BOT.html</link>
        <guid isPermaLink="true">https://ashutoshmishra.dev/deep%20learning/geo-loc/2017/11/27/THE-BOT.html</guid>
        
        <category>Geo-loc</category>
        
        <category>Python</category>
        
        <category>Deep-Learning</category>
        
        
        <category>Deep Learning</category>
        
        <category>Geo-Loc</category>
        
      </item>
    
  </channel>
</rss>
