nn_layers


\documentclass[border=0.1cm]{standalone}

\usepackage{scalerel}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{shapes,snakes}
\usetikzlibrary{calc, shapes.geometric,shapes.symbols,fit,positioning,shadows, arrows,automata}

\usepackage{listofitems} % for \readlist to create arrays
\usetikzlibrary{arrows.meta} % for arrow size
\usepackage[outline]{contour} % glow around text
\contourlength{1.4pt}

\tikzset{>=latex} % for LaTeX arrow head
\colorlet{myred}{red!80!black}
\colorlet{myblue}{blue!80!black}
\colorlet{mygreen}{green!60!black}
\colorlet{myorange}{orange!70!red!60!black}
\colorlet{mydarkred}{red!30!black}
\colorlet{mydarkblue}{blue!40!black}
\colorlet{mydarkgreen}{green!30!black}
\tikzstyle{node}=[thick,circle,draw=myblue,minimum size=22,inner sep=0.5,outer sep=0.6]
\tikzstyle{node in}=[node,green!20!black,draw=mygreen!30!black,fill=mygreen!25]
\tikzstyle{node hidden}=[node,blue!20!black,draw=myblue!30!black,fill=myblue!20]
\tikzstyle{node convol}=[node,orange!20!black,draw=myorange!30!black,fill=myorange!20]
\tikzstyle{node out}=[node,red!20!black,draw=myred!30!black,fill=myred!20]
\tikzstyle{connect}=[thick,black] %,line cap=round
\tikzstyle{connect arrow}=[-{Latex[length=4,width=3.5]},thick]





\begin{document}
	\begin{tikzpicture}[x=2.7cm,y=1.6cm]
	\def\NI{5} % n nodes in input layers
	\def\NO{4} % n nodes in output layers
	\def\NH{3} % n nodes in hidden layer
	\def\yshift{0.4} % shift last node for dots
	
	% INPUT LAYER
	\foreach \i [evaluate={\c=int(\i==\NI); \y=\NI/2-\i-\c*\yshift; \index=(\i<\NI?int(\i):"n");}]
	in {1,...,\NI}
	{
		\node[node in,outer sep=0.6] (NI-\i) at (0,\y) {$a_{\index}^{(l-1)}$};
	}
	
	
	
	% HIDDEN LAYER
	\foreach \i [evaluate={\c=int(\i==\NH); \y=\NH/2-\i-\c*\yshift; \index=(\i<\NH?int(\i):"m");}] 
	in {\NH,...,1}
	{
		\ifnum\i=1 % highlighted node
			\node[node hidden] (NH-\i) at (1,\y) {$a_{\index}^{(l)}$};
			\foreach \j [evaluate={\index=(\j<\NI?int(\j):"n");}] in {1,...,\NI}
			{
				\draw[connect arrow] (NI-\j) -- (NH-\i)
				node[pos=0.50] {\contour{white}{$W^{(l-1)}_{\index, 1}$}};
			}
		\else
			\node[node,blue!20!black!80,draw=myblue!20,fill=myblue!5]
			(NH-\i) at (1,\y) {$a_{\index}^{(l)}$};
			\foreach \j in {1,...,\NI}
			{
				\draw[connect,myblue!20] (NI-\j) -- (NH-\i);
			}
		\fi
	}
	
	% OUTPUT LAYER
	\foreach \i [evaluate={\c=int(\i==\NO); \y=\NO/2-\i-\c*\yshift; \index=(\i<\NO?int(\i):"k");}]
	in {1,...,\NO}{ % loop over nodes
		\node[node out] (NO-\i) at (2,\y) {$a_{\index}^{(l+1)}$};
		\foreach \j in {1,...,\NH}
		{
			\ifnum\j=1
				\draw[connect arrow] (NH-\j) -- (NO-\i) node[pos=0.50] {\contour{white}{$W^{(l)}_{1,\index}$}};
			\else
				\draw[connect,myred!20] (NH-\j) -- (NO-\i);
			\fi
			
		}
	}
	
	% DOTS
	\path (NI-\NI) --++ (0,1+\yshift) node[midway,scale=1.2] {$\vdots$};
	\path (NH-\NH) --++ (0,1+\yshift) node[midway,scale=1.2] {$\vdots$};
	\path (NO-\NO) --++ (0,1+\yshift) node[midway,scale=1.2] {$\vdots$};
	\end{tikzpicture}
\end{document}