\begin{frame}
	\myheading{Module 13.4: Finding influence of input pixels using backpropagation}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}
	\begin{columns}
		\column{0.5\textwidth}
		\centering
		% \begin{figure}
		% \includegraphics[scale=0.17,trim={0 2cm 0 3cm},clip=true]{images/CatImage.jpg}
		% \end{figure}

		\input{modules/Module4/tikz_images/cnn_ff.tex}
		%\vspace{-0.5cm}
		\input{modules/Module4/tikz_images/cat_grid1.tex}

		\column{0.5\textwidth}
		\begin{overlayarea}{\textwidth}{\textheight}
			\begin{itemize}
				\justifying
				\onslide<1->{\item We can think of an image as a $m \times n$ inputs $x_0,x_1,\ldots, x_{m \times n}$}
				\onslide<2->{\item We are interested in finding the influence of each of these inputs($x_i$) on a given neuron($h_j$) }
				\onslide<3->{\item If a small change in $x_i$ causes a large change in $h_j$ then we can say that $x_i$ has a lot of influence of $h_j$}
				\onslide<4->{\item In other words the gradient $\frac{\partial h_j}{\partial x_i}$ could tell us about the influence}
			\end{itemize}
		\end{overlayarea}
	\end{columns}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}
	\begin{columns}
		\column{0.5\textwidth}
		\centering
		\input{modules/Module4/tikz_images/cnn_ff1.tex}
		%\vspace{-0.5cm}
		\input{modules/Module4/tikz_images/cat_grid2.tex}
		% \begin{figure}[hbtp]
		% \includegraphics[scale=0.17,trim={0 2cm 0 3cm},clip=true]{images/CatImage.jpg}
		% \end{figure}
		\column{0.5\textwidth}
		\begin{overlayarea}{\textwidth}{\textheight}
			\begin{align*}
				\onslide<1->{\frac{\partial h_j}{\partial x_i} & = 0     & \longrightarrow \text{   no influence}  \\}
				\onslide<2->{\frac{\partial h_j}{\partial x_i} & = large & \longrightarrow \text{ high influence}  \\}
				\onslide<3->{\frac{\partial h_j}{\partial x_i} & = small & \longrightarrow \text{ low influence} }
			\end{align*}

			\begin{itemize}
				\justifying
				\onslide<4->{\item We could just compute these partial derivatives w.r.t all the inputs}
				\onslide<5->{\item And then visualize this gradient matrix as an image itself}
			\end{itemize}
		\end{overlayarea}
	\end{columns}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}
	\begin{columns}
		\column{0.5\textwidth}
		\centering
		\only<1>{
			\input{modules/Module4/tikz_images/cnn_ff.tex}
			%\vspace{-0.5cm}
			\input{modules/Module4/tikz_images/cat_grid3.tex}
		}
		\only<2->{
			\input{modules/Module4/tikz_images/cnn_bf.tex}
			%\vspace{-0.5cm}
			\input{modules/Module4/tikz_images/cat_grid4.tex}
		}

		\column{0.5\textwidth}
		\begin{overlayarea}{\textwidth}{\textheight}
			\begin{itemize}
				\justifying
				\onslide<1->{\item But how do we compute these gradients?}
				\onslide<2->{\item Recall that we can represent CNNs by feedforward neural network}
				\onslide<3->{\item Then we already know how to compute influences (gradient) using backpropogation}
				\onslide<4->{\item For example, we know how to backprop the gradients till the first hidden layer}
				\onslide<5->{
					\footnotesize{
						\begin{align*}
							\frac{\partial h_{32}}{\partial x_{2}} & = \sum_{i=1}^{3} \frac{\partial h_{32}}{\partial h_{1i}} \frac{\partial h_{1i}}{\partial x_2} \\
							h_{1i}                                 & = \sum_{j=1}^{4} w_{ji}x_{j}                                                                  \\
							\frac{\partial h_{1i}}{\partial x_2}   & = w_{12}
						\end{align*}
				}}

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

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}
	\begin{columns}
		\column{0.5\textwidth}
		\centering
		\begin{figure}[hbtp]
			\includegraphics[scale=0.4]{images/2_4_1.png}
		\end{figure}


		\column{0.5\textwidth}
		\begin{overlayarea}{\textwidth}{\textheight}
			\begin{itemize}
				\justifying
				\item<1-> This is what we get if we compute the gradients and plot it as an image
				\onslide<2->{\item The above procedure does not show very sharp influences }

				\onslide<3->{\item Springenberg et al. proposed ``guided back propagation'' which gives a better idea about the influences}
			\end{itemize}
		\end{overlayarea}
	\end{columns}
\end{frame}
