0

I have the following structure of the neural network, But I would like to modify it and colour all input nodes as black and write f(x) inside the hidden nodes. Kindly guide me on how to attain it.

enter image description here

to something like this

enter image description here

 \usetikzlibrary{positioning}
    \tikzset{%
      every neuron/.style={
        circle,
        draw,
        minimum size=1cm
      },
      neuron missing/.style={
        draw=none, 
        scale=4,
        text height=0.333cm,
        execute at begin node=\color{black}$\vdots$
      },
    }
    
    \begin{tikzpicture}[x=1.3cm, y=1.3cm, >=stealth]
    
    \foreach \m/\l [count=\y] in {1,2,3,missing,4}
      \node [every neuron/.try, neuron \m/.try] (input-\m) at (0,2.5-\y) {};
    
    \foreach \m [count=\y] in {1,missing,2}
      \node [every neuron/.try, neuron \m/.try ] (hidden-\m) at (2,2-\y*1.25) {};
    
    
    \foreach \m [count=\y] in {1,2,missing,3}
      \node [every neuron/.try, neuron \m/.try ] (output-\m) at (4,2.0-\y) {};
    
    \foreach \l [count=\i] in {1,2,3,j}
      \draw [<-] (input-\i) -- ++(-1,0)
        node [above, midway] {$I_\l_f$};
    
    \foreach \l [count=\i] in {1,k}
      \node [above] at (hidden-\i.north) {$H_\l_f$};
    
    
    \foreach \l [count=\i] in {1,2,l}
      \draw [->] (output-\i) -- ++(1,0)
        node [above, midway] {$O_\l_f$};
        
    \foreach \i in {1,...,4}
      \foreach \j in {1,...,2}
        \draw [->] (input-\i) -- (hidden-\j);
    
    \foreach \i in {1,...,2}
      \foreach \j in {1,...,3}
        \draw [->] (hidden-\i) -- (output-\j);
    
    \foreach \l [count=\x from 0] in {Input, Hidden, Output}
      \node [align=center, above] at (\x*2,2) {\l \\ layer};
    
    \end{tikzpicture}
1
  • would you like to accept and upvote the answer
    – js bibra
    Jun 25 at 1:02
2

enter image description here

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{positioning}
\begin{document}


\tikzset{%
    every neuron/.style={
        circle,
        draw,
        minimum size=1cm
    },
    neuron missing/.style={
        draw=none, fill=none,%<-----------------new
        scale=4,
        text height=0.333cm,
        execute at begin node=\color{black}$\vdots$
    },
}

\begin{tikzpicture}[x=1.3cm, y=1.3cm, >=stealth]
    
    \foreach \m/\l [count=\y] in {1,2,3,missing,4}
    \node [fill=black!20, every neuron/.try, neuron \m/.try, ] (input-\m) at (0,2.5-\y) {};%<-----fill=
    
    \foreach \m [count=\y] in {1,missing,2}
    \node [every neuron/.try, neuron \m/.try ] (hidden-\m) at (2,2-\y*1.25) {};
    
    
    \foreach \m [count=\y] in {1,2,missing,3}
    \node [every neuron/.try, neuron \m/.try ] (output-\m) at (4,2.0-\y) {};
    
    \foreach \l [count=\i] in {1,2,3,j}
    \draw [<-] (input-\i) -- ++(-1,0)
    node [above, midway] {$I$};
    
    \foreach \l [count=\i] in {1,k}
    \node [above] at (hidden-\i.north) {$H$};
    
    
    \foreach \l [count=\i] in {1,2,l}
    \draw [->] (output-\i) -- ++(1,0)
    node [above, midway] {$O$};
    
    \foreach \i in {1,...,4}
    \foreach \j in {1,...,2}
    \draw [->] (input-\i) -- (hidden-\j);
    
    \foreach \i in {1,...,2}
    \foreach \j in {1,...,3}
    \draw [->] (hidden-\i) -- (output-\j);
    
    \foreach \l [count=\x from 0] in {Input, Hidden, Output}
    \node [align=center, above] at (\x*2,2) {\l \\ layer};
    \node (nx1) at (hidden-1) {$\mathbf{f_x}$};%<---------------new
    \node (nx2) at (hidden-2) {$\mathbf{f_x}$};%<---------------new
\end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.