I am a new user of TikZ and seeking help with this. I am trying to draw an autoassoicative neural network as illustrated in the figure below in terms of number of units and label with each layer fully connected to the one after.
Im stuck . I couldn't figure how to specify each hidden layer seperately. It ends up over-writing the hidden layer specs and fully connecting to the last hidden layer while the others remain unconnected as shown below.

Here is the code:
\documentclass[border=0.125cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\tikzset{%
neuron missing/.style={
draw=none,
scale=2,
text height=0.333cm,
execute at begin node=\color{black}$\vdots$
},
}
\begin{tikzpicture}[x=1.5cm, y=1.5cm, >=stealth]
\newcommand\Nhidden{3}
% First three nodes in Input Layer
\foreach \m/\l [count=\y] in {1,2,3}
{
\node [circle,fill=green!50,minimum size=1cm] (input-\m) at (0,2.5-\y) {};
}
% Last node in Input Layer
\foreach \m/\l [count=\y] in {4}
{
\node [circle,fill=green!50,minimum size=1cm ] (input-\m) at (0,-2.5) {};
}
% The missing nodes in Input Layer
\node [neuron missing] at (0,-1.5) {};
%%%%%%
% First node in Hidden Layer#1 (Mapping)
\foreach \m [count=\y] in {1,2,3,4,5,6}
\node [circle,fill=red!50,minimum size=1cm ] (hidden-\m) at (2,0.75) {};
% Last node in Hidden Layer#1 (Mapping)
\foreach \m [count=\y] in {7}
\node [circle,fill=red!50,minimum size=1cm ] (hidden-\m) at (2,-1.85) {};
% The missing nodes in Hidden Layer#1 (Mapping)
\node [neuron missing] at (2,-0.3) {};
%%%%%%%
% First node in Hidden Layer#2 (Bottleneck)
\foreach \m [count=\y] in {1}
\node [circle,fill=blue!50,minimum size=1cm ] (hidden-\m) at (4,1.5-\y) {};
% Last node in Hidden Layer#2 (Bottleneck)
\foreach \m [count=\y] in {2}
\node [circle,fill=blue!50,minimum size=1cm ] (hidden-\m) at (4,-0.5-\y) {};
% The missing nodes in Hidden Layer#2 (Bottleneck)
\node [neuron missing] at (4,-0.4) {};
%%%%%%%
% First node in Hidden Layer#3 (De-Mapping)
\foreach \m [count=\y] in {1,2,3,4,5,6}
\node [circle,fill=red!50,minimum size=1cm ] (hidden-\m) at (6,0.75) {};
% Last node in Hidden Layer#3 (De-Mapping)
\foreach \m [count=\y] in {7}
\node [circle,fill=red!50,minimum size=1cm ] (hidden-\m) at (6,-1.85) {};
% The missing nodes in Hidden Layer#1 (De-Mapping)
\node [neuron missing] at (6,-0.3) {};
%%%%%%%
% First three nodes in Output Layer
\foreach \m/\l [count=\y] in {1,2,3}
{
\node [circle,fill=green!50,minimum size=1cm] (output-\m) at (8,2.5-\y) {};
}
% Last node in Output Layer
\foreach \m/\l [count=\y] in {4}
{
\node [circle,fill=green!50,minimum size=1cm ] (output-\m) at (8,-2.5) {};
}
% The missing nodes in Output Layer
\node [neuron missing] at (8,-1.5) {};
%%%%%%%%%%------------------------------------
\foreach \l [count=\i] in {1,2,3,n}
\draw [<-] (input-\i) -- ++(-1,0)
node [above, midway] {$X_{\l}$};
\foreach \N in {1,...,\Nhidden} {
\foreach \l [count=\i] in {1,2,3,4,5,6,k}
\node [above] at (hidden-\i.north) {$H_{m\l}$};
\foreach \l [count=\i] in {1,f}
\draw [->] (hidden-\i) -- ++(1,0)
node [above, midway] {$T_{ \l}$};
\foreach \l [count=\i] in {1,2,3,4,5,6,k}
\node [above] at (hidden-\i.north) {$H_{d\l}$};
}
\foreach \l [count=\i] in {1,2,3,n}
\draw [->] (output-\i) -- ++(1,0)
node [above, midway] {$Y_{\l}$};
\foreach \i in {1,...,4}
\foreach \j in {1,...,7}
\draw [->] (input-\i) -- (hidden-\j);
\foreach \i in {1,...,7}
\foreach \j in {1,...,4}
\draw [->] (hidden-\i) -- (output-\j);
\end{tikzpicture}
\end{document}
Code is based on https://www.overleaf.com/latex/examples/neural-network-color/jwsbrhgwmgmt#.WyDQpKczbIV
I really appricate your help. Thank you.

