I would like to draw like this :

My current code is
\begin{figure}
\centering
\label{fig:nn2}
\begin{tikzpicture}[shorten >=1pt,->,draw=black!50, node distance=\layersep]
\tikzstyle{every pin edge}=[<-,shorten <=1pt]
\tikzstyle{neuron}=[circle,fill=black!25,minimum size=17pt,inner sep=0pt]
\tikzstyle{input neuron}=[neuron, fill=green!50];
\tikzstyle{output neuron}=[neuron, fill=red!50];
\tikzstyle{hidden neuron}=[neuron, fill=blue!50];
\tikzstyle{annot} = [text width=4em, text centered]
% Draw the input layer nodes
\foreach \name / \y in {1,...,4}
% This is the same as writing \foreach \name / \y in {1/1,2/2,3/3,4/4}
%\if \y in {1,2,3,4}
\node[input neuron, pin=left:Input \#\y] (I-\name) at (0,-\y) {$x_{\name}$};
%\else
%\node[input neuron, pin=left:Input \#\y] (I-\name) at (0,-\y) {$x_{\name}$};
%\node[input neuron, pin=left:Input \#4] (+1) at (0,-4) {$x_{\name}$};
% Draw the hidden layer nodes
\foreach \name / \y in {1,...,4}
\path[yshift=0.5cm]
node[hidden neuron] (H-\name) at (\layersep,-\y cm) {$h_{\name}$};
% Draw the output layer node
\node[output neuron,pin={[pin edge={->}]right:Output}, right of=H-3] (O) {$y_{0}$};
% Connect every node in the input layer with every node in the
% hidden layer.
\foreach \source in {1,...,4}
\foreach \dest in {1,...,4}
\path (I-\source) edge (H-\dest);
% Connect every node in the hidden layer with the output layer
\foreach \source in {1,...,4}
\path (H-\source) edge (O);
% Annotate the layers
\node[annot,above of=H-1, node distance=1cm] (hl) {Hidden layer};
\node[annot,left of=hl] {Input layer};
\node[annot,right of=hl] {Output layer};
\end{tikzpicture}
\caption{A figure shows the structure of a general neural networks model}
\end{figure}
I try to use "if-else". and after revising, my code is:
\begin{figure}
\centering
\label{fig:nn2}
\begin{tikzpicture}[shorten >=1pt,->,draw=black!50, node distance=\layersep]
\tikzstyle{every pin edge}=[<-,shorten <=1pt]
\tikzstyle{neuron}=[circle,fill=black!25,minimum size=17pt,inner sep=0pt]
\tikzstyle{input neuron}=[neuron, fill=green!50];
\tikzstyle{output neuron}=[neuron, fill=red!50];
\tikzstyle{hidden neuron}=[neuron, fill=blue!50];
\tikzstyle{annot} = [text width=4em, text centered]
% Draw the input layer nodes
\foreach \name / \y in {1,...,4}
% This is the same as writing \foreach \name / \y in {1/1,2/2,3/3,4/4}
\if \y in {1,2,3,4}
\node[input neuron, pin=left:Input \#\y] (I-\name) at (0,-\y) {$x_{\name}$};
\else
%\node[input neuron, pin=left:Input \#\y] (I-\name) at (0,-\y) {$x_{\name}$};
%\node[input neuron, pin=left:Input \#4] (+1) at (0,-4) {$x_{\name}$};
% Draw the hidden layer nodes
\foreach \name / \y in {1,...,4}
\path[yshift=0.5cm]
node[hidden neuron] (H-\name) at (\layersep,-\y cm) {$h_{\name}$};
% Draw the output layer node
\node[output neuron,pin={[pin edge={->}]right:Output}, right of=H-3] (O) {$y_{0}$};
% Connect every node in the input layer with every node in the
% hidden layer.
\foreach \source in {1,...,4}
\foreach \dest in {1,...,4}
\path (I-\source) edge (H-\dest);
% Connect every node in the hidden layer with the output layer
\foreach \source in {1,...,4}
\path (H-\source) edge (O);
% Annotate the layers
\node[annot,above of=H-1, node distance=1cm] (hl) {Hidden layer};
\node[annot,left of=hl] {Input layer};
\node[annot,right of=hl] {Output layer};
\end{tikzpicture}
\caption{A figure shows the structure of a general neural networks model}
\end{figure}
however, there is an error: Extra }, or forgotten \endgroup
Thank you!

