\begin{frame}
	\myheading{Module 16.4: Attention over images}
\end{frame}

\begin{frame}
  \begin{columns}
    \column{0.45\textwidth}
      \begin{overlayarea}{\textwidth}{\textheight}
      \vspace{0.3cm}
      \centering
        \only<1>{
          \centering
          \input{modules/Module4/tikz_images/rnn3} }
        \only<2>{
          \centering
          \input{modules/Module4/tikz_images/mt_attn_no_anim}
         }
        \only<3->{
          \centering
          \input{modules/Module4/tikz_images/rnn8_mod}
        }
      \end{overlayarea}

    \column{0.55\textwidth}
      \begin{overlayarea}{\textwidth}{\textheight}
        \begin{itemize}\justifying
          \item<1-> How do we model an attention mechanism for images?

          \item<2-> In the case of text we have a representation for every location (time step) of the input sequence

          \item<3-> But for images we typically use representation from one of the fully connected layers

          \item<4-> This representation does not contain any location information

          \item<5-> So then what is the input to the attention mechanism?
        \end{itemize}
      \end{overlayarea}
  \end{columns}
\end{frame}

\begin{frame}
  \begin{columns}

    \column{0.5\textwidth}
       \vspace{2cm}

   \only<1-2>{
     \input{modules/Module4/tikz_images/vgg_net}
     }
    \only<3>{
\begin{tikzpicture}[scale= 1, transform shape]
\onslide<1->{

\node [rectangle, minimum height=10mm, minimum width=3mm, fill=blue!50, draw=black] (A1) at (0,1){};
\node [rectangle, minimum height=10mm, minimum width=3mm, fill=blue!50, draw=black] (A2) at (1,1){};
\node at (2,0.5) {\dots};
\node at (0,0.3) {1};
\node at (1,0.3) {2};
\node at (3,0.3) {196};
\node [rectangle, minimum height=10mm, minimum width=3mm, fill=blue!50, draw=black] (A3) at (3,1){};
\draw [decorate,decoration={brace,amplitude=4pt},xshift=-4pt,yshift=0pt]
(-0.2,0.5) -- (-0.2,1.5) node [black,midway,xshift=-0.6cm]
{\footnotesize $512$};
            }
    \node at (1.5,-1) {\input{modules/Module4/tikz_images/cuboid}};
              \end{tikzpicture}
      }
          \only<4->{
            \begin{tikzpicture}[scale= 1, transform shape]
            \onslide<1->{

              \node [rectangle, minimum height=10mm, minimum width=3mm, fill=blue!50, draw=black] (A) at (0,1){};
              \node [rectangle, minimum height=10mm, minimum width=3mm, fill=blue!50, draw=black] (A) at (1,1){};
              \node at (2,0.5) {\dots};
              \node at (0,0.3) {1};
              \node at (1,0.3) {2};
              \node at (3,0.3) {196};
              \node [rectangle, minimum height=10mm, minimum width=3mm, fill=blue!50, draw=black] (A) at (3,1){};
              \draw [decorate,decoration={brace,amplitude=4pt},xshift=-4pt,yshift=0pt]
              (-0.2,0.5) -- (-0.2,1.5) node [black,midway,xshift=-0.6cm]
              {\footnotesize $512$};
   \node[circle, minimum width=0.15mm, align=center, draw=black] (M) at (1.5,2.5){\tiny $+$};
   \draw [dashed] (0,1.5)-- (M);
   \draw [dashed] (3,1.5)-- (M);
   \draw [dashed] (0.9,1.5)-- (M);
   \node at (0.1,1.75) {$\alpha_{t1}$};
   \node at (3.1,1.75) {$\alpha_{t196}$};
    \node at (1.5,-1) {\input{modules/Module4/tikz_images/cuboid}};
            }
            \end{tikzpicture}
          }
    \column{0.5\textwidth}
    \begin{overlayarea}{\textwidth}{\textheight}

      \begin{itemize}\justifying
        \small
        \item<1-> Well, instead of the fc7 representation we use the output of one of the convolution layers which has spatial information

        \item<2-> For example the output of the $5^{th}$ convolutional layer of VGGNet is a $14 \times 14 \times 512$ size feature map

        \item<3-> We could think of this as 196 locations (each having a 512 dimensional representation)

        \item<4->The model will then learn an attention over these locations (which in turn correspond to actual locations in the images)


      \end{itemize}

    \end{overlayarea}
  \end{columns}
\end{frame}

\begin{frame}

  \begin{itemize}\justifying

    \item Let us look at some examples of attention over images for the task of image captioning

  \end{itemize}

\end{frame}


\begin{frame}
\begin{figure}
  \includegraphics[scale=0.5]{images/fig5.png}
  \caption{Examples of the attention-based model attending to the correct object (\textit{white} indicates the attended regions,\textit{underlines} indicates the corresponding word) [\href{https://arxiv.org/pdf/1507.01053.pdf}{Kyunghyun Cho et al.  2015}.]  }
  \end{figure}
\end{frame}
