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

\tikzstyle{input}=[circle,draw=black!50,fill=black!20,thick,minimum size=6mm]
\hspace*{-50pt}\begin{tikzpicture}
  \newcommand*{\xbase}{-1}
  \node (neuron01l) at (\xbase+7.5,4) {\small $x_1$};
  \node (neuron02l) at (\xbase+8.5,4) {\small $x_2$};
  \node (neuron03l) at (\xbase+9.5,4) {\small $x_3$};
  \node (neuron04l) at (\xbase+10.5,4) {\small $x_4$};

  \node [input_neuron] (neuron01) at (\xbase+7.5,4.5) {};
  \node [input_neuron] (neuron02) at (\xbase+8.5,4.5) {};
  \node [input_neuron] (neuron03) at (\xbase+9.5,4.5) {};
  \node [input_neuron] (neuron04) at (\xbase+10.5,4.5) {};

  \node [hidden_neuron] (neuron11) at (\xbase+7,6)    {};
  \node [hidden_neuron] (neuron12) at (\xbase+8,6)    {};
  \node [hidden_neuron] (neuron13) at (\xbase+9,6)    {};
  \node [hidden_neuron] (neuron14) at (\xbase+10,6)   {};
  \node [hidden_neuron] (neuron15) at (\xbase+11,6)   {};

  \node [hidden_neuron] (neuron21) at (\xbase+7, 7.5) {};
  \node [hidden_neuron] (neuron22) at (\xbase+8, 7.5) {};
  \node [hidden_neuron] (neuron23) at (\xbase+9, 7.5) {};
  \node [hidden_neuron] (neuron24) at (\xbase+10,7.5) {};
  \node [hidden_neuron] (neuron25) at (\xbase+11,7.5) {};

  \node [output_neuron] (neuron31) at (\xbase+7.5,9)  {};
  \node [output_neuron] (neuron32) at (\xbase+8.5,9)  {};
  \node [output_neuron] (neuron33) at (\xbase+9.5,9)  {};
  \node [output_neuron] (neuron34) at (\xbase+10.5,9)  {};
  \node (neuron31l) at (\xbase+7.5,9.5) {\small $\hat{x}_1$};
  \node (neuron32l) at (\xbase+8.5,9.5) {\small $\hat{x}_2$};
  \node (neuron33l) at (\xbase+9.5,9.5) {\small $\hat{x}_3$};
  \node (neuron33l) at (\xbase+10.5,9.5) {\small $\hat{x}_4$};

  \node (W1) at (\xbase+6.75,5.2) {$\mathbf{W}^1$};
  \foreach \x in {1,...,4}
      \foreach \y in {1,...,5}  
        \draw[->,thick] (neuron0\x) -- (neuron1\y);

  \node (W2) at (\xbase+6.5,6.7) {$\mathbf{W}^2$};
  \foreach \x in {1,...,5}
      \foreach \y in {1,...,5}  
        \draw[->,thick] (neuron1\x) -- (neuron2\y);

  \node (V) at (\xbase+6.75,8.2) {$\mathbf{V}$};
  \foreach \x in {1,...,5}
      \foreach \y in {1,...,4}  
        \draw[->,thick] (neuron2\x) -- (neuron3\y);


  \node (masks) at (12,9.5) {\textbf{Masks}};

  \def\MASKA{0,1,2,3}
  \def\MASKB{1,1,2,1,3}
  \def\MASKC{1,2,1,2,3}
  \def\MASKD{1,2,3,4}

  \node (mask1) at (12,8.5) {
    \begin{tikzpicture}[scale=0.35, every node/.style={scale=0.35}]
      \newcommand*{\size}{1cm}%
      \tikzstyle{box}=[rectangle,draw=gray, thin, minimum size=\size]
      \foreach \x in {0,...,4}{
          \foreach \y in {0,...,3}
              \node[box] at (11+\x,8-\y) {};
      }
      \foreach \y [count=\yi] in \MASKA {
        \foreach \x [count=\xi] in \MASKB {
            \ifnum \y<\x %
            \else %
              \node[box,fill=black] at (11+\xi-1,8-\yi+1){};  
            \fi
          }
        }

      \node at (11+5.5,8-1.3) {\scalebox{2}{$=\mathbf{M}^\mathbf{V}$}};
    \end{tikzpicture}
  };

  \node (mask2) at (12,6.7) {
    \begin{tikzpicture}[scale=0.35, every node/.style={scale=0.35}]
      \newcommand*{\size}{1cm}%
      \tikzstyle{box}=[rectangle,draw=gray, thin, minimum size=\size]
      \foreach \x in {0,...,4}{
          \foreach \y in {0,...,4}
              \node[box] at (11+\x,8-\y) {};
      }
      \foreach \y [count=\yi] in \MASKB {
        \foreach \x [count=\xi] in \MASKC {
            \ifnum \y<\x %
            \else %
              \node[box,fill=black] at (11+\xi-1,8-\yi+1){};  
            \fi
          }
        }
      \node at (11+5.5,8-1.3) {\scalebox{2}{$=\mathbf{M}^{\mathbf{W}^2}$}};
    \end{tikzpicture}
  };

  \node (mask3) at (12,4.7) {
    \begin{tikzpicture}[scale=0.35, every node/.style={scale=0.35}]
      \newcommand*{\size}{1cm}%
      \tikzstyle{box}=[rectangle,draw=gray, thin, minimum size=\size]
      \foreach \x in {0,...,3}{
          \foreach \y in {0,...,4}
              \node[box] at (11+\x,8-\y) {};
      }
      \foreach \y [count=\yi] in \MASKC {
        \foreach \x [count=\xi] in \MASKD {
            \ifnum \y<\x %
            \else %
              \node[box,fill=black] at (11+\xi-1,8-\yi+1){};  
            \fi
          }
        }
      \node at (11+5.5,8-1.3) {\scalebox{2}{$=\mathbf{M}^{\mathbf{W}^1}$}};
    \end{tikzpicture}
  };

 % \draw[
 %      -triangle 90,
 %      line width=4mm,
 %      postaction={draw, line width=0.2cm, shorten >=1cm, -}
 %  ] (13,6) -- (15,6);
  \renewcommand*{\xbase}{7}
  \node (Xneuron01l) at (\xbase+7.5,4) {\small $x_1$};
  \node (Xneuron02l) at (\xbase+8.5,4) {\small $x_2$};
  \node (Xneuron03l) at (\xbase+9.5,4) {\small $x_3$};
  \node (Xneuron03l) at (\xbase+10.5,4) {\small $x_4$};
    \node [input_neuron] (Xneuron01) at (\xbase+7.5,4.5) {1};
    \node [input_neuron] (Xneuron02) at (\xbase+8.5,4.5) {2};
    \node [input_neuron] (Xneuron03) at (\xbase+9.5,4.5) {3};
    \node [input_neuron] (Xneuron04) at (\xbase+10.5,4.5) {4};
    \node [hidden_neuron] (Xneuron11) at (\xbase+7,6)    {1};
    \node [hidden_neuron] (Xneuron12) at (\xbase+8,6)    {2};
    \node [hidden_neuron] (Xneuron13) at (\xbase+9,6)    {1};
    \node [hidden_neuron] (Xneuron14) at (\xbase+10,6)   {2};
    \node [hidden_neuron] (Xneuron15) at (\xbase+11,6)   {3};

    \node [hidden_neuron] (Xneuron21) at (\xbase+7, 7.5) {1};
    \node [hidden_neuron] (Xneuron22) at (\xbase+8, 7.5) {1};
    \node [hidden_neuron] (Xneuron23) at (\xbase+9, 7.5) {2};
    \node [hidden_neuron] (Xneuron24) at (\xbase+10,7.5) {1};
    \node [hidden_neuron] (Xneuron25) at (\xbase+11,7.5) {3};
    \node [output_neuron] (Xneuron31) at (\xbase+7.5,9)  {1};
    \node [output_neuron] (Xneuron32) at (\xbase+8.5,9)  {2};
    \node [output_neuron] (Xneuron33) at (\xbase+9.5,9)  {3};
    \node [output_neuron] (Xneuron34) at (\xbase+10.5,9) {4};

  \node [rotate=45, text width=1.5] (Xneuron31l) at (\xbase+7.5, 9.5) {\small $p(x_1)$};
  \node [rotate=45, text width=1.5] (Xneuron32l) at (\xbase+8.5, 9.5) {\small $p(x_2|x_1)$};
  \node [rotate=45, text width=1.5] (Xneuron33l) at (\xbase+9.5, 9.5) {\small $p(x_3|x_1,x_2)$};
  \node [rotate=45, text width=1.5] (Xneuron34l) at (\xbase+10.5,9.5) {\small $p(x_4|x_1,x_2,x_3)$};

  \foreach \y [count=\yi] in \MASKC {
    \foreach \x [count=\xi] in \MASKD {
        \ifnum\y<\x %
        \else %
          \draw[->,thick,black] (Xneuron0\xi) -- (Xneuron1\yi);
        \fi
      }
    }

  \foreach \y [count=\yi] in \MASKB {
    \foreach \x [count=\xi] in \MASKC {
        \ifnum\y<\x %
        \else %
          \draw[->,thick,black] (Xneuron1\xi) -- (Xneuron2\yi);
        \fi
      }
    }

  \foreach \y [count=\yi] in \MASKA {
    \foreach \x [count=\xi] in \MASKB {
        \ifnum\y<\x %
        \else %
          \draw[->,thick,black] (Xneuron2\xi) -- (Xneuron3\yi);
        \fi
      }
    }
\end{tikzpicture}  