<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Zoheb Abai</title>
    <description>The latest articles on DEV Community by Zoheb Abai (@zohebabai).</description>
    <link>https://dev.to/zohebabai</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F426542%2Fbce71db0-35f6-4410-bad0-04b11805cc99.png</url>
      <title>DEV Community: Zoheb Abai</title>
      <link>https://dev.to/zohebabai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zohebabai"/>
    <language>en</language>
    <item>
      <title>Upgrade to PyTorch 2.0</title>
      <dc:creator>Zoheb Abai</dc:creator>
      <pubDate>Wed, 24 May 2023 15:30:05 +0000</pubDate>
      <link>https://dev.to/zohebabai/upgrade-to-pytorch-20-b23</link>
      <guid>https://dev.to/zohebabai/upgrade-to-pytorch-20-b23</guid>
      <description>&lt;h2&gt;
  
  
  Why Upgrade?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pytorch.org/get-started/pytorch-2.0/" rel="noopener noreferrer"&gt;PYTORCH 2.X: FASTER, MORE PYTHONIC AND AS DYNAMIC AS EVER&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pytorch.org/blog/deprecation-cuda-python-support/#:~:text=If%20you%20are%20still%20using,versions%20required%20for%20PyTorch%202.0." rel="noopener noreferrer"&gt;Deprecation of CUDA 11.6 and Python 3.7 Support&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Upgrade Objectives
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Python ≥ 3.8, ≤ 3.11&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CUDA ≥ 11.7.0&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CUDNN ≥ 8.5.0.96&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pytorch ≥ 2.0.0&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;blockquote&gt;
&lt;p&gt;“We expect that with PyTorch 2, people will change the way they use PyTorch day-to-day”&lt;br&gt;
“Data scientists will be able to do with PyTorch 2.x the same things that they did with 1.x, but they can do them faster and at a larger scale” &lt;br&gt;
— Soumith Chintala&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Steps for Upgrade
&lt;/h2&gt;

&lt;h3&gt;
  
  
  If you have Python ≥ 3.8, ≤ 3.11 jump to next section
&lt;/h3&gt;

&lt;p&gt;Steps for upgrading Python from ≤ 3.8 to 3.10&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For Clean Installation remove all existing Python related files&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Replace X with the specific version number&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nt"&gt;--purge&lt;/span&gt; remove python3.X
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get autoremove
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get autoclean
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pre-Installations Actions&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update

&lt;span class="c"&gt;# Install required dependencies&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Installing Python 3.10.6 from source&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Download desired version (here 3.10.6) from &lt;a href="https://www.python.org/downloads/source/" rel="noopener noreferrer"&gt;Python Website&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Extract the source code&lt;/span&gt;
&lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-xvf&lt;/span&gt; Python-3.10.6.tgz

&lt;span class="c"&gt;# Configure the build &lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;python-3.10.6
./configure &lt;span class="nt"&gt;--enable-optimizations&lt;/span&gt; &lt;span class="nt"&gt;--prefix&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/local

&lt;span class="c"&gt;# Start the build process&lt;/span&gt;
make &lt;span class="nt"&gt;-j&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;nproc&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;# Once the build completes, install Python&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;make &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open &lt;code&gt;./bashrcfile&lt;/code&gt; and add following lines at the end&lt;/p&gt;

&lt;p&gt;&lt;code&gt;export PATH="/usr/local/bin:$PATH"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Save the file and update the environment variables for the current session by running&lt;/p&gt;

&lt;p&gt;&lt;code&gt;source ~/.bashrc&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Verify Python version&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 &lt;span class="nt"&gt;--version&lt;/span&gt;

which python3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  If you already have CUDA ≥ 11.7.0 jump to next section
&lt;/h3&gt;

&lt;p&gt;Steps for upgrading Cuda ≤ 11.7 on Ubuntu 22.04 with a Nvidia Geforce RTX Graphics Card:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For Clean Installation remove all existing cuda related files&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nt"&gt;--purge&lt;/span&gt; remove &lt;span class="s2"&gt;"*cuda*"&lt;/span&gt; &lt;span class="s2"&gt;"*cublas*"&lt;/span&gt; &lt;span class="s2"&gt;"*cufft*"&lt;/span&gt; &lt;span class="s2"&gt;"*cufile*"&lt;/span&gt; &lt;span class="s2"&gt;"*curand*"&lt;/span&gt;  &lt;span class="s2"&gt;"*cusolver*"&lt;/span&gt; &lt;span class="s2"&gt;"*cusparse*"&lt;/span&gt; &lt;span class="s2"&gt;"*gds-tools*"&lt;/span&gt; &lt;span class="s2"&gt;"*npp*"&lt;/span&gt; &lt;span class="s2"&gt;"*nvjpeg*"&lt;/span&gt; &lt;span class="s2"&gt;"nsight*"&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nt"&gt;--purge&lt;/span&gt; remove &lt;span class="s2"&gt;"*nvidia*"&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get autoremove
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get autoclean
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pre-Installation Actions&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Verify You Have a CUDA-Capable GPU&lt;/span&gt;
lspci | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; nvidia

&lt;span class="c"&gt;# Verify the System Has gcc Installed&lt;/span&gt;
gcc &lt;span class="nt"&gt;--version&lt;/span&gt;

&lt;span class="c"&gt;# Verify the System has the Correct Kernel Headers and Development Packages Installed&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;linux-headers-&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;uname&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Install NVIDIA CUDA Toolkit 11.7.1 (Debian Installer Preferred)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install the repository meta-data, update the GPG key, update the apt-get cache, and install CUDA:&lt;/span&gt;
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
&lt;span class="nb"&gt;sudo mv &lt;/span&gt;cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.7.1/local_installers/cuda-repo-ubuntu2204-11-7-local_11.7.1-515.65.01-1_amd64.deb
&lt;span class="nb"&gt;sudo &lt;/span&gt;dpkg &lt;span class="nt"&gt;-i&lt;/span&gt; cuda-repo-ubuntu2204-11-7-local_11.7.1-515.65.01-1_amd64.deb
&lt;span class="nb"&gt;sudo cp&lt;/span&gt; /var/cuda-repo-ubuntu2204-11-7-local/cuda-&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="nt"&gt;-keyring&lt;/span&gt;.gpg /usr/share/keyrings/
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nt"&gt;-y&lt;/span&gt; &lt;span class="nb"&gt;install &lt;/span&gt;cuda
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For more details, check &lt;a href="https://developer.nvidia.com/cuda-toolkit-archive" rel="noopener noreferrer"&gt;this&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;During Cuda Installation you might get asked for creating a password for MOK management — Do it.&lt;/p&gt;

&lt;p&gt;Reboot the system to load the NVIDIA drivers. If you get a blue screen, DO NOT continue to boot, instead enrol the key providing the password you created a while ago. And then continue to boot.&lt;/p&gt;

&lt;p&gt;Open &lt;code&gt;./bashrc&lt;/code&gt; file and add following lines at the end&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/local/cuda-11.7/bin&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;:+:&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="k"&gt;}}&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;LD_LIBRARY_PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/local/cuda-11.7/lib64&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;LD_LIBRARY_PATH&lt;/span&gt;:+:&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;LD_LIBRARY_PATH&lt;/span&gt;&lt;span class="k"&gt;}}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the file and update the environment variables for the current session by running&lt;/p&gt;

&lt;p&gt;&lt;code&gt;source ~/.bashrc&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Verify the Cuda version&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nvcc &lt;span class="nt"&gt;--version&lt;/span&gt;

nvidia-smi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  If you already have CUDNN ≥ 8.5.0.96 jump to next section
&lt;/h3&gt;

&lt;p&gt;Steps for upgrading CUDNN ≤ 8.5.0.96&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install CUDNN 8.5.0.96 (Debian Installer Preferred)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wget https://developer.nvidia.com/compute/cudnn/secure/8.5.0/local_installers/11.7/cudnn-local-repo-ubuntu2204-8.5.0.96_1.0-1_amd64.deb
&lt;span class="nb"&gt;sudo &lt;/span&gt;dpkg &lt;span class="nt"&gt;-i&lt;/span&gt; cudnn-local-repo-ubuntu2204-8.5.0.96_1.0-1_amd64.deb

&lt;span class="c"&gt;# Import the CUDA GPG key&lt;/span&gt;
&lt;span class="nb"&gt;sudo cp&lt;/span&gt; /var/cudnn-local-repo-ubuntu2204-8.5.0.96/cudnn-local-&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="nt"&gt;-keyring&lt;/span&gt;.gpg /usr/share/keyrings/

&lt;span class="c"&gt;# Refresh the repository metadata&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get update

&lt;span class="c"&gt;# Install the runtime library&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;&lt;span class="nv"&gt;libcudnn8&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;8.5.0.96-1+cuda11.7

&lt;span class="c"&gt;# Install the developer library&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;libcudnn8-dev&lt;span class="o"&gt;=&lt;/span&gt;8.5.0.96-1+cuda11.7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fore more details, check &lt;a href="https://developer.nvidia.com/rdp/cudnn-archive" rel="noopener noreferrer"&gt;this&lt;/a&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  If you already have PyTorch ≥ 2.0.0 you are awesome.
&lt;/h3&gt;

&lt;p&gt;Steps for upgrading PyTorch≤ 2.0.0&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# If you have virtualenv and use pip as manager&lt;/span&gt;
python3 &lt;span class="nt"&gt;-m&lt;/span&gt; pip &lt;span class="nb"&gt;install &lt;/span&gt;&lt;span class="nv"&gt;torch&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;2.0.0+cu117 &lt;span class="nv"&gt;torchvision&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;0.15.1+cu117 &lt;span class="nv"&gt;torchaudio&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;2.0.1 &lt;span class="nt"&gt;--index-url&lt;/span&gt; https://download.pytorch.org/whl/cu117
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For other OS or package manager, check &lt;a href="https://pytorch.org/get-started/previous-versions/" rel="noopener noreferrer"&gt;this&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For downloading wheel files, check &lt;a href="https://download.pytorch.org/whl/cu117" rel="noopener noreferrer"&gt;this&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Verify PyTorch 2.0 Installation&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"import torch; print(torch.__version__)"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;If you get errors google it or comment it down.&lt;/p&gt;

&lt;p&gt;I hope the article helped. Thanks.&lt;/p&gt;




</description>
      <category>python</category>
      <category>deeplearning</category>
      <category>productivity</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>What’s in the controversial article that forced Timnit Gebru out of Google?</title>
      <dc:creator>Zoheb Abai</dc:creator>
      <pubDate>Sat, 30 Jan 2021 18:12:59 +0000</pubDate>
      <link>https://dev.to/zohebabai/what-s-in-the-infamous-article-that-forced-timnit-gebru-out-of-google-li7</link>
      <guid>https://dev.to/zohebabai/what-s-in-the-infamous-article-that-forced-timnit-gebru-out-of-google-li7</guid>
      <description>&lt;p&gt;&lt;em&gt;“On the Dangers of Stochastic Parrots: Can Language Models Be Too Big?”&lt;/em&gt; — &lt;strong&gt;Summarized&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In short — Authors have raised global awareness on recent NLP trends and have urged researchers, developers, and practitioners associated with language technology to take a holistic and responsible approach.&lt;/p&gt;

&lt;h1&gt;
  
  
  Where lies the Issue?
&lt;/h1&gt;

&lt;p&gt;Most notable NLP trend — the ever-increasing size (based on its number of parameters and size of training data) of Language models (LMs) like BERT and its variants, T-NLG, GPT-2/3, etc. Language Models (LMs) are trained on string prediction tasks: that is, predicting the likelihood of a token (character, word, or string) given either its preceding context or its surrounding context (in bidirectional and masked LMs). Such systems are unsupervised while training, later fine-tuned for specific tasks, and, when deployed, take a text as input, commonly outputting scores or string predictions. Increasing the number of model params/larger architecture did not yield noticeable increases for LSTMs; however, Transformers have continuously benefited from it. This trend of increasingly large LMs can be expected to continue as long as they correlate with an increase in performance. Even the models like DistilBERT and ALBERT, which are reduced form of BERT using techniques such as knowledge distillation, quantization, etc., still rely on large quantities of data and significant computing resources.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fegxpnjbf9jgx8jwlgy0r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fegxpnjbf9jgx8jwlgy0r.png" alt="Table 1" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  What are the Issues?
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Environmental Costs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Training a single BERT base model (without hyperparameter tuning) on GPUs was estimated to require as much energy as a trans-American flight (~1900 CO2e).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffbmqoc8kp3zgtwd4lgct.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffbmqoc8kp3zgtwd4lgct.png" alt="Table 2" width="700" height="258"&gt;&lt;/a&gt;&lt;/p&gt;
Source: https://arxiv.org/pdf/1906.02243.pdf



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;For the task of machine translation where large LMs have resulted in performance gains, they estimate that an increase in 0.1 BLEU scores using neural architecture search for English to German translation results in an increase of $150,000 compute cost in addition to the carbon emissions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Most sampled papers from ACL 2018, NeurIPS 2018, and CVPR 2019 claim accuracy improvements alone as primary contributions to the field. None focused on measures of efficiency as primary contributions, which should be prioritized as the evaluation metric.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Financial Costs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The amount of compute used to train the largest deep learning models (for NLP and other applications) has increased 300,000x in 6 years, increasing at a far higher pace than Moore’s Law. This, in turn, erects barriers to entry, limiting who can contribute to this research area and which languages can benefit from the most advanced techniques.&lt;/li&gt;
&lt;li&gt;Many LMs are deployed in industrial or other settings where the cost of inference might greatly outweigh that of training in the long run.&lt;/li&gt;
&lt;li&gt;While some language technology is genuinely designed to benefit marginalized communities, most language technology is built to serve the needs of those who already have the most privilege in society.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Risks associated with Large Training Data
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Starting with who is contributing to these Internet text collections, we see that Internet access itself is not evenly distributed, resulting in Internet data overrepresenting younger users and those from developed countries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A limited set of subpopulations continue to easily add data, sharing their thoughts and developing platforms that are inclusive of their worldviews; this systemic pattern, in turn, worsens diversity and inclusion within Internet-based communication, creating a feedback loop that lessens the impact of data from underrepresented populations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Thus at each step, from initial participation in Internet fora to continued presence there to the collection and finally the filtering of training data, current practice privileges the hegemonic viewpoint. In accepting large amounts of web text as ‘representative’ of ‘all’ of humanity, we risk perpetuating dominant viewpoints, increasing power imbalances, and further reifying inequality.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An important caveat is that social movements that are poorly documented and do not receive significant media attention will not be captured at all. As a result, the data underpinning LMs stands to misrepresent social movements and disproportionately align with existing power regimes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Developing and shifting frames stand to be learned in incomplete ways or lost in the big-ness of data used to train large LMs — particularly if the training data isn’t continually updated. Given the compute costs alone of training large LMs, it likely isn’t feasible for even large corporations to fully retrain them frequently enough to keep up with the kind of language change discussed here.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Components like toxicity classifiers would need culturally appropriate training data for each audit context, and even still, we may miss marginalized identities if we don’t know what to audit for.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When we rely on ever-larger datasets, we risk incurring documentation debt, i.e., putting ourselves in a situation where the datasets are undocumented and too large to document post hoc. While documentation allows for potential accountability, undocumented training data perpetuates harm without recourse.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Risks due to misdirected Research Effort
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;(specifically around the application of LMs for tasks intended to test for Natural Language Understanding)&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The allocation of research effort towards measuring how well BERT and its kin do on both existing and new benchmarks brings with it an opportunity cost, on the one hand in terms of time not spent applying to meaning capturing approaches to meaning sensitive tasks, and on the other hand in terms of time not spent exploring more effective ways of building technology with datasets of a size that can be carefully curated and available for a broader set of languages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;From a theoretical perspective, languages are systems of signs, i.e., pairings of form and meaning. But the training data for LMs is only a form; they do not have access to meaning. Therefore, claims about model abilities must be carefully characterized.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;LMs ties us to certain epistemological and methodological commitments. Either i) we commit ourselves to a noisy-channel interpretation of the task, ii) we abandon any goals of theoretical insight into tasks and treat LMs as “just some convenient technology,” or iii) we implicitly assume a certain statistical relationship — known to be invalid — between inputs, outputs, and meanings.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;From the perspective of work on language technology, it is far from clear that all of the effort being put into using large LMs to ‘beat’ tasks designed to test natural language understanding, and all of the effort to create new such tasks, once the LMs have bulldozed the existing ones, brings us any closer to long-term goals of general language understanding systems. If a large LM, endowed with hundreds of billions of parameters and trained on a very large dataset, can manipulate linguistic form well enough to cheat its way through tests meant to require language understanding, have we learned anything of value about building machine language understanding?&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Risks and Harms of deploying LMs at Scale
&lt;/h3&gt;

&lt;p&gt;Human language usage occurs between individuals who share common ground and are mutually aware of that sharing (and its extent), who have communicative intents that they use language to convey, and who model each others’ mental states as they communicate. As such, human communication relies on the interpretation of implicit meaning conveyed between individuals. The fact that human-human communication is a jointly constructed activity is most clearly true in co-situated spoken or signed communication. Still, we use the same facilities for producing language that is intended for audiences not co-present with us (readers, listeners, watchers at a distance in time or space) and in interpreting such language when we encounter it. It must follow that even when we don’t know the person who generated the language we are interpreting, we build a partial model of who they are and what common ground we think they share with us and use this in interpreting their words.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Text generated by an LM is not grounded in communicative intent, any model of the world, or any model of the reader’s state of mind. It can’t have been because the training data never included sharing thoughts with a listener, nor does the machine have the ability to do that. This can seem counter-intuitive given the increasingly fluent qualities of automatically generated text. Still, we have to account that our perception of natural language text, regardless of how it was generated, is mediated by our own linguistic competence. Our predisposition to interpret communicative acts as conveying coherent meaning and intent, whether or not they do. The problem is, if one side of the communication does not have meaning, then the comprehension of the implicit meaning is an illusion arising from our singular human understanding of language (independent of the model). Contrary to how it may seem when we observe its output, an LM is a system for haphazardly stitching together sequences of linguistic forms observed in its vast training data, according to probabilistic information about how they combine, but without any reference to meaning: a stochastic parrot.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;LMs producing text will reproduce and even amplify the encoded biases in their training data. Thus the risk is that people disseminate text generated by LMs, meaning more text in the world that reinforces and propagates stereotypes and problematic associations, both to humans who encounter the text and future LMs trained on training sets that ingested the previous generation LM’s output.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Miscreants can take advantage of the ability of large LMs to produce large quantities of seemingly coherent texts on specific topics on demand in cases where those deploying the LM have no investment in the truth of the generated text.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Risks associated with large LMs during machine translation tasks to produce seemingly coherent text over larger passages could erase cues that might tip users off to translation errors in longer passages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Risks associated with the fact that LMs with huge numbers of parameters model their training data very closely and can be prompted to output specific information from that training data, such as personally identifiable information.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Recommended Paths Ahead!
&lt;/h1&gt;

&lt;p&gt;We should consider our research time and effort a valuable resource to be spent to the extent possible on research projects that are built towards a technological ecosystem whose benefits are at least evenly distributed. Each of the below mentioned approaches take time and are most valuable when applied early in the development process as part of a conceptual investigation of values and harms rather than a post hoc discovery of risks.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Considering Environmental and Financial Impacts&lt;/strong&gt;: We should consider the financial and environmental costs of model development upfront before deciding on a course of an investigation. The resources needed to train and tune state-of-the-art models stand to increase economic inequities unless researchers incorporate energy and compute efficiency in their model evaluations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Doing careful data curation and documentation&lt;/strong&gt;: Significant time should be spent on assembling datasets suited for the tasks at hand rather than ingesting massive amounts of data from convenient or easily-scraped Internet sources. Simply turning to massive dataset size as a strategy for being inclusive of diverse viewpoints is doomed to failure. As a part of careful data collection practices, researchers must adopt frameworks such as (&lt;a href="https://www.aclweb.org/anthology/Q18-1041.pdf" rel="noopener noreferrer"&gt;Data Statements for Natural Language Processing&lt;/a&gt;, &lt;a href="https://arxiv.org/pdf/1803.09010.pdf" rel="noopener noreferrer"&gt;Datasheets for Datasets&lt;/a&gt;, &lt;a href="https://arxiv.org/pdf/1810.03993.pdf" rel="noopener noreferrer"&gt;Model Cards for Model Reporting&lt;/a&gt;) to describe the uses for which their models are suited and benchmark evaluations for a variety of conditions. This involves providing thorough documentation on the data used in model building, including the motivations underlying data selection and collection processes. This documentation should reflect and indicate researchers’ goals, values, and motivations in assembling data and creating a given model.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Engaging with stakeholders early in the design process&lt;/strong&gt;: It should note potential users and stakeholders, particularly those that stand to be negatively impacted by model errors or misuse. An exploration of stakeholders for likely use cases can still be informative around potential risks, even when there is no way to guarantee that all use cases can be explored.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Exploring multiple possible paths towards long-term goals&lt;/strong&gt;: We also advocate for a re-alignment of research goals: Where much effort has been allocated to making models (and their training data) bigger and to achieving ever higher scores on leaderboards often featuring artificial tasks, we believe there is more to be gained by focusing on understanding how machines are achieving the tasks in question and how they will form part of socio-technical systems. To that end, LM development may benefit from guided evaluation exercises such as pre-mortems.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Keeping alert to dual-use scenarios&lt;/strong&gt;: For researchers working with LMs, the value-sensitive design is poised to help throughout the development process in identifying whose values are expressed and supported through technology and, subsequently, how a lack of support might result in harm.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Allocating research effort to mitigate harm&lt;/strong&gt;: Finally, we would like to consider use cases of large LMs that have specifically served marginalized populations. We should consider cases such as: Could LMs be built in such a way that synthetic text generated with them would be watermarked and thus detectable? Are there policy approaches that could effectively regulate their use?&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We hope these considerations encourage NLP researchers to direct resources and effort into techniques for approaching NLP tasks effectively without being endlessly data-hungry. But beyond that, we call on the field to recognize that applications that aim to mimic humans bring a risk of extreme harm believably. Work on synthetic human behavior is a bright line in ethical AI development, where downstream effects need to be understood and modeled to block foreseeable harm to society and different social groups.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Please find the original article &lt;a href="https://faculty.washington.edu/ebender/papers/Stochastic_Parrots.pdf" rel="noopener noreferrer"&gt;here&lt;/a&gt; and refer to its references not mentioned above. If this post saved your time, don’t forget to appreciate it.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>deeplearning</category>
      <category>machinelearning</category>
      <category>ai</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Top 10 Deep Learning Breakthroughs - Deep Reinforcement Learning</title>
      <dc:creator>Zoheb Abai</dc:creator>
      <pubDate>Sun, 06 Sep 2020 15:05:37 +0000</pubDate>
      <link>https://dev.to/zohebabai/top-10-deep-learning-breakthroughs-deep-reinforcement-learning-1nmc</link>
      <guid>https://dev.to/zohebabai/top-10-deep-learning-breakthroughs-deep-reinforcement-learning-1nmc</guid>
      <description>&lt;p&gt;&lt;strong&gt;Have you watched this?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/WXuK6gekU1Y"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Or this?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/tfb6aEUMC04"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Watch these videos as per your convenience and go through this blog to understand (without much mathematical sophistication) how we arrived at this stage.&lt;/p&gt;

&lt;p&gt;If you have already watched these videos I totally understand your excitement. This breakthrough came in 2013 after the &lt;a href="https://dev.to/zohebabai/top-10-deep-learning-breakthroughs-alexnet-1670"&gt;AlexNet&lt;/a&gt; in a paper titled &lt;a href="https://arxiv.org/pdf/1312.5602.pdf" rel="noopener noreferrer"&gt;Playing Atari with Deep Reinforcement Learning&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Preliminaries
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Machine Learning provides automated methods that can detect patterns in data and use them to achieve some tasks&lt;/strong&gt;. Generally, ML tasks are categorized into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Supervised Learning - the task of learning from labeled datasets.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Unsupervised Learning - the task of drawing inferences from&lt;br&gt;
unlabeled datasets&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reinforcement Learning - the task of maximizing cumulative rewards from sequences of action taken by agents while interacting with its environment&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will be discussing on RL here, so let's understand an RL problem by imagining a robot mouse maze world.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F4t7p4latvd4urs25nb5p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F4t7p4latvd4urs25nb5p.png" alt="Alt Text" width="361" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The robot mouse is the &lt;strong&gt;agent&lt;/strong&gt;, Maze is the &lt;strong&gt;environment&lt;/strong&gt; with food at few locations as positive &lt;strong&gt;rewards&lt;/strong&gt; and electricity at other locations as negative rewards. At every moment it can &lt;strong&gt;observe&lt;/strong&gt; the full state of the maze to decide about the &lt;strong&gt;actions&lt;/strong&gt; (such as turn left/right and move forward) to consider next. The &lt;strong&gt;goal&lt;/strong&gt; is to allow our robot to learn on its own to find as much food as possible while avoiding an electric shock whenever possible. &lt;/p&gt;

&lt;p&gt;To solve these tasks, ML exploits the idea of the &lt;em&gt;function&lt;br&gt;
approximators&lt;/em&gt;. Since the 1950s we know of several types of function approximators such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.ru.ac.bd/stat/wp-content/uploads/sites/25/2019/03/301_03_Anderson_An-Introduction-to-Multivariate-Statistical-Analysis-2003.pdf" rel="noopener noreferrer"&gt;Linear Models by Anderson et al. (1958)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://homepages.rpi.edu/~bennek/class/mmld/papers/svn.pdf" rel="noopener noreferrer"&gt;SVMs by Cortes and Vapnik (1995)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://cogns.northwestern.edu/cbmg/LiawAndWiener2002.pdf" rel="noopener noreferrer"&gt;Decisions Tree by Liaw, Wiener, et al. (2002)&lt;/a&gt; and &lt;a href="https://link.springer.com/content/pdf/10.1007/s10994-006-6226-1.pdf" rel="noopener noreferrer"&gt;Geurts et al. (2006)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.cs.ubc.ca/~hutter/EARG.shtml/earg/papers05/rasmussen_gps_in_ml.pdf" rel="noopener noreferrer"&gt;Gaussian Processes by Rasmussen (2004)&lt;/a&gt;
and &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.nature.com/articles/nature14539" rel="noopener noreferrer"&gt;Deep Learning by Yann LeCun, Yoshua Bengio &amp;amp; Geoffrey Hinton (formally introduced in 2015 after networks actually started going deep)&lt;/a&gt; &lt;a href="https://mega.nz/file/moUTBIbZ#tDX3dH43s8825qe8ICSN7uFWw91EUKpzpn6BEBbfWWg" rel="noopener noreferrer"&gt;Read it here&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://deepmind.com/" rel="noopener noreferrer"&gt;DeepMind&lt;/a&gt; pioneered by applying deep learning methods into RL and since then, DRLs have achieved beyond human-level performance across many challenging domains (two of which you saw above).&lt;/p&gt;

&lt;h1&gt;
  
  
  Fundamentals of RL
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frwrp85s9h4ysboo4fmwp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frwrp85s9h4ysboo4fmwp.png" alt="Alt Text" width="435" height="284"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The two major RL entities are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Agent&lt;/strong&gt; -  is a piece of software that implements some &lt;em&gt;policy&lt;/em&gt;. Basically, this policy must decide what action is needed at every time step, given our observations, thus solving a given problem in a more-or-less efficient way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Environment&lt;/strong&gt; - a model of the world which is external to an agent and communicating in limited scope by rewards (obtained from the environment), actions (executed by the agent and given to the environment), and observations (some information besides the rewards that the agent receives from the environment). The state of the environment can change based on the agent's actions. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Actions&lt;/strong&gt;, &lt;strong&gt;Observations&lt;/strong&gt; and &lt;strong&gt;Rewards&lt;/strong&gt; are the communication channels here.&lt;br&gt;
Actions are things that an agent can do in the environment. It can be either discrete or continuous.&lt;/p&gt;

&lt;p&gt;Observations are pieces of information that the environment provides the agent with, like what's going on around them. It may be relevant to the upcoming reward or may not, but it eventually doesn't drive the agent's learning process (as a reward does).&lt;/p&gt;

&lt;p&gt;The purpose of a reward is to give agent feedback about its success, and it's an important central concept in RL. Basically, the term &lt;em&gt;reinforcement&lt;/em&gt; comes from the fact that a reward obtained by an agent should reinforce its behavior in a positive or negative way.&lt;/p&gt;

&lt;p&gt;That's basically the fundamentals of RL. The environment could be an extremely complicated physics model, and an agent could easily be a large neural network implementing the latest RL algorithm, but the basic pattern stays the same: &lt;em&gt;on every step, an agent takes some observations from the environment, does its calculations, and selects the action to issue. The result of this action is a reward and a new observation. The final goal is to achieve the largest accumulated reward over its sequence of actions.&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  RL Methods
&lt;/h1&gt;

&lt;p&gt;RL methods are mostly categorized as&lt;/p&gt;

&lt;h3&gt;
  
  
  Model-free or Model-based
&lt;/h3&gt;

&lt;p&gt;Model-free methods: means that the method doesn't build a model of the environment or reward; it just directly connects observations to actions (or values that are related to actions). In other words, the agent takes current observations and does some computations on them, and the result is the action that it should take. These methods are usually easier to train.&lt;br&gt;
In contrast, &lt;br&gt;
Model-based methods: try to predict what the next observation and/or reward will be. Based on this prediction, the agent is trying to choose the best possible action to take, very often making such predictions multiple times to look more and more steps into the future.&lt;/p&gt;

&lt;h3&gt;
  
  
  Policy-based or Value-based
&lt;/h3&gt;

&lt;p&gt;Policy-based methods: are directly approximating the policy of the agent, that is, what actions the agent should carry out at every step. The policy is usually represented by a probability distribution over the available actions.&lt;br&gt;
In contrast,&lt;br&gt;
Value-based methods: here instead of the probability of actions, the agent calculates the value of every possible action and chooses the action with the best value.&lt;/p&gt;

&lt;h3&gt;
  
  
  On-policy or Off-policy
&lt;/h3&gt;

&lt;p&gt;On-policy methods: heavily depend on the training data to be sampled according to the current policy we're updating.&lt;br&gt;
In contrast,&lt;br&gt;
Off-policy methods: the ability of the method to learn on old historical data obtained by a previous version of the agent.&lt;/p&gt;

&lt;h1&gt;
  
  
  Cross-Entropy
&lt;/h1&gt;

&lt;p&gt;One of the basic RL methods is &lt;strong&gt;cross-entropy&lt;/strong&gt; - a model-free, policy-based, and on-policy method which simply means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It doesn't build any model of the environment; it just says to the agent what to do at every step&lt;/li&gt;
&lt;li&gt;It approximates the policy of the agent&lt;/li&gt;
&lt;li&gt;It requires fresh data obtained from the environment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In practice, the agent needs to pass an observation from the environment to the network, get probability distribution over actions (i.e. policy), and perform random sampling using probability distribution to get an action to carry out (similar to ML classification task). At the beginning of the training when our weights are random, the agent behaves randomly. After the agent gets an action to issue, it fires the action to the environment and obtains the next observation and reward for the last action. This experience of our agent is called &lt;strong&gt;episodes&lt;/strong&gt;. Thus, the loop of such episodes continues.&lt;/p&gt;

&lt;p&gt;But there are several limitations of the cross-entropy method:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For training, our episodes have to be short&lt;/li&gt;
&lt;li&gt;The total reward for the episodes should have enough variability to separate good episodes from bad ones&lt;/li&gt;
&lt;li&gt;There is no intermediate indication about whether the agent has succeeded or failed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also, for interesting environments, the optimal policy is much harder to formulate and it's even harder to prove their optimality.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Bellman Equation of optimality
&lt;/h1&gt;

&lt;p&gt;Richard Bellman proved that &lt;em&gt;the optimal value of the state is equal to the action, which gives us the maximum possible expected immediate reward, plus discounted long-term reward for the next state&lt;/em&gt;. The Bellman optimality equation of value &lt;code&gt;V&lt;/code&gt; of state &lt;code&gt;S0&lt;/code&gt;  is given as&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fx2tmpsu4iwggpixt007b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fx2tmpsu4iwggpixt007b.png" alt="Alt Text" width="436" height="59"&gt;&lt;/a&gt;&lt;/p&gt;
where r is respective rewards for states s and action a and 𝛾 a discount factor between 0 and 1, p(a,i-&amp;gt;j) means the probability of action a, issued in state i, to end up in state j



&lt;p&gt;You may also notice that this definition is recursive: the value of the state is defined via the values of immediately reachable states. These values not only give us the best reward that we can obtain, but they basically give us the optimal policy to obtain that reward: if our agent knows the value for every state, then it automatically knows how to gather all this reward.&lt;/p&gt;

&lt;p&gt;Now the value of action &lt;code&gt;Q(s, a)&lt;/code&gt; which equals the total reward we can get by executing action &lt;code&gt;a&lt;/code&gt; in state &lt;code&gt;s&lt;/code&gt; is defined as&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1ey4hx9vbuybns2ydu75.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1ey4hx9vbuybns2ydu75.png" alt="Alt Text" width="385" height="59"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can also define &lt;code&gt;V(s)&lt;/code&gt; via &lt;code&gt;Q(s, a)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9gnds3yvsk0ff64yd5iw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9gnds3yvsk0ff64yd5iw.png" alt="Alt Text" width="132" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And finally, we can express &lt;code&gt;Q(s, a)&lt;/code&gt; via itself&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxl9fvytafbj2a8bh0ti7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxl9fvytafbj2a8bh0ti7.png" alt="Alt Text" width="257" height="60"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A general procedure to calculate &lt;code&gt;Q(s, a)&lt;/code&gt; is the &lt;strong&gt;value iteration algorithm&lt;/strong&gt; which allows us to numerically calculate the values of actions with known transition probabilities and rewards includes the following steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Initialize all &lt;code&gt;Q(s, a)&lt;/code&gt; to zero&lt;/li&gt;
&lt;li&gt;For every state &lt;code&gt;s&lt;/code&gt; and every action &lt;code&gt;a&lt;/code&gt; in this state, perform update: &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F331dnf6aqryz7bu2z21h.png" alt="Alt Text" width="313" height="29"&gt;
&lt;/li&gt;
&lt;li&gt;Repeat step 2&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Q-values are much more convenient, as for the agent it's much simpler to make decisions about actions based on Q than based on V. For Q, to choose the action based on the state, the agent just needs to calculate Q for all available actions, using the current state and choose the action with the largest value of Q. To do the same using values of states, the agent needs to know not only values but also probabilities for transitions. In practice, we rarely know them in advance, so the agent needs to estimate transition probabilities for every action and state pair.&lt;/p&gt;

&lt;h1&gt;
  
  
  Deep Q-Learning
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F386r1g1ou2nzqogo7j8t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F386r1g1ou2nzqogo7j8t.png" alt="Alt Text" width="529" height="70"&gt;&lt;/a&gt;&lt;/p&gt;
Five Atari 2600 games : Pong, Breakout, Space Invaders, Seaquest, Beam Rider



&lt;p&gt;In practice, the &lt;strong&gt;value-iteration algorithm&lt;/strong&gt; has several obvious limitations. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The first obvious problem is the count of environment states and our ability to iterate over them. In the Value iteration, we assume that we know all states in our environment in advance, can iterate over them, and can store value approximation associated with the state. &lt;br&gt;
To give you an example of an environment with a much larger number of potential states, let's consider the Atari 2600 game platform (a very popular benchmark among RL researches). Let's calculate the state space for the Atari platform. The resolution of the screen is 210 x 160 pixels, and every pixel has one of 128 colors. So, every frame of the screen has 210 × 160 = 33600 pixels and the total amount of different screens possible is &lt;code&gt;128^33600&lt;/code&gt;, which is slightly more than &lt;code&gt;10^70802&lt;/code&gt;. If we decide to just enumerate all possible states of Atari once, it will take billions of years even for the fastest supercomputer. Also, 99.9% of this job will be a waste of time, as most of the combinations will never be shown during even long gameplay, so we'll never have samples of those states. So, this causes a major limitation for the value iteration method.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The second problem with the value iteration approach is that it limits us to discrete action spaces. Indeed, both &lt;code&gt;Q(s, a)&lt;/code&gt; and &lt;code&gt;V(s)&lt;/code&gt; approximations assume that our actions are a mutually exclusive discrete set, which is not true for continuous control problems where actions can represent continuous variables, such as the angle of a steering wheel. This issue is much more challenging than the first (and I would like to cover it in another blog), so for now, let's assume that we have a discrete count of actions and this count is not large.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To solve the first limitation, we can use states obtained from the environment to update the values of states, which can save us lots of resources. This modification of the Value iteration method is known as &lt;strong&gt;Q-learning&lt;/strong&gt;. But what if those count of the observable set of states is huge (not infinite). For example, Atari games can have a large variety of different screens, so if we decide to use raw pixels as individual states, we'll quickly realize that we have too many states to track and approximate values for. For example, consider the two different situations in a game of Pong where the agent has to act on them differently due to change in single-pixel representing the ball.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fvjdm9jaa80xhw6c8xh07.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fvjdm9jaa80xhw6c8xh07.png" alt="Alt Text" width="439" height="264"&gt;&lt;/a&gt;&lt;/p&gt;
On left agent (green paddle) doesn't need to move but on right it has quickly movie to avoid losing a point 



&lt;p&gt;As a solution to this problem, we can use a nonlinear representation that maps both state and action onto a value, which can be trained using a &lt;strong&gt;deep neural network&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Cut short, There are many tips and tricks that researchers have discovered to make Deep Q-Networks training more stable and efficient. However, tricks like &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;𝟄-greedy: switching between random and Q policy using the probability hyperparameter 𝟄. By varying, we can select the ratio of random actions. The usual practice is to start with = 1.0 (100% random actions and that's better as it gives us more uniformly distributed information about the environment states) and slowly decrease it to some small value such as 5% or 2% of random actions. It helps both to explore the environment in the beginning and to stick to a good policy at the end of the training. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;replay buffer: use a large buffer of our past experience and sample training data from it, instead of using our latest experience. It allows us to train on more-or-less independent data, but data will still be fresh enough to train on samples generated by our recent policy.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;target network: To make training more stable we keep a copy of our network and use it for the &lt;code&gt;Q(s′, a′)&lt;/code&gt; value in the Bellman equation. This network is synchronized with our main network only periodically, for example, once in N steps (where N is usually quite a large hyperparameter, such as 1k or 10k training iterations).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;formed the basis that allowed &lt;a href="https://deepmind.com/" rel="noopener noreferrer"&gt;DeepMind&lt;/a&gt; to successfully train a DQN on a set of 7 Atari games and demonstrate the efficiency of this approach applied to complicated environments. Later, at the beginning of 2015, they &lt;a href="https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwi_ntne2NTrAhXr6XMBHXIyA18QFjABegQIBRAB&amp;amp;url=https%3A%2F%2Fweb.stanford.edu%2Fclass%2Fpsych209%2FReadings%2FMnihEtAlHassibis15NatureControlDeepRL.pdf&amp;amp;usg=AOvVaw0uqHxqo8Yyn3cmySQWqe8Z" rel="noopener noreferrer"&gt;published a revised version of the 2013 paper&lt;/a&gt;, on 49 different games.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fl05829kwfpuu7wabxurz.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fl05829kwfpuu7wabxurz.gif" alt="Alt Text" width="295" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The final form of the DQN algorithm used in the paper contains the following steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Initialize parameters for &lt;code&gt;Q(s, a)&lt;/code&gt; and &lt;code&gt;ℚ(s, a)&lt;/code&gt; with random weights, 𝟄 -&amp;gt; 1.0, and empty replay buffer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;With probability 𝟄, select a random action &lt;code&gt;a&lt;/code&gt;, otherwise &lt;code&gt;a = argmax_a Q(s, a)&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Execute action &lt;code&gt;a&lt;/code&gt; in an emulator and observe reward &lt;code&gt;r&lt;/code&gt; and the next state&lt;code&gt;s'&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Store transition &lt;code&gt;(s, a, r, s')&lt;/code&gt; in the replay buffer&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Sample a random mini-batch of transitions from the replay buffer&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For every transition in the buffer, calculate target &lt;code&gt;y = r&lt;/code&gt; if the episode has ended at this step or &lt;code&gt;y = r + 𝛾 max ℚ(s', a')&lt;/code&gt;, otherwise&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Calculate loss, ℒ = (Q(s, a) - y)^2&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Update Q(s, a) using the &lt;a href="https://dev.to/zohebabai/top-10-deep-learning-breakthroughs-family-of-sngd-optimizers-4ek6"&gt;SGD optimizer&lt;/a&gt; algorithm by minimizing the loss in respect to model parameters&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Every N steps copy weights from Q to ℚ&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Repeat from step 2 until converged.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Remarks
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fc74t15xy6ryzrz00jfs4.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fc74t15xy6ryzrz00jfs4.gif" alt="Alt Text" width="1024" height="1024"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This paper had a significant effect on the Reinforcement Learning field by demonstrating that, despite common belief, it's possible to use nonlinear approximators in RL. This proof of concept stimulated large interest in the deep Q-learning field in particular and in deep RL in general. Since 2015, many improvements have been proposed, along with tweaks to the basic architecture, which significantly improves convergence, stability, and sample efficiency of the basic DQN invented by DeepMind. In January 2016, DeepMind published a paper titled &lt;a href="https://storage.googleapis.com/deepmind-media/alphago/AlphaGoNaturePaper.pdf" rel="noopener noreferrer"&gt;Mastering the game of Go with deep neural networks and tree search&lt;/a&gt; which presented the AlphaGo version which defeated European Go Champion Fan Hui. Very conveniently, again in October 2017, they published a paper titled &lt;a href="https://arxiv.org/pdf/1710.02298" rel="noopener noreferrer"&gt;Rainbow: Combining Improvements in Deep Reinforcement Learning&lt;/a&gt; which presented the seven most important improvements to DQN reaching SOTA results on Atari Games Arcade. 3 years since, this technology has progressed a lot, has produced some amazing results and shall surely be surprising us in the future.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>beginners</category>
      <category>deeplearning</category>
    </item>
    <item>
      <title>Boost your Colab Notebooks with GCP and AWS Instance in a few minutes</title>
      <dc:creator>Zoheb Abai</dc:creator>
      <pubDate>Fri, 28 Aug 2020 07:56:31 +0000</pubDate>
      <link>https://dev.to/zohebabai/boost-your-colab-notebooks-with-gcp-and-aws-instance-within-a-few-minutes-47ma</link>
      <guid>https://dev.to/zohebabai/boost-your-colab-notebooks-with-gcp-and-aws-instance-within-a-few-minutes-47ma</guid>
      <description>&lt;p&gt;For Data Scientists, Notebooks have become the 'de facto' tool while working on a project. Whether they perform EDA on the initially available dataset or begin with some data preprocessing steps or experiment with different models and libraries, notebook is the one they begin with. In this respect, &lt;a href="https://colab.research.google.com/" rel="noopener noreferrer"&gt;Colab Notebooks&lt;/a&gt; are second to none - Easily available with almost all the libraries pre-installed, efficient enough with readily available GPUs and TPUs, can be saved on multiple locations from Drive to GitHub and also shared live with colleagues.&lt;/p&gt;

&lt;p&gt;But sometimes you might require resources more than Colab typically offers, for example, you might require &lt;strong&gt;multi-GPUs&lt;/strong&gt; or &lt;strong&gt;higher GPU RAM&lt;/strong&gt; or maybe &lt;strong&gt;a better GPU&lt;/strong&gt; or &lt;strong&gt;more than 12 hours of runtime&lt;/strong&gt; (default) to conclude a successful DS experiments in your notebook. In this blog, I shall cover how to upgrade your Colab in a few minutes, receiving all the above mentioned benefits, without moving your code elsewhere, having Google Cloud Platform or Amazon Web Service Instance as its backend.&lt;/p&gt;

&lt;h1&gt;
  
  
  Google Cloud Platform
&lt;/h1&gt;

&lt;p&gt;When you first sign up on GCP, you will have $300 free credits. &lt;/p&gt;

&lt;h3&gt;
  
  
  Request an increase in GPU Quota
&lt;/h3&gt;

&lt;p&gt;Your account typically does not come with GPU quota. You have to explicitly request for it under &lt;strong&gt;IAM Admin &amp;gt; Quotas&lt;/strong&gt;.&lt;br&gt;
You should change your quota of &lt;strong&gt;GPU (all regions)&lt;/strong&gt;. Filter the Metric to GPU (all regions), increase its limit&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frsctfqaele0juk6oibhu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frsctfqaele0juk6oibhu.png" alt="Alt Text" width="800" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And Submit a request. Wait until GCP sends you a second email (the first email is just to notify you that they received the request). It would take a couple of minutes (or hours maybe) for them to approve.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create an Instance of your choice
&lt;/h2&gt;

&lt;p&gt;Now go to &lt;strong&gt;Compute Engine &amp;gt; VM instances&lt;/strong&gt; and create an instance&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6cb5yac70wfbig2ykz8w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6cb5yac70wfbig2ykz8w.png" alt="Alt Text" width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fill the details as shown below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fghlh199obqc2ff80ohk0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fghlh199obqc2ff80ohk0.png" alt="Alt Text" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcndwpyn002epqcjbhyg3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcndwpyn002epqcjbhyg3.png" alt="Alt Text" width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbh9sqimgkgmcgfemxtix.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbh9sqimgkgmcgfemxtix.png" alt="Alt Text" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Furgqzgqw8mlslw3oxjiy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Furgqzgqw8mlslw3oxjiy.png" alt="Alt Text" width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyitkwbmjvkq876ffbcef.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyitkwbmjvkq876ffbcef.png" alt="Alt Text" width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And click &lt;strong&gt;Create&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Also, do this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ftdaevvcdk969z7on16gx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ftdaevvcdk969z7on16gx.png" alt="Alt Text" width="697" height="385"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once your instance is up, it shall display similar to this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F84fvgfl0apt1i46o641k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F84fvgfl0apt1i46o641k.png" alt="Alt Text" width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Amazon Web Services
&lt;/h1&gt;

&lt;p&gt;If you are using AWS for the first time, you can apply for receiving $300 free credits. &lt;/p&gt;

&lt;h3&gt;
  
  
  Request an increase in GPU Quota
&lt;/h3&gt;

&lt;p&gt;Your account typically does not come with GPU quota. You have to explicitly request for it under &lt;strong&gt;Support &amp;gt; Create Case &amp;gt; Service Limit Increase&lt;/strong&gt;. You should increase EC2 All P instances in your region by limit 1. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fv4ejanx8rpq1up7e1kpq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fv4ejanx8rpq1up7e1kpq.png" alt="Alt Text" width="562" height="700"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Write a short description of the use case and submit a request. Wait until AWS replies to you back. It would take a couple of minutes (or hours maybe) for them to approve.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create an Instance of your choice
&lt;/h2&gt;

&lt;p&gt;Now go to &lt;strong&gt;EC2 &amp;gt; Launch instance&lt;/strong&gt; and create an instance&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhyqhfkhjr9knmfm1azzf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhyqhfkhjr9knmfm1azzf.png" alt="Alt Text" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Follow the steps as shown below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0mknlmpru643r5makenl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0mknlmpru643r5makenl.png" alt="Alt Text" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F58vztaz7ya5sd8gl3eww.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F58vztaz7ya5sd8gl3eww.png" alt="Alt Text" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F96or3m81rkktaq9zzaly.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F96or3m81rkktaq9zzaly.png" alt="Alt Text" width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7wqgztspctcsrfugg69y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7wqgztspctcsrfugg69y.png" alt="Alt Text" width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6covf3nruy8lih6rwft9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6covf3nruy8lih6rwft9.png" alt="Alt Text" width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fm233p45raxn2b8p7046d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fm233p45raxn2b8p7046d.png" alt="Alt Text" width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Download the key pair in your local storage (and maybe copy it into a secure location too). Tick the box and click &lt;strong&gt;Launch Instances&lt;/strong&gt;. It shall show similar to this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fq556ly9f34nh8mubcz2s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fq556ly9f34nh8mubcz2s.png" alt="Alt Text" width="800" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once your instance is up, it shall display similar to this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxl8q0m7hgbn8a74n34hv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxl8q0m7hgbn8a74n34hv.png" alt="Alt Text" width="800" height="488"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Command Line Terminal and Colab
&lt;/h1&gt;

&lt;h2&gt;
  
  
  For GCP:
&lt;/h2&gt;

&lt;p&gt;Install &lt;a href="https://cloud.google.com/sdk/docs/quickstarts" rel="noopener noreferrer"&gt;Google Cloud SDK using the quick start&lt;/a&gt; for your operating system.&lt;/p&gt;

&lt;p&gt;Once Google cloud is set up, initialize GCloud SDK for your Google account: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;gcloud init&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now Connect to your server and forward your port:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;gcloud beta compute ssh --zone "us-central1-a" "colab-backend" --project "myfirstproject" -- -L 8888:localhost:8888&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  For AWS:
&lt;/h2&gt;

&lt;p&gt;Go to the directory where your EC2 security key is located and run&lt;/p&gt;

&lt;p&gt;&lt;code&gt;chmod 0400 awsec2keypair1.pem&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Next,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ssh -L localhost:8888:localhost:8888 -i "awsec2keypair1.pem" ubuntu@ec2-33-142-118-69.compute-1.amazonaws.com&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Common for both GCP &amp;amp; AWS:
&lt;/h2&gt;

&lt;p&gt;First make sure this is installed: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip install --upgrade jupyter_http_over_ws&amp;gt;=0.0.1a3 &amp;amp;&amp;amp; \&lt;br&gt;
  jupyter serverextension enable --py jupyter_http_over_ws&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For AWS (not required for GCP):&lt;/strong&gt; Before launching notebook please activate the environment:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;source activate pytorch_p36&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;you can check envs list by running &lt;code&gt;conda info --envs&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finally, launch your Jupyter notebook:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;jupyter notebook \&lt;br&gt;
  --NotebookApp.allow_origin='https://colab.research.google.com' \&lt;br&gt;
  --port=8888 \&lt;br&gt;
  --NotebookApp.port_retries=0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It shall display similar to this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frso2rdksszq15ykcpwiz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frso2rdksszq15ykcpwiz.png" alt="Alt Text" width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy the notebook link, go to Colab and follow these steps:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2gyni8dph5o3hpyqnqvb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2gyni8dph5o3hpyqnqvb.png" alt="Alt Text" width="800" height="297"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9s6jmpkw933xfzo7ib4x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9s6jmpkw933xfzo7ib4x.png" alt="Alt Text" width="800" height="370"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and click &lt;strong&gt;Connect&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To check if GCP/AWS backend is integrated:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu12mibrdg8943pfq0r00.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu12mibrdg8943pfq0r00.png" alt="Alt Text" width="800" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: Google Colab currently doesn’t support integration with Google Drive while connected to a local runtime.&lt;/p&gt;

&lt;p&gt;And Voilà! Your &lt;strong&gt;SUPER-Colab&lt;/strong&gt; is ready!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8c547ysatg5oe6r5gxyt.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8c547ysatg5oe6r5gxyt.gif" alt="Alt Text" width="328" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important: Don't forget to stop your GPU/AWS instance once you are done.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Let me know in the comments if you face any issue. &lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>beginners</category>
      <category>productivity</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Step-by-Step Instructions for Testing your GitHub Python Project using GitHub Actions</title>
      <dc:creator>Zoheb Abai</dc:creator>
      <pubDate>Sun, 23 Aug 2020 04:23:11 +0000</pubDate>
      <link>https://dev.to/zohebabai/step-by-step-instructions-for-testing-your-github-python-project-using-github-actions-227b</link>
      <guid>https://dev.to/zohebabai/step-by-step-instructions-for-testing-your-github-python-project-using-github-actions-227b</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/l6fV09z5XHk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Here is the complete step-by-step video tutorial for creating a python project and testing it automatically on every commit using GitHub actions. This can be a useful addition to your project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ZohebAbai/python_test_repo" rel="noopener noreferrer"&gt;GitHub Repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This tutorial was created for autograding python assignments in GitHub Classroom&lt;/em&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>tutorial</category>
      <category>python</category>
      <category>github</category>
    </item>
    <item>
      <title>A Decade of Deep CNN Archs. - GoogLeNet (ILSVRC Winner 2014)</title>
      <dc:creator>Zoheb Abai</dc:creator>
      <pubDate>Sun, 16 Aug 2020 05:49:39 +0000</pubDate>
      <link>https://dev.to/zohebabai/googlenet-ilsvrc-winner-2014-211e</link>
      <guid>https://dev.to/zohebabai/googlenet-ilsvrc-winner-2014-211e</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6kcfhsuxcqq0z9slxygq.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6kcfhsuxcqq0z9slxygq.jpg" alt="Inception" width="400" height="226"&gt;&lt;/a&gt;&lt;/p&gt;
The meme from which it derived its name



&lt;p&gt;Until 2014, CNN architectures had a standard design:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Stacked convolutional layers with ReLU activations
2. Optionally followed by contrast normalization and max-pooling and dropouts to address the problem of overfitting
3. Followed by one or more fully connected layers at the end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Variants of this design were prevalent in the image classification literature and had yielded the best results on MNIST and CIFAR10/100 datasets. On the ImageNet classification challenge dataset the recent trend had been to increase &lt;em&gt;the number of layers (depth)&lt;/em&gt; and &lt;em&gt;number of units at each level (width)&lt;/em&gt; blindly. Despite trends, taking inspiration and guidance from the theoretical work done by &lt;a href="https://arxiv.org/pdf/1310.6343.pdf" rel="noopener noreferrer"&gt;Arora et al.&lt;/a&gt; GoogLeNet takes a slightly different route for its architectural design.&lt;/p&gt;

&lt;h2&gt;
  
  
  Major Drawbacks of Design Trend for a Bigger Size
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;A large number of parameters - which makes the enlarged network more prone to overfitting, especially if the number of labeled examples in the training set is limited.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Increased use of computational resources - any uniform increase in the number of units in two consecutive convolutional layers, results in a quadratic increase in computation. The efficient distribution of computing resources is always preferred to an indiscriminate increase in size since practically the computational budget is always finite.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Approach
&lt;/h2&gt;

&lt;p&gt;The main result of a theoretical study performed by &lt;a href="https://arxiv.org/pdf/1310.6343.pdf" rel="noopener noreferrer"&gt;Aurora et al.&lt;/a&gt; states that if the probability distribution of the dataset is representable by a large, very sparse deep neural network, then the optimal network topology can be constructed layer-by-layer by analyzing the correlation statistics of the activations of the last layer and clustering neurons with highly correlated outputs. The statement resonates with the well known &lt;strong&gt;Hebbian principle&lt;/strong&gt; – &lt;em&gt;neurons that fire together, wire together.&lt;/em&gt;&lt;br&gt;
In short, the approach as suggested by the theory was to build a non-uniform sparsely connected architecture that make use of the extra sparsity, even at the filter level. But since &lt;a href="https://dev.to/zohebabai/alexnet-ilsvrc-winner-2012-3cfo"&gt;AlexNet&lt;/a&gt;, to better optimize parallel computing, convolutions were implemented as collections of dense connections to the patches in the earlier layer. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fou1poza6xeamarviii40.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fou1poza6xeamarviii40.jpg" alt="sparse vs dense" width="638" height="638"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So based on suggestions by &lt;a href="https://www.cc.gatech.edu/~umit/papers/Catalyurek10-SISC.pdf" rel="noopener noreferrer"&gt;Çatalyürek et al.&lt;/a&gt; to obtain SOTA performance for sparse matrix multiplication, authors clustered sparse matrices into relatively dense submatrices, thus approximating an optimal local sparse structure in a CNN layer (Inception module) and repeating it spatially all over.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9q4r8jqiikm7m6wzucqa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9q4r8jqiikm7m6wzucqa.png" alt="Inception naive" width="365" height="215"&gt;&lt;/a&gt;&lt;/p&gt;
Naive inception module



&lt;h2&gt;
  
  
  Architectural Details
&lt;/h2&gt;

&lt;p&gt;One big problem with this stacked inception module is that even a modest number of 5×5 convolutions would be prohibitively expensive on top of a convolutional layer with numerous filters. This problem becomes even more pronounced once pooling units are added. Even while the architecture might cover the optimal sparse structure, it would do that very inefficiently; the merging of the output of the pooling layer with the outputs of convolutional layers would definitely lead to a computational blow up within a few stages. &lt;/p&gt;

&lt;p&gt;Thus, authors borrowed Network-in-Network architecture which was proposed by &lt;a href="https://arxiv.org/pdf/1312.4400.pdf" rel="noopener noreferrer"&gt;Lin et al.&lt;/a&gt; to increase the representational power of neural networks. It can be viewed as an additional 1 × 1 convolutional layer followed typically by the ReLU activation. Authors applied it in forms of &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;dimension reductions&lt;/strong&gt; - &lt;em&gt;1×1 convolutions used for computing reductions before the expensive 3×3 and 5×5 convolutions&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;projections&lt;/strong&gt; - &lt;em&gt;1×1 convolutions used for shielding a large number of input filters of the last stage to the next after max-pooling&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;wherever the computational requirements would increase too much (computational bottlenecks). This allows for not just increasing the depth, but also the width of our networks without a significant performance penalty.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fe3910tbhxjs68xxzvxqr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fe3910tbhxjs68xxzvxqr.png" alt="Inception dim reduce" width="363" height="222"&gt;&lt;/a&gt;&lt;/p&gt;
Inception module with embedded NiN 



&lt;p&gt;Authors also added auxiliary classifiers, taking the form of smaller convolutional networks on top of the output of the Inception (4a) and (4d) modules, expecting to &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. encourage discrimination in the lower stages in the classifier
2. increase the gradient signal that gets propagated back
3. provide additional regularization. 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;During training, their loss gets added to the total loss of the network with a discount weight of 0.3. At inference time, these auxiliary networks were discarded.&lt;/p&gt;

&lt;p&gt;The exact structure of these auxiliary classifiers is as follows: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An average pooling layer with 5×5 filter size and stride 3, resulting in a 4×4×512 output for the (4a), and 4×4×528 for the (4d) stage.&lt;/li&gt;
&lt;li&gt;A 1×1 convolution with 128 filters for dimension reduction and rectified linear activation.&lt;/li&gt;
&lt;li&gt;A fully connected layer with 1024 units and rectified linear activation.&lt;/li&gt;
&lt;li&gt;A dropout layer with a 70% ratio of dropped outputs.&lt;/li&gt;
&lt;li&gt;A linear layer with softmax loss as the classifier (predicting the same 1000 classes as the main classifier, but removed at inference time).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The complete architecture of GoogLeNet:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feovbeh9sbdfd7ncl4dxt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feovbeh9sbdfd7ncl4dxt.png" alt="Complete arch" width="800" height="179"&gt;&lt;/a&gt;&lt;/p&gt;
GoogLeNet Architecture



&lt;h2&gt;
  
  
  Training
&lt;/h2&gt;

&lt;p&gt;It was trained using the &lt;a href="https://papers.nips.cc/paper/4687-large-scale-distributed-deep-networks.pdf" rel="noopener noreferrer"&gt;DistBelief&lt;/a&gt; distributed machine learning system. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Image Transformations&lt;/strong&gt;&lt;br&gt;
Photometric distortions by &lt;a href="https://arxiv.org/pdf/1312.5402.pdf" rel="noopener noreferrer"&gt;Andrew Howard&lt;/a&gt; were useful to combat overfitting to some extent&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Optimizer&lt;/strong&gt;&lt;br&gt;
SGD with Nesterov accelerated gradient of 0.9 momentum &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Learning Rate Manager&lt;/strong&gt;&lt;br&gt;
Decreasing the learning rate by 4% every 8 epochs&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No. of Layers&lt;/strong&gt;&lt;br&gt;
22&lt;/p&gt;

&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Classification
&lt;/h3&gt;

&lt;p&gt;Authors adopted a set of techniques during testing to obtain a higher performance:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Independently trained 7 versions of the same GoogLeNet model, and performed ensemble prediction with them. They only differ in sampling methodologies and the random order in which they see input images.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Adopted a more aggressive cropping approach than that of &lt;a href="https://dev.to/zohebabai/alexnet-ilsvrc-winner-2012-3cfo"&gt;AlexNet&lt;/a&gt;. Specifically, authors resized the images to 4 scales where the shorter dimension (height or width) was 256, 288, 320 and 352 respectively, taking the left, center, and the right square of these resized images (if portrait images, take the top, center and bottom squares). For each square, they then took the 4 corners and the center 224×224 crop as well as the square resized to 224×224, and their mirrored versions. This results in 4×3×6×2 = 144 crops per image. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The softmax probabilities are averaged over multiple crops and overall the individual classifiers to obtain the final prediction. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fgjgg08j3bv9eifif2goc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fgjgg08j3bv9eifif2goc.png" alt="Set for testing" width="685" height="249"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GoogleNet ranked first.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxhubyg7g8kn5pl2vd90i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxhubyg7g8kn5pl2vd90i.png" alt="Ranks" width="550" height="257"&gt;&lt;/a&gt;&lt;/p&gt;
Classification Performance Comparison 



&lt;h3&gt;
  
  
  Object Detection
&lt;/h3&gt;

&lt;p&gt;The approach by GoogLeNet for detection was similar to the &lt;a href="https://arxiv.org/pdf/1311.2524.pdf" rel="noopener noreferrer"&gt;R-CNN&lt;/a&gt; proposed by Girshick et al., but augmented with the Inception model as the region classifier.&lt;br&gt;
&lt;strong&gt;Note:&lt;/strong&gt; &lt;em&gt;R-CNN decomposes the overall detection problem into two subproblems: to first utilize low-level cues such as color and superpixel consistency for potential object proposals in a category-agnostic fashion, and to then use CNN classifiers to identify object categories at those locations.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The region proposal step is improved here by combining the Selective Search approach with multi-box predictions for higher object bounding box recall. To cut down the number of false positives, the superpixel size was increased two folds, improving the mAP (mean average precision) metric by 1% for the single model case. Contrary to R-CNN, they did not use bounding box regression and localization data for pretraining.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F76byqyopeapiwb332v6g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F76byqyopeapiwb332v6g.png" alt="Alt Text" width="661" height="247"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, they use an ensemble of 6 CNNs when classifying each region which improves results from 40% to 43.9% mAP, drawing them to the top.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2d6hevbq44g4ait7hcg6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2d6hevbq44g4ait7hcg6.png" alt="Alt Text" width="724" height="193"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Remarks
&lt;/h2&gt;

&lt;p&gt;GoogLeNet's success promised a future towards creating sparser and more refined structures for CNN architectures. It also conveyed a strong message on consideration of a model's power and memory use efficiency while designing a new architecture. Similar to &lt;a href="https://dev.to/zohebabai/vggnet-ilsvrc-winner-2014-3mpk"&gt;VGGNet&lt;/a&gt;, GoogLeNet also reinstated that going deeper and wider was indeed the right direction to improve accuracy.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>deeplearning</category>
    </item>
    <item>
      <title>Top 10 Deep Learning Breakthroughs - Family of SNGD Optimizers</title>
      <dc:creator>Zoheb Abai</dc:creator>
      <pubDate>Sat, 08 Aug 2020 21:56:47 +0000</pubDate>
      <link>https://dev.to/zohebabai/top-10-deep-learning-breakthroughs-family-of-sngd-optimizers-4ek6</link>
      <guid>https://dev.to/zohebabai/top-10-deep-learning-breakthroughs-family-of-sngd-optimizers-4ek6</guid>
      <description>&lt;p&gt;Which three concepts lie at the heart of deep learning? - Loss Functions, Optimization algorithms, and Backpropagation. Without them, we would have been 'conceptually' stuck at the perceptron model of the 1950s. &lt;/p&gt;

&lt;p&gt;If you are completely unfamiliar with these terms, feel free to go through CS231n Lecture Notes &lt;a href="https://cs231n.github.io/optimization-1/" rel="noopener noreferrer"&gt;1&lt;/a&gt;, &lt;a href="https://cs231n.github.io/optimization-2/" rel="noopener noreferrer"&gt;2&lt;/a&gt;, &lt;a href="https://cs231n.github.io/neural-networks-3/" rel="noopener noreferrer"&gt;3&lt;/a&gt; or/and watch this and subsequent videos by Andrew Ng. &lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/uJryes5Vk1o"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Different problems require different loss functions, most of them are well known to us, also several new ones shall be arriving in the future. &lt;br&gt;
Backpropagation, proposed by &lt;a href="https://www.iro.umontreal.ca/~vincentp/ift3395/lectures/backprop_old.pdf" rel="noopener noreferrer"&gt;Hinton et al. in 1986&lt;/a&gt;,  drives the Neural Networks. &lt;br&gt;
But the choice of Optimization algorithms has always been the center of discussions and research inside the ML community. Researchers have been working for years on building an optimizer algorithm which&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. performs equally well on all major tasks - image classification, speech recognition, machine translation, and language modeling 
2. is robust to learning rate (LR) and weight initialization
3. has strong regularization properties
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you are a beginner and merely started coding Neural Network following online available notebooks, you might be most familiar with &lt;a href="https://arxiv.org/pdf/1412.6980.pdf" rel="noopener noreferrer"&gt;ADAM optimizer (2015)&lt;/a&gt;. It's the default optimizer algorithm for almost all DL frameworks including the popular one - Keras. There's a reason why it's kept default - it's robust to different learning rates and weight initialization. If you want to train your architecture on any data and worry less about hyperparameter tuning just use the defaults and it will give you good enough result for a start.&lt;/p&gt;

&lt;p&gt;But if you are an experienced one and already familiar with deep learning research papers, you know that except while training GANs and Reinforcement learning (both doesn't solve optimization problems), experts mostly use SGD with momentum or Nesterov as their preferred choice of the optimization algorithm. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So, which one should I choose?&lt;/strong&gt; 🤔&lt;/p&gt;

&lt;h3&gt;
  
  
  Non-adaptive methods
&lt;/h3&gt;

&lt;p&gt;Stochastic Gradient Descent, as we know now, arrived from its initial form of &lt;a href="https://projecteuclid.org/euclid.aoms/1177729586" rel="noopener noreferrer"&gt;Stochastic Approximation (1951) a landmark paper&lt;/a&gt; in the history of numerical optimization methods by Robbins and Monro. Here it wasn't proposed as a gradient method, but as a Markov chain. The form of SGD we are familiar with can be recognized in a subsequent &lt;a href="https://projecteuclid.org/euclid.aoms/1177729392" rel="noopener noreferrer"&gt;paper by Kiefer and Wolfowitz&lt;/a&gt;. Programmers now mostly use the variant &lt;em&gt;Mini-batch gradient descent&lt;/em&gt; with a batch size often between 32 and 512 (intervals in the exponent of 2) for training NN. But the key challenge faced by SGD is that it gets trapped in numerous suboptimal local minima and saddle points in loss function's landscape. So arrived the idea of implementing momentum, borrowed from a &lt;a href="https://vsokolov.org/courses/750/2018/files/polyak64.pdf" rel="noopener noreferrer"&gt;Polyak (1964)&lt;/a&gt; by Hinton et al. in their famous &lt;a href="https://www.iro.umontreal.ca/~vincentp/ift3395/lectures/backprop_old.pdf" rel="noopener noreferrer"&gt;Backpropagation paper&lt;/a&gt;. Momentum helps accelerate SGD in the relevant direction and dampens its oscillations. But it's still vulnerable to vanishing and exploding gradients. &lt;a href="https://papers.nips.cc/paper/5718-beyond-convexity-stochastic-quasi-convex-optimization.pdf" rel="noopener noreferrer"&gt;Hazan et al in 2015&lt;/a&gt; showed that the direction of the gradient is sufficient for convergence, thus proposing Stochastic Normalized Gradient Descent Optimizers. But it's still sensitive to 'noisy' gradients, especially during an initial training phase. In 2013, &lt;a href="https://www.cs.toronto.edu/~fritz/absps/momentum.pdf" rel="noopener noreferrer"&gt;Hinton et al.&lt;/a&gt; conclusively demonstrated that SGD with momentum or &lt;a href="http://mpawankumar.info/teaching/cdt-big-data/nesterov83.pdf" rel="noopener noreferrer"&gt;Nesterov accelerated gradient (1983)&lt;/a&gt;(a variant of SNGD) and simple learning rate annealing schedule combined with well-chosen weight initialization schemes achieved better convergence rates and resulted in surprisingly good accuracy for several architectures and tasks. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi185ufa36lovsx870qdg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi185ufa36lovsx870qdg.gif" alt="Comparisions" width="620" height="480"&gt;&lt;/a&gt;&lt;/p&gt;
Optimizers on Loss Surface Contours



&lt;h3&gt;
  
  
  Adaptive methods
&lt;/h3&gt;

&lt;p&gt;Parameter updates by the above-described methods do not adapt with different learning rates, proper choice of which is crucial. This gave rise to &lt;a href="https://ruder.io/optimizing-gradient-descent/index.html" rel="noopener noreferrer"&gt;several adaptive learning rate-based optimizers within next 4-5 years&lt;/a&gt; to improve SNGD robustness. They generally updated the parameters via an exponential moving average of past squared gradients. But even they weren't problem-free; such as for Adam it is the vanishing or exploding of the second moment, especially during the initial phase of training, and requirement of double the optimizer memory compared to SGD with momentum for storing the second moment. In 2018, &lt;a href="https://arxiv.org/pdf/1705.08292.pdf" rel="noopener noreferrer"&gt;Wilson et al.&lt;/a&gt; extensively studied &lt;em&gt;how optimization relates to generalization&lt;/em&gt; and concluded three major findings:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;with the same amount of hyperparameter tuning, SGD and SGD with momentum outperform adaptive methods on the development/test set across all evaluated models and tasks (even if the adaptive methods achieve the same training loss or lower than non-adaptive methods.)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;adaptive methods often display faster initial progress on the training set, but their performance quickly plateaus on the development/test set&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;the same amount of hyperparameter tuning was required for all methods, including adaptive methods&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check out this &lt;a href="https://gist.github.com/wiseodd/85ad008aef5585cec017f4f1e6d67a02" rel="noopener noreferrer"&gt;beautiful python implementation of some common optimizers&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Way Ahead
&lt;/h2&gt;

&lt;p&gt;Last year &lt;a href="https://arxiv.org/pdf/1711.05101.pdf" rel="noopener noreferrer"&gt;Loshchilov et al.&lt;/a&gt; pointed out the major factor for the poor generalization of Adam - &lt;em&gt;L2regularization being not nearly as effective as for SGD&lt;/em&gt;. The author explains that major deep learning libraries implement only L2regularization,  and not the original weight decay (most people confuse them as identical). To improve regularization in Adam they proposed AdamW - which decouples the weight decay from the gradient-based update. Although for achieving this they used a cosine learning rate annealing with Adam. 😩&lt;/p&gt;

&lt;p&gt;This year NVIDIA team proposed a new member of SNGD family - &lt;a href="https://arxiv.org/pdf/1905.11286.pdf" rel="noopener noreferrer"&gt;NovoGrad&lt;/a&gt; an adaptive stochastic gradient descent method with layer-wise gradient normalization and decoupled weight decay. They combined SGD’s and Adam’s strengths by implementing the following three ideas while building it:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. starting with Adam, replaced the element-wise second moment with the layer-wise moment
2. computed the first-moment using gradients normalized by the layer-wise second moment
3. decoupled weight decay (WD)from normalized gradients (similar to AdamW)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Not only it generalizes well or better than Adam/AdamW and SGD with momentum on all major tasks, but also is more robust to the initial learning rate and weight initialization than them. In addition,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. It works well without LR warm-up (annealing)
2. It performs exceptionally well for large batch training (for ResNet-50 up to 32K)
3. It requires half the memory compared to Adam
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;A few days back, &lt;a href="https://arxiv.org/pdf/2007.13985.pdf" rel="noopener noreferrer"&gt;Zhao et al.&lt;/a&gt; theoretically proved and empirically showed that SNGD with momentum can achieve the SOTA accuracy with a large batch size (much faster training).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Febusnijlwco7v7l50p62.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Febusnijlwco7v7l50p62.gif" alt="Yep" width="370" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope you realize that we are at a brink of a breakthrough after a long search for a dataset/task/hyperparameter-tuning independent better-generalizing optimizer algorithm.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>tutorial</category>
      <category>python</category>
    </item>
    <item>
      <title>Top 10 Deep Learning Breakthroughs - AlexNet</title>
      <dc:creator>Zoheb Abai</dc:creator>
      <pubDate>Wed, 05 Aug 2020 22:35:04 +0000</pubDate>
      <link>https://dev.to/zohebabai/top-10-deep-learning-breakthroughs-alexnet-1670</link>
      <guid>https://dev.to/zohebabai/top-10-deep-learning-breakthroughs-alexnet-1670</guid>
      <description>&lt;p&gt;If you want to learn about AlexNet, check out this blog where I have extensively covered it &lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/zohebabai" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F426542%2Fbce71db0-35f6-4410-bad0-04b11805cc99.png" alt="zohebabai"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/zohebabai/alexnet-ilsvrc-winner-2012-3cfo" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;A Decade of Deep CNN Archs. - AlexNet (ILSVRC Winner 2012)&lt;/h2&gt;
      &lt;h3&gt;Zoheb Abai ・ Jul 18 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#datascience&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#machinelearning&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#deeplearning&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;Here is an example notebook, in which I have imported a pretrained AlexNet model from PyTorch Library and used it for classifying an image. &lt;/p&gt;

&lt;p&gt;Feel free to play around and discuss.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;If you want to explore a bit more on AlexNet, go through my blog on ZFNet.&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/zohebabai" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F426542%2Fbce71db0-35f6-4410-bad0-04b11805cc99.png" alt="zohebabai"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/zohebabai/zfnet-ilsvrc-runner-up-2013-4hnj" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;A Decade of Deep CNN Archs. - ZFNet (ILSVRC Runner-up 2013)&lt;/h2&gt;
      &lt;h3&gt;Zoheb Abai ・ Jul 25 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#machinelearning&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#datascience&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#deeplearning&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;Although it was an updated version of AlexNet, the paper contributed towards our in-depth understanding of CNN architectures.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>python</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>A Decade of Deep CNN Archs. - VGGNet (ILSVRC Winner 2014)</title>
      <dc:creator>Zoheb Abai</dc:creator>
      <pubDate>Sat, 01 Aug 2020 07:56:27 +0000</pubDate>
      <link>https://dev.to/zohebabai/vggnet-ilsvrc-winner-2014-3mpk</link>
      <guid>https://dev.to/zohebabai/vggnet-ilsvrc-winner-2014-3mpk</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fn05dfxqznc4hcktefiex.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fn05dfxqznc4hcktefiex.jpg" alt="Vgg arch" width="360" height="459"&gt;&lt;/a&gt;&lt;/p&gt;
VGGNet Architecture



&lt;p&gt;Each year ILSVRC winners conveyed some interesting insights and 2014 was special in that regard. For most years the challenge tasks were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Image classification&lt;/strong&gt;: Predict the classes of objects present in an image.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Single-object localization&lt;/strong&gt;: Image classification + draw a bounding box around one example of each object present.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Object detection&lt;/strong&gt;: Image classification + draw a bounding box around each object present.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By 2014 it was apparent that as more and more fresh architecture unveiled, no one single CNN architecture could champion all the tasks and 2014 winners were perfect embodiment of it. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VGGNet&lt;/strong&gt; was introduced in the paper titled &lt;a href="https://arxiv.org/pdf/1409.1556.pdf" rel="noopener noreferrer"&gt;Very Deep Convolutional Networks for Large-Scale Image Recognition&lt;/a&gt; by &lt;em&gt;Karen Simonyan&lt;/em&gt; and &lt;em&gt;Andrew Zisserman&lt;/em&gt;. VGGNet architecture won the competition in &lt;em&gt;localization&lt;/em&gt; task while bagging 2nd position in the &lt;em&gt;classification&lt;/em&gt; task. The beauty of this network lies in its architectural simplicity and reinforcing the idea of having deeper CNNs for improved performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Improvements over top CNN Architectures
&lt;/h2&gt;

&lt;p&gt;Since 2012, there had been numerous attempts to improve over &lt;a href="https://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf" rel="noopener noreferrer"&gt;AlexNet&lt;/a&gt; in every possible way. In 2013, both &lt;a href="https://arxiv.org/pdf/1312.6229.pdf" rel="noopener noreferrer"&gt;Overfeat&lt;/a&gt; and &lt;a href="https://arxiv.org/pdf/1311.2901.pdf" rel="noopener noreferrer"&gt;ZFNet&lt;/a&gt; improved their performance compared to AlexNet, by utilizing smaller receptive window size (7 × 7) and smaller stride (2) in their first convolutional layer. Small-size convolution filters were previously used by &lt;a href="http://people.idsia.ch/~juergen/ijcai2011.pdf" rel="noopener noreferrer"&gt;Dan Ciresan Net&lt;/a&gt;, but their nets were significantly less deep, and they did not evaluate the large-scale dataset. In VGGNet, authors used petite 3 × 3 receptive fields (which is the smallest size to capture the notion of left/right, up/down, center) throughout the 16 and 19 layer deep networks with a stride of 1 and padding of 1 so that the spatial resolution is preserved after each convolution. Optional spatial pooling was carried out by a max-pooling layer of lowered size 2 x 2 with a stride of 2, instead of 3 x 3. The reason behind such implementation as provided by authors are :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;2 or 3 consecutive 3x3 layers has an &lt;em&gt;effective receptive field&lt;/em&gt; of 5x5 or 7x7 respectively&lt;/li&gt;
&lt;li&gt;as every convolutional operation is followed with a non-linear ReLU activation, so multiples of them make the decision function more discriminating than a single ReLU,&lt;/li&gt;
&lt;li&gt;a layer of 7x7 convolutional filters with C channels has 7C x 7C parameters, whereas a layer of 3x3 convolutional filters with C channels has just 3C x 3C parameters, 81% less.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://arxiv.org/pdf/1312.5402.pdf" rel="noopener noreferrer"&gt;HowardNet&lt;/a&gt; and &lt;a href="https://arxiv.org/pdf/1312.6229.pdf" rel="noopener noreferrer"&gt;Overfeat&lt;/a&gt; also improved their performance by utilizing similar multiple scaling of images during both training and testing of the network, instead of using a single scale as AlexNet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Training
&lt;/h2&gt;

&lt;p&gt;Training and evaluation of 140 million parameters VGGNet were performed on 4 NVIDIA Titan Black GPUs installed in a single system. Multi-GPU training exploits data parallelism and is carried out by splitting each batch of training images into several GPU batches, processed in parallel on each GPU. After the GPU batch gradients are computed, they are averaged to obtain the gradient of the full batch. Gradient computation is synchronous across the GPUs, so the result is the same as when training on a single GPU.&lt;br&gt;
Despite the larger number of parameters and the greater depth of VGGNet compared to AlexNet it required &lt;em&gt;fewer epochs to converge&lt;/em&gt;, to which authors conjecture that might be due to &lt;em&gt;implicit regularization imposed by the greater depth and smaller convolutional filter sizes and pre-initialization of certain layers&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;VGGNet does not contain Local Response Normalization as in AlexNet because such normalization does not improve the performance instead leads to increased memory consumption and computation time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Preprocessing&lt;/strong&gt;: The mean value of pixels over the training set was subtracted from each pixel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Image Augmentation&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Single scale training&lt;/strong&gt;: Authors first trained the network using images scaled to 256. Then to speed-up training of the network with images scaled to 384, it was initialized with the weights pre-trained with that of scale 256, and they used a smaller initial learning rate of 1e-03&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Multiscale training&lt;/strong&gt;: Where each training image was individually rescaled by randomly sampling scales from a certain range [Smin, Smax] where Smin = 256 and Smax = 512. For speed reasons, authors trained multi-scale models by fine-tuning all layers of a single-scale model with the same configuration, pre-trained with a fixed scale of 384.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Multi-Crop&lt;/strong&gt;: Finally, to feed the network with the fixed-size 224×224 input images, rescaled training images were randomly cropped (one crop per image - per SGD iteration). To further augment the training set, the crops underwent random horizontal flipping and random RGB color shift as done during AlexNet.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Dropout&lt;/strong&gt;: Same as &lt;a href="https://dev.to/zohebabai/alexnet-ilsvrc-winner-2012-3cfo"&gt;AlexNet&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Kernel Initializer&lt;/strong&gt;: Same&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bias Initializer&lt;/strong&gt;: 0 for each layer&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Batch Size&lt;/strong&gt;: 256&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Optimizer&lt;/strong&gt;: Same&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L2 weight decay&lt;/strong&gt;: Same&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Learning Rate Manager&lt;/strong&gt;: Same&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Total epochs&lt;/strong&gt;: 74&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Total time&lt;/strong&gt;: 21 days (max for VGG-19)&lt;/p&gt;

&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frv7rmn0zm27v7069qvyj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frv7rmn0zm27v7069qvyj.jpg" alt="VGGNet Results" width="720" height="820"&gt;&lt;/a&gt;&lt;/p&gt;
6 different architectures used for experimenting



&lt;p&gt;&lt;strong&gt;Test Time Augmentation&lt;/strong&gt;: During test time the network was applied densely over the rescaled test images in a way similar to Overfeat. Namely, the fully connected layers were first converted to convolutional layers (the first FC layer to a 7 × 7 convolutional layer, the last two FC layers to 1 × 1 convolutional layers). The resulting fully convolutional net was then applied to the whole (uncropped) images. The result was a class score map with the number of channels equal to the number of classes, and a variable spatial resolution, dependent on the input image size. Finally, to obtain a fixed-size vector of class scores for the image, the class score map is spatially averaged (sum-pooled). Authors also augment the test set by horizontally flipping the images; the soft-max class posteriors of the original and flipped images were averaged to obtain the final scores for the images.&lt;/p&gt;

&lt;p&gt;Authors justify using dense evaluation methods instead of multi-crop evaluation (performed during AlexNet) due to decreased computation time, although the methods being complementary to each other (due to different convolution boundary conditions) were used together for better results. &lt;br&gt;
While applying a CNN to a cropped image, the convolved feature maps were padded with zeros, while for dense evaluation the padding for the same cropped image naturally came from the neighboring parts of the image (due to both the convolutions and spatial pooling), which substantially increased the overall network receptive field, so more context was captured.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Single Scale Evaluation&lt;/strong&gt;: The test image size was set as follows: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Q = S for fixed training image scale S, and &lt;/li&gt;
&lt;li&gt;Q = 0.5(Smin + Smax) for jittered S ∈ [Smin, Smax].&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqwrst9lc6gyay6noepwl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqwrst9lc6gyay6noepwl.jpg" alt="VGG SSE" width="740" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Authors observed that the classification error decreased with the increased ConvNet depth: from 11 layers in A to 19 layers in E (but saturated after that). The scale jittering at training time (S ∈ [256; 512]) lead to significantly better results than training on images with the fixed smallest side (S = 256 or S = 384), even though a single scale is used at test time. This confirmed that training set augmentation by scale jittering was indeed helpful for capturing multi-scale image statistics.&lt;/p&gt;

&lt;p&gt;The Least performing Network &lt;strong&gt;A&lt;/strong&gt; achieving 10.4% top-5 error confirmed that a deep network with small filters outperforms a shallow network with larger filters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multi-Scale Evaluation&lt;/strong&gt;: Here, the authors assessed the effect of scale jittering at test time. It consisted of running a model over several rescaled versions of a test image (corresponding to different values of Q), followed by averaging the resulting class posteriors. The model trained with variable S ∈ [Smin; Smax] was evaluated over a larger range of sizes Q = {Smin, 0.5(Smin + Smax), Smax}.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fa3oq8i1e1ng8krhawxf5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fa3oq8i1e1ng8krhawxf5.jpg" alt="VGG MSE" width="740" height="272"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The results indicated that scale jittering at test time leads to better performance as compared to evaluating the same model at a single scale.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multi-Crop and Dense&lt;/strong&gt;: As mentioned earlier best-performing networks &lt;strong&gt;D&lt;/strong&gt; (VGG16) and &lt;strong&gt;E&lt;/strong&gt; (VGG19) achieved slightly better results with Multi-Crop and Dense evaluation together.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Funk1qtmtd5w6u6q149wg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Funk1qtmtd5w6u6q149wg.jpg" alt="VGG MCD" width="740" height="157"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final submission ensembling VGG16 and VGG19&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F15tfj3ogj52h29jjgd2c.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F15tfj3ogj52h29jjgd2c.jpg" alt="Vgg comparision" width="740" height="310"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similar to AlexNet(2012) and ZFNet(2013) submissions authors too submitted an ensemble (combining the outputs of several models by averaging their soft-max class posteriors) of their best performing models &lt;strong&gt;D&lt;/strong&gt; and &lt;strong&gt;E&lt;/strong&gt;; just two, a significantly less number of models than earlier submissions and remarkably outperforming them. &lt;strong&gt;The final submitted top-5 error of 6.8% outperformed all earlier submitted results.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Remarks
&lt;/h2&gt;

&lt;p&gt;VGGNet, &lt;em&gt;simplicity at its best&lt;/em&gt; architecture compared to its competitor &lt;a href="https://arxiv.org/pdf/1409.4842.pdf" rel="noopener noreferrer"&gt;GoogLeNet&lt;/a&gt;, had few but important insights to offer. The use of now &lt;em&gt;omnipresent&lt;/em&gt; 3x3 convolutional layers throughout an architecture was seeded here. Both VGGNet and GoogLeNet, the winners of 2014, using the concept of effective receptive field highlighted the importance of depth in visual representations which eventually became the stepping stone of a breakthrough transformation arriving next year.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>deeplearning</category>
    </item>
    <item>
      <title>A Decade of Deep CNN Archs. - ZFNet (ILSVRC Runner-up 2013)</title>
      <dc:creator>Zoheb Abai</dc:creator>
      <pubDate>Sat, 25 Jul 2020 07:09:20 +0000</pubDate>
      <link>https://dev.to/zohebabai/zfnet-ilsvrc-runner-up-2013-4hnj</link>
      <guid>https://dev.to/zohebabai/zfnet-ilsvrc-runner-up-2013-4hnj</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fp1rfz9z2c6flu4wwer6x.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fp1rfz9z2c6flu4wwer6x.jpg" alt="Cover" width="740" height="194"&gt;&lt;/a&gt;&lt;/p&gt;
ZFNet Architecture



&lt;p&gt;&lt;strong&gt;ZFNet&lt;/strong&gt; was introduced in the paper titled &lt;em&gt;&lt;a href="https://arxiv.org/pdf/1311.2901.pdf" rel="noopener noreferrer"&gt;Visualizing and Understanding Convolutional Networks&lt;/a&gt;&lt;/em&gt; by &lt;em&gt;Matthew D. Zeiler&lt;/em&gt; and &lt;em&gt;Rob Fergus&lt;/em&gt;. This architecture did not win the competition, but its inference was implemented by winner of that year (&lt;em&gt;Clarifai&lt;/em&gt; founded by &lt;em&gt;Zeiler&lt;/em&gt;, 11.19% test error). This paper is remarkable because of its &lt;strong&gt;visualizations and understanding of the internal operation and behavior of a CNN model&lt;/strong&gt; classifying an image. The paper also introduced us to a technique now widely known as &lt;strong&gt;Transfer Learning&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Due to 2012 winner AlexNet, there was an enormous increase in submission of CNN models for ILSVRC 2013 but most of them were trial-and-error based without exhibiting any understanding of how and why CNN performed so well. &lt;/p&gt;

&lt;p&gt;Let's understand that (as explained by authors).&lt;/p&gt;

&lt;h2&gt;
  
  
  A CNN model
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Maps a color 2D input image &lt;code&gt;x_i&lt;/code&gt;, via a series of layers, to a probability vector &lt;code&gt;y_i_hat&lt;/code&gt; over the &lt;code&gt;C&lt;/code&gt; different classes, where each layer consists of&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Convolution of the previous layer output with a set of learned filters, passing the responses through a rectified linear function

2. Optionally max pooling over local neighborhoods 

3. Optionally a local contrast operation that normalizes the responses across feature maps (it's not relevant anymore)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;has conventional fully connected top few layers with final layer as a softmax classifier.&lt;/li&gt;
&lt;li&gt;is trained using a large set of &lt;code&gt;N&lt;/code&gt; labelled images &lt;code&gt;{x, y}&lt;/code&gt;, where label &lt;code&gt;y_i&lt;/code&gt; is a discrete variable indicating the true class.&lt;/li&gt;
&lt;li&gt;cross-entropy loss function - &lt;code&gt;p(x)log(q(x))&lt;/code&gt;, suitable for image classification, is used to compare &lt;code&gt;y_hat&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;parameters are trained by backpropagating the derivative of the loss regarding the parameters throughout the network, and updating the parameters via stochastic gradient descent in batches.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Updating &lt;a href="https://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf" rel="noopener noreferrer"&gt;AlexNet&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Understanding the operation of a CNN requires interpreting the feature activity in intermediate layers, so authors present a novel way known as &lt;strong&gt;DeconvNet&lt;/strong&gt; (Zeiler et al. proposed it initially as unsupervised learning technique) to map these activities back to the input pixel space, showing what input pattern, originally, had caused a given activation in the feature maps.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fth5w28n5012mo8s9m2li.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fth5w28n5012mo8s9m2li.jpg" alt="Deconvnet" width="445" height="441"&gt;&lt;/a&gt;&lt;/p&gt;
A DeconvNet layer (left) attached to a ConvNet layer (right)



&lt;p&gt;A DeconvNet is attached to each of its ConvNet layers, providing a continuous path back to image pixels. To examine a given ConvNet activation, all other activations in the layer are set to zero and the feature maps are passed as input to the attached DeconvNet layer. Then it is successively &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. unpooled (uses the switch which records the location of the local max in maxpool), 

2. rectified, and 

3. filtered (uses transposed version of same filters in convnet) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;to reconstruct the activity in the layer beneath, that gave rise to the chosen activation. This is repeated until input pixel space is reached.&lt;/p&gt;

&lt;p&gt;They train AlexNet reproducing test error percentage within 0.1% of reported value in 2012. By visualizing the first and second layers of AlexNet, they observe two specific issues:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Filters at layer 1 are a mix of extremely high and low frequency information, with little coverage of the mid frequencies. Without the mid frequencies, there is a chain effect that deep features can only learn from extremely high and low frequency information. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Note: Spatial frequency information in an image describes the information on periodic distributions of 'light' and 'dark' in that image. High spatial frequencies correspond to features such as sharp edges and fine details, whereas low spatial frequencies correspond to features such as global shape.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fx6zwh5zzdxisishp8z4e.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fx6zwh5zzdxisishp8z4e.jpg" alt="Issue1" width="155" height="127"&gt;&lt;/a&gt;&lt;/p&gt;
AlexNet Layer 1 features



&lt;ul&gt;
&lt;li&gt;Layer 2 shows aliasing artifacts caused by the large stride 4 used in the 1st layer convolutions. Aliasing occurs when sampling frequency is too low.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Note : In each CNN layer (if not using Upsampling or DeconvNet) we are mainly sampling down (discretization) the image. If sampling frequency is too low (insufficient sampling) then we get aliasing effects on the sampled image such as jagged boundaries/edges, repetitive textures etc.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F61r4wbqqh96yqnh0e09t.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F61r4wbqqh96yqnh0e09t.jpg" alt="Issue2" width="247" height="249"&gt;&lt;/a&gt;&lt;/p&gt;
AlexNet Layer 2 features



&lt;p&gt;To remedy these problems, authors made following changes in AlexNet Architecture:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Reduced the 1st layer filter size from 11×11 to 7×7. Filters of size 11x11 proved to be skipping a lot of relevant information&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frpnfmgouibo9n3eyvq37.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frpnfmgouibo9n3eyvq37.jpg" alt="Solution1" width="152" height="123"&gt;&lt;/a&gt;&lt;/p&gt;
ZFNet Layer 1 features


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Made the stride of the convolution 2, rather than 4. A filter of stride of 2 proved to retain a lot of pixel information&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdxd4v3bydrij1rcki82s.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdxd4v3bydrij1rcki82s.jpg" alt="Solution2" width="250" height="248"&gt;&lt;/a&gt;&lt;/p&gt;
ZFNet Layer 2 features



&lt;p&gt;This new architecture retains much more information in the 1st and 2nd layer features. So final ZFNet architecture looks like this :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F745h9khoniihaxysr71u.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F745h9khoniihaxysr71u.jpg" alt="Table1" width="740" height="423"&gt;&lt;/a&gt;&lt;/p&gt;
Table 1: Architecture Details



&lt;h2&gt;
  
  
  Training
&lt;/h2&gt;

&lt;p&gt;During training, visualization of the first layer filters revealed that, a few of them dominated. To combat this, authors renormalized each filter in the convolutional layers to a fixed radius of RMS value of 1e-01.&lt;/p&gt;

&lt;p&gt;The model was trained on the ImageNet 2012 training set (1.3 million images, spread over 1000 different classes) on single NVIDIA GTX 580 GPU with 3 GB memory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Preprocessing:&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://dev.to/zohebabai/alexnet-ilsvrc-winner-2012-3cfo"&gt;Same as AlexNet&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Image Augmentation:&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://dev.to/zohebabai/alexnet-ilsvrc-winner-2012-3cfo"&gt;Same as AlexNet.&lt;/a&gt; (224x224 here)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dropout:&lt;/strong&gt; &lt;br&gt;
Same as AlexNet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Kernel Initializer:&lt;/strong&gt; &lt;br&gt;
1e-02 for each layer&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bias Initializer:&lt;/strong&gt; &lt;br&gt;
0 for each layer&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Batch Size:&lt;/strong&gt; &lt;br&gt;
Same&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Optimizer:&lt;/strong&gt; &lt;br&gt;
Same&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L2 weight decay:&lt;/strong&gt; &lt;br&gt;
None&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Learning Rate Manager:&lt;/strong&gt; &lt;br&gt;
Same.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Total epochs:&lt;/strong&gt; &lt;br&gt;
70&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Total time:&lt;/strong&gt; &lt;br&gt;
12 days&lt;/p&gt;

&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;p&gt;Single ZFNet model achieves top-1 and top-5 test errors of 38.4% and 16.5% respectively, lower by a margin of 1.7% than that of AlexNet. Their final submission comprised of an ensemble of 6 CNNs (average of 5 ZFNet's and a network same as ZFNet but layer Conv3, Conv4, Conv5 with 512, 1024, 512 channels respectively) which gave an error rate of &lt;strong&gt;14.8%&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Depth of the model is important for obtaining good performance:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Removing two fully connected layers yielded a slight increase in error, although they contained the majority of model parameters. Removing two of the middle convolutional layers also made a relatively small difference to the error rate. However, removing both the middle convolution layers and the fully connected layers yielded a model with only 4 layers whose performance was dramatically worse.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transfer Learning:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Finally, authors showed that model trained on ImageNet generalizes well to other datasets. For this, they kept layers 1-7 of the ImageNet trained model fixed and train a new softmax classifier on top (for the appropriate number of classes) using the training images of the new dataset.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Faiqonveqnxumhzfpdifm.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Faiqonveqnxumhzfpdifm.jpg" alt="TL1" width="360" height="102"&gt;&lt;/a&gt;&lt;/p&gt;
Fine-Tuning ImageNet trained ZFNet on Caltech-101 dataset



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fnpag2v1cgrpwmuhaeoqf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fnpag2v1cgrpwmuhaeoqf.jpg" alt="TL2" width="360" height="87"&gt;&lt;/a&gt;&lt;/p&gt;
Fine-Tuning ImageNet trained ZFNet on Caltech-256 dataset



&lt;h2&gt;
  
  
  Visualizations
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Feature Visualization&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ff0npezqeebc3c7q07bpb.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ff0npezqeebc3c7q07bpb.jpg" alt="FV1" width="505" height="679"&gt;&lt;/a&gt;&lt;/p&gt;
Visualization of features in a fully trained model. For layers 2-5 authors show the top 9 activations in a random subset of feature maps across the validation data, projected down to pixel space using the de-convolutional network approach



&lt;p&gt;The projections from each layer show the hierarchical nature of the features in the network. Layer 2 responds to corners and other edge/color conjunctions.&lt;/p&gt;

&lt;p&gt;Layer 3 has more complex invariance, capturing similar textures such as mesh patterns and text patterns.&lt;/p&gt;

&lt;p&gt;Layer 4 shows significant variation, but is more class-specific such as dog faces and bird’s legs.&lt;/p&gt;

&lt;p&gt;Layer 5 shows entire objects with significant pose variation such as keyboards and dogs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Feature Evolution during Training&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3t64au3fv7aeji70mqf7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3t64au3fv7aeji70mqf7.jpg" alt="FV2" width="740" height="125"&gt;&lt;/a&gt;&lt;/p&gt;
Evolution of a randomly chosen subset of model features through training. Each layer’s features are displayed in a different block. Within each block, it shows a randomly chosen subset of features at epochs [1,2,5,10,20,30,40,64]. The visualization shows the strongest activation (across all training examples) for a given feature map, projected down to pixel space using the DeconvNet approach



&lt;p&gt;Here, the lower layers of the model can be seen to converge within a few epochs. However, the upper layers only develop after a considerable number of epochs (40-50), demonstrating the need to let the models train until fully converged.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Feature Invariance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fejxv5vgvj8o0s88yet4g.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fejxv5vgvj8o0s88yet4g.jpg" alt="FV3" width="740" height="493"&gt;&lt;/a&gt;&lt;/p&gt;
Column1 and Column2: Euclidean distance between feature vectors from the original and transformed images in layers 1 and 7 respectively. Column 3:The probability of the true label for each image, as the image is transformed



&lt;p&gt;Small transformations have a dramatic effect in the first layer of the model, but a lesser impact at the top feature layer, being quasi linear for translation &amp;amp; scaling. The network output is stable to translations and scaling. In general, the output is not invariant to rotation, except for object with rotational symmetry (e.g. entertainment center).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Occlusion Sensitivity&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fy4nxthtjxn5668p1spgp.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fy4nxthtjxn5668p1spgp.jpg" alt="FV4" width="740" height="427"&gt;&lt;/a&gt;&lt;/p&gt;
The first row example shows the strongest feature to be the dog’s face. When this is covered-up the activity in the feature map decreases (blue area in (b)). When the dog’s face is obscured, the probability for “Pomeranian” drops significantly. In the 1st row, for most locations it is “Pomeranian”, but if the dog’s face is obscured but not the ball, then it predicts “tennis ball”. In the 2nd example, text on the car is the strongest feature in layer 5, but the classifier is most sensitive to the wheel. The 3rd example contains multiple objects. The strongest feature in layer 5 picks out the faces, but the classifier is sensitive to the dog (blue region in (d)), since it uses multiple feature maps



&lt;p&gt;&lt;strong&gt;With these image classification approaches, a natural question arises : Is model truly identifying the location of the object in the image, or just using the surrounding context?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Authors attempt to answer this question by systematically occluding different portions of the input image with a gray square, and monitoring the output of the classifier. Above examples show visualizations from the strongest feature map of the top convolution layer, in addition to activity in this map (summed over spatial locations) as a function of 'occluder' position. It clearly shows that the model is localizing the objects within the scene, as the probability of the correct class and activity in the feature map drops significantly when the object is occluded. This shows that the model, while trained for classification, is &lt;em&gt;highly sensitive to local structure in the image and is not just using broad scene context&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Remarks
&lt;/h2&gt;

&lt;p&gt;Thus, the paper holds its significance for introducing us to the &lt;em&gt;perspective&lt;/em&gt; we require while structuring a CNN architecture. The visualization techniques introduced here to  visualize  the  activity within the model are still relevant for inferring the performance of models or determining data preprocessing techniques for obtaining better results. Authors brought this fact to the limelight that CNN models &lt;em&gt;do not generate features with random, non-interpretable patterns&lt;/em&gt; (black box - as thought by many) but revealing several intuitively desirable properties such as &lt;strong&gt;compositionality&lt;/strong&gt;,  &lt;strong&gt;increasing  invariance&lt;/strong&gt;  and  &lt;strong&gt;class  discrimination&lt;/strong&gt; as we ascend the layers of a CNN model.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>deeplearning</category>
    </item>
    <item>
      <title>A Decade of Deep CNN Archs. - AlexNet (ILSVRC Winner 2012)</title>
      <dc:creator>Zoheb Abai</dc:creator>
      <pubDate>Sat, 18 Jul 2020 08:48:39 +0000</pubDate>
      <link>https://dev.to/zohebabai/alexnet-ilsvrc-winner-2012-3cfo</link>
      <guid>https://dev.to/zohebabai/alexnet-ilsvrc-winner-2012-3cfo</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3ykad1kyrlzg2j3b3ja7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3ykad1kyrlzg2j3b3ja7.jpg" alt="Cover" width="740" height="251"&gt;&lt;/a&gt;&lt;/p&gt;
AlexNet Architecture (Split into two GPUs)



&lt;p&gt;&lt;strong&gt;AlexNet&lt;/strong&gt; was introduced in the paper, titled &lt;a href="https://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf" rel="noopener noreferrer"&gt;ImageNet Classification with Deep Convolutional Networks&lt;/a&gt;, by &lt;em&gt;Alex Krizhevsky, Ilya Sutskever, Geoffrey E. Hinton&lt;/em&gt; and since then it has been cited around &lt;a href="https://scholar.google.com/citations?user=xegzhJcAAAAJ&amp;amp;hl=en#d=gs_md_cita-d&amp;amp;u=%2Fcitations%3Fview_op%3Dview_citation%26hl%3Den%26user%3DxegzhJcAAAAJ%26citation_for_view%3DxegzhJcAAAAJ%3Au5HHmVD_uO8C%26tzom%3D-330" rel="noopener noreferrer"&gt;67000 times&lt;/a&gt; and is widely considered as one of the most influential papers published in the field of computer vision. It was neither the first implementation of CNN architecture nor the first GPU implementation of a Deep CNN architecture, then why it's so influential? &lt;/p&gt;

&lt;p&gt;Let's find it out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before publication of the paper
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Most of the computer vision tasks were solved using machine learning methods such as SVM and K-NN or Fully Connected Neural Networks.&lt;/li&gt;
&lt;li&gt;CNN architecture with the use of a backpropagation algorithm for computer vision problem was introduced back in 1989 by &lt;a href="https://en.wikipedia.org/wiki/Yann_LeCun" rel="noopener noreferrer"&gt;Yann LeCun&lt;/a&gt; et al. (&lt;a href="http://yann.lecun.com/exdb/publis/pdf/lecun-98.pdf" rel="noopener noreferrer"&gt;LeNet&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Fast GPU implementation of a deep CNN with back propagation was introduced a year before (August 2011) by Dan C. Ciresan et al., which had achieved SOTA test error rate of 0.35% on MNIST, 2.53% on NORB and 19.51% on CIFAR10 datasets. They showed their implementation to be 10 to 60 times faster than a compiler-optimized CPU version. (&lt;a href="http://people.idsia.ch/~juergen/ijcai2011.pdf" rel="noopener noreferrer"&gt;Dan C. Ciresan Net&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Rectified Linear Unit (&lt;a href="https://www.cs.toronto.edu/~fritz/absps/reluICML.pdf" rel="noopener noreferrer"&gt;ReLU&lt;/a&gt;) was introduced by Geoffrey E. Hinton et al. in 2010 on Restricted Boltzmann Machines replacing binary units for recognizing objects and comparing faces.&lt;/li&gt;
&lt;li&gt;In the authors' earlier work, they introduced &lt;a href="https://arxiv.org/pdf/1207.0580.pdf" rel="noopener noreferrer"&gt;Dropout&lt;/a&gt; layers as an efficient method for reducing overfitting.&lt;/li&gt;
&lt;li&gt;Other than ImageNet dataset, all the publicly available labelled dataset were relatively small (in order of tens of thousands) such as MNIST and CIFAR-10, on which it was easy to achieve good performance with optimized image augmentations.&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://image-net.org/challenges/LSVRC/" rel="noopener noreferrer"&gt;ImageNet Large-Scale Visual Recognition Challenge&lt;/a&gt; (an annual competition started since 2010) uses a subset of &lt;a href="http://www.image-net.org/papers/imagenet_cvpr09.pdf" rel="noopener noreferrer"&gt;ImageNet&lt;/a&gt; (a database introduced by Fei-Fei et al. in 2009) with roughly 1000 images of variable-resolution in each of 1000 categories, enclosing a total of 1.2 million training images, 50,000 validation images, and 150,000 testing images. It is customary to report two error rates: top-1 and top-5 in final submissions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Data Preprocessing
&lt;/h2&gt;

&lt;p&gt;AlexNet was trained on the centered RGB values of the pixels.&lt;/p&gt;

&lt;p&gt;Given a rectangular image, at first, the shorter side was re-scaled to a length of 256 and then a patch of size 256×256 was cropped from the center. Later, the mean value of pixels over the training set was subtracted from each pixel.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1gq0wegh6eiea65ccr4h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1gq0wegh6eiea65ccr4h.png" alt="Table 1 : Architecture Details" width="740" height="424"&gt;&lt;/a&gt;&lt;/p&gt;
Table 1 : Architecture Details



&lt;p&gt;The network with 60 million parameters was trained by spreading it across two NVIDIA GTX 580 GPU with 3 GB memory each. The kernels of the second, fourth, and fifth convolutional layers were connected only to feature maps which resided on the same GPU, while the kernels of the third convolutional layer were connected to all feature maps across GPUs. Neurons in the fully-connected layers were also connected to all neurons in the previous layer across GPUs.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;ReLU&lt;/em&gt; non-linear activation was applied to the output of every convolutional and fully connected layer, replacing previously used tanh units. This non-saturating non-linear function was much faster in terms of training time than saturating non-linear tanh function.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Local Response normalization&lt;/em&gt; (or brightness normalization) layers followed first and second convolutional layers after applying ReLU activation. These layers helped lower top-1 and top-5 test errors by 1.4% and 1.2% respectively.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fmn8jn5d7ipzv3fy0once.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fmn8jn5d7ipzv3fy0once.png" alt="LRN" width="360" height="84"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here variable &lt;code&gt;a&lt;/code&gt; represents the ReLU activated value of a neuron. The constants k, n, α, and β are hyper-parameters whose values were k = 2, n = 5, α = 10e-4, and β = 0.75. The sum runs over n “adjacent” kernel maps at the same spatial position, and N is the total number of kernels in the layer.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Max-pooling&lt;/em&gt; layers followed both response-normalization layers and the fifth convolutional layer. These overlapping (strides &amp;lt; kernel size) max-pooling layers helped in reducing overfitting.&lt;/p&gt;

&lt;h2&gt;
  
  
  Training
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Image Augmentation Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Translation and Horizontal Reflections&lt;/em&gt;: During training, network extracts random 227x227 patches (falsely mentioned as 224x224) and applies horizontal reflections. All these augmentations are performed on the fly on the CPU while the GPUs train previous batch of data.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Test Time Augmentations&lt;/em&gt;: During test time, the network predicts by extracting five 224 × 224 patches (the four corner patches and the center patch) as well as their horizontal reflections (hence ten patches in all), and averaging the predictions.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;PCA color augmentation&lt;/em&gt;: At first, PCA is performed on all pixels of ImageNet training data set. As a result, they get a 3x3 covariance matrix, as well as 3 eigenvectors and 3 eigenvalues. During training, a random intensity factor based on PCA components is added to each color channel of an image, which is equivalent to changing intensity and color of illumination.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Dropout:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Each hidden neuron in the first two fully-connected layers is set to zero with a probability of 0.5 during training. This means 'dropped out' neurons do not contribute to the forward pass and do not participate in back propagation. Although during testing, all neurons were active and were not dropped.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Kernel Initializer:&lt;/strong&gt; &lt;br&gt;
Zero-mean Gaussian distribution with a standard deviation of 0.01&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bias Initializer:&lt;/strong&gt; &lt;br&gt;
1 for second, fourth, fifth convolutional layers and the fully-connected hidden layers. Remaining layers with 0.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Batch Size:&lt;/strong&gt; &lt;br&gt;
128&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Optimizer:&lt;/strong&gt; &lt;br&gt;
Stochastic Gradient Descent with momentum 0.9&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L2 weight decay:&lt;/strong&gt; &lt;br&gt;
5e-04&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Learning Rate Manager:&lt;/strong&gt; &lt;br&gt;
LR initialized with value 1e-2 and manually reduced on a plateau by a factor of 10&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Total epochs:&lt;/strong&gt; &lt;br&gt;
90&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Total time:&lt;/strong&gt; &lt;br&gt;
6 days&lt;/p&gt;

&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;p&gt;Single AlexNet model achieves top-1 and top-5 test errors of 40.7% and 18.2% respectively.&lt;/p&gt;

&lt;p&gt;Their final submission comprised of an ensemble of 7 CNNs (average of 2 extended AlexNet pre-trained on 2011 dataset and then fine-tuned on 2012 dataset and an average of five AlexNet on 2012 dataset) which gave an error rate of &lt;strong&gt;15.3%,&lt;/strong&gt; lower by a margin of 11% than that of the runner-up (SIFT+FVs model by Fei-Fei et al.).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Foigjj4eiiz60w8a1ahqb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Foigjj4eiiz60w8a1ahqb.png" alt="Result" width="360" height="293"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thus, the world got its first Deep CNN based large database image recognition winner. The authors used several deep learning techniques which are still relevant and thus established a framework which is still followed to approach complex computer vision problems.&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
    </item>
    <item>
      <title>Share your local Jupyter Notebook on Internet for Free</title>
      <dc:creator>Zoheb Abai</dc:creator>
      <pubDate>Sat, 11 Jul 2020 13:00:11 +0000</pubDate>
      <link>https://dev.to/zohebabai/share-your-local-jupyter-notebook-on-internet-18do</link>
      <guid>https://dev.to/zohebabai/share-your-local-jupyter-notebook-on-internet-18do</guid>
      <description>&lt;p&gt;During this global lockdown, it's interesting to observe an upsurge in learning &lt;em&gt;python&lt;/em&gt; and in particular &lt;em&gt;machine learning&lt;/em&gt;. There are innumerable free online resources and teachers from where or whom you can learn, but all use a common open-source software (or its clone) - &lt;strong&gt;Jupyter Notebooks&lt;/strong&gt;. It's one of the most useful tools for all ranks of data scientists/engineers/analysts.&lt;/p&gt;

&lt;p&gt;While teaching online, the teachers either prerecord the sessions or consider taking sessions live. During live sessions most of the teachers use one of several video conferencing platforms, coding on their local machine (or ready-to-run notebooks) and share it live. This has two serious demerits - &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Internet penetration is still worse for many developing countries. So viewing code onscreen or receiving a clear audio is a still a distant dream for many.&lt;/li&gt;
&lt;li&gt;If students want to just run few lines of code or check their doubts regarding the code shared onscreen during sessions, they have no option to copy. It has to be either shared by the teacher before the session or the teacher has to pause for extra few minutes on each code blocks. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Being a teaching assistant myself for several data science courses, I have noticed few good and enthusiastic teachers discussing on the lack of free video conferencing with live code sharing platforms. There isn't any! &lt;/p&gt;

&lt;p&gt;Well, for now, an audio conference with live code sharing shall suffice.&lt;/p&gt;

&lt;p&gt;For live code sharing, one solution is very obvious - &lt;strong&gt;Google Colab Notebooks&lt;/strong&gt;. It's the best resource built for data science EVER!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8dx8642v8p0opswffly3.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8dx8642v8p0opswffly3.gif" alt="Kind of solved" width="498" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In this article&lt;/strong&gt; I shall provide you an alternate free option for live code sharing, which might help you. At the least, it's a good feature to know.&lt;/p&gt;

&lt;p&gt;You can share your local Jupyter notebooks live with a small group while hosting a session.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisite:
&lt;/h3&gt;

&lt;p&gt;You already have &lt;a href="https://jupyter.org/install" rel="noopener noreferrer"&gt;Jupyter notebooks&lt;/a&gt; installed locally.&lt;/p&gt;

&lt;h3&gt;
  
  
  Requirements:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Download &lt;a href="https://ngrok.com/download" rel="noopener noreferrer"&gt;ngrok&lt;/a&gt; locally.&lt;/li&gt;
&lt;li&gt;Follow all the steps mentioned till step 3.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Steps:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Before firing up the ngrok or a Jupyter notebook, run&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fah2gndpapnbelep3v3hw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fah2gndpapnbelep3v3hw.png" alt="Step 1" width="800" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Copy the address mentioned after &lt;code&gt;Writing default config to:&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fruv22ehv573nwswwugdp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fruv22ehv573nwswwugdp.png" alt="Step 2" width="800" height="201"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Then run the code below, replacing your address (from the step above) instead of mine.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Feudhwfbspx58g7nwojpv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Feudhwfbspx58g7nwojpv.png" alt="Step 3" width="800" height="161"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For a secured session, set the password for your Jupyter Notebook by running&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fnz7elmirigotvb66t8i4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fnz7elmirigotvb66t8i4.png" alt="Step 4" width="720" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fire up your Jupyter notebook and keep a note of the port&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqp1ie77173vboiv9pvdz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqp1ie77173vboiv9pvdz.png" alt="Step 5" width="800" height="305"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open a new tab in your terminal and fire up ngrok on your port&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fl7zggqstyqmjf332gma8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fl7zggqstyqmjf332gma8.png" alt="Step 6" width="586" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your terminal would show something similar to&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fots8vk7hxamvhsm6xb8f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fots8vk7hxamvhsm6xb8f.png" alt="Output" width="800" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy the HTTP link with ngrok.io at the end and share it with your group with the notebook password. You get an 8-hour session.&lt;br&gt;
Each time you write a new line/block of code in your notebook press Ctrl+S (Linux/Windows) or Cmd+S (macOS) to share the updated notebook. The group members have to refresh on their end to see those changes. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: As a host if you receive an alert like this&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5k15t6gi8v02l7gfg1nf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5k15t6gi8v02l7gfg1nf.png" alt="Alert" width="698" height="186"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just click &lt;code&gt;Overwrite&lt;/code&gt; so that whatever changes you make during the session remains intact for that session.&lt;/p&gt;

&lt;p&gt;That's how you share your code session live with a group for free while working on your local machine and simultaneously allowing your group to code on the notebook during the session and eventually letting them download the session notebook.&lt;/p&gt;

&lt;p&gt;Thanks to &lt;strong&gt;Project Jupyter&lt;/strong&gt; and &lt;strong&gt;ngrok&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Let me know if you have any better idea. &lt;/p&gt;

</description>
      <category>datascience</category>
      <category>machinelearning</category>
      <category>jupyter</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
