\tikzstyle{neuron}=[circle,draw=red!50,fill=red!50,thick,minimum size=6mm]
\tikzstyle{neuron_red}=[circle,draw=red!50,fill=red!50,thick,minimum size=6mm]
\tikzstyle{neuron_green}=[circle,draw=green!50,fill=green!50,thick,minimum size=6mm]
\tikzstyle{neuron_blue}=[circle,draw=blue!50,fill=blue!50,thick,minimum size=6mm]
\tikzstyle{neuron_brown}=[circle,draw=brown!50,fill=brown!50,thick,minimum size=6mm]
\tikzstyle{neuron_gray}=[circle,draw=gray!20,fill=gray!20,thick,minimum size=6mm]

\tikzstyle{hidden_neuron}=[circle,draw=blue!50,fill=cyan!10,thick,minimum size=4mm]
\tikzstyle{output_neuron}=[circle,draw=green!50,fill=green!10,thick,minimum size=6mm]

\begin{tikzpicture}
  %%%% Neurons
  \only<1-3>
  {
    \visible<2->
    {
      \node [neuron_red]   (neuron1) at (0.0,0)  {\small $x_1$};
      \node [neuron_green] (neuron2) at (1.5,0)  {\small $x_2$};
      \node [neuron_blue]  (neuron3) at (3.0,0)  {\small $x_3$};
      \node [neuron_brown]  (neuron4) at (4.5,0) {\small $x_4$};
    }

    \node [neuron_red]   (oneuron1) at (0.0,6) {};
    \node [neuron_green] (oneuron2) at (1.5,6) {};
    \node [neuron_blue]  (oneuron3) at (3.0,6) {};
    \node [neuron_brown] (oneuron4) at (4.5,6) {};

    \node [rotate=30, text width=1.5](oneuron1l) at (0.0-0.5,6.6) {\small $p(x_1)$};
    \node [rotate=30, text width=1.5](oneuron2l) at (1.5-0.5,6.6) {\small $p(x_2|x_1)$};
    \node [rotate=30, text width=1.5](oneuron3l) at (3.0-0.5,6.6) {\small $p(x_3|x_1,x_2)$};
    \node [rotate=30, text width=1.5](oneuron4l) at (4.5-0.5,6.6) {\small $p(x_4|x_1,x_2,x_3)$};

    \def\HIDDEN{$h_1$,$h_2$,$h_3$,$h_4$}
    \newcommand*{\xpos}{0}
    \newcommand*{\rectstarty}{1.3}
    \newcommand*{\rectendy}{4.7}

    %%%% Labels
    \node[white,text width=2] (V) at (-0-1,\rectendy+0.4) {\scalebox{1.5}{$V_3$}};
    \node[white,text width=2] (W) at (-0-1,\rectstarty-0.4) {\scalebox{1.5}{$W_{.,<k}$}};
  }

  \only<4->
  {
    \node [neuron_red]   (neuron1) at (0.0,0) {\small $x_1$};
    \node [neuron_green] (neuron2) at (1.5,0) {\small $x_2$};
    \node [neuron_gray]  (neuron3) at (3.0,0) {\small $x_3$};
    \node [neuron_gray]  (neuron4) at (4.5,0) {\small $x_4$};

    \node [neuron_gray]   (oneuron1) at (0.0,6) {};
    \node [neuron_gray] (oneuron2) at (1.5,6) {};
    \node [neuron_blue]  (oneuron3) at (3.0,6) {};
    \node [neuron_gray] (oneuron4) at (4.5,6) {};

    \node [rotate=30, text width=1.5](oneuron1l) at (0.0-0.5,6.6) {\small $p(x_1)$};
    \node [rotate=30, text width=1.5](oneuron2l) at (1.5-0.5,6.6) {\small $p(x_2|x_1)$};
    \node [rotate=30, text width=1.5](oneuron3l) at (3.0-0.5,6.6) {\small $p(x_3|x_1,x_2)$};
    \node [rotate=30, text width=1.5](oneuron4l) at (4.5-0.5,6.6) {\small $p(x_4|x_1,x_2,x_3)$};

    \def\HIDDEN{$h_1$,$h_2$,$h_3$,$h_4$}
    \newcommand*{\xpos}{0}
    \newcommand*{\rectstarty}{1.3}
    \newcommand*{\rectendy}{4.7}
    %%%% Labels
    \node[white,text width=2] (V) at (-0-1,\rectendy+0.4) {\scalebox{1.5}{$V_3$}};
    \node[white,text width=2] (W) at (-0-1,\rectstarty-0.4) {\scalebox{1.5}{$W_{.,<k}$}};
  }
\end{tikzpicture}