%% -*- mode: latex; mode: reftex; mode: flyspell; coding: utf-8; tex-command: "pdflatex.sh" -*-

\documentclass[11pt,a4paper,twoside]{article}
\usepackage[a4paper,top=2.5cm,bottom=2cm,left=2.5cm,right=2.5cm]{geometry}
\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue,citecolor=blue]{hyperref}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{dsfont}
\usepackage{tikz}
\usetikzlibrary{arrows,arrows.meta,calc}
\usetikzlibrary{patterns,backgrounds}
\usetikzlibrary{positioning,fit}
\usetikzlibrary{shapes.geometric,shapes.multipart}
\usetikzlibrary{patterns.meta,decorations.pathreplacing,calligraphy}
\usetikzlibrary{tikzmark}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{pgfplots}
\usepgfplotslibrary{patchplots,colormaps}
\pgfplotsset{compat = newest}


\begin{document}

\definecolor{blue}{rgb}{0.3,0.5,0.85}
\definecolor{red}{rgb}{0.65,0.0,0.0}

\begin{figure}

  \immediate\write18{./warp.py --result_dir=.}

  \newcommand{\warp}[1]{%
    \begin{tikzpicture}
      \begin{axis}[ticks=none,width=7.0cm, height=7.0cm,xmin=-1.2,xmax=1.2,ymin=-1.2,ymax=1.2]
        \input{#1}
      \end{axis}
    \end{tikzpicture}
  }

  \center

  \begin{tikzpicture}[warp/.style={inner sep=1pt,minimum width=5.0cm,minimum height=5.0cm}]
    \node[warp]                 (W0) {\warp{warp_0.tex}};
    \node[warp,right=2pt of W0] (W1) {\warp{warp_1.tex}};
    \node[warp,right=2pt of W1] (W2) {\warp{warp_2.tex}};
    \node[warp,below=20pt of W0] (W3) {\warp{warp_3.tex}};
    \node[warp,right=2pt of W3] (W4) {\warp{warp_4.tex}};
    \node[warp,right=2pt of W4] (W5) {\warp{warp_5.tex}};
    \node[warp,below=20pt of W3] (W6) {\warp{warp_6.tex}};
    \node[warp,right=2pt of W6] (W7) {\warp{warp_7.tex}};
    \node[warp,right=2pt of W7] (W8) {\warp{warp_8.tex}};
    \node[inner sep=0pt,below=4pt of W0] (lW0) {\footnotesize Input};
    \foreach \n in {1,...,8}{
      \node[inner sep=0pt,below=4pt of W\n] (lW\n) {\footnotesize Layer \#\n};
    };

  \end{tikzpicture}

  \caption[Feature warping]{Each plot shows the deformation of the space
    and the resulting distribution of the training points in
    $\mathbb{R}^2$ corresponding to the output of each layer, starting
    with the input in the top-left square. The thick oblique line in the
    bottom-right plot shows the final affine decision.}\label{fig:warp}

\end{figure}

\end{document}
