# How to draw the diagram of additive model of a neuron by Tikz in Latex?

I want to draw the diagram, as attached in the image, with Tikz in latex. I tried by myself to do it but I couldn't get success. My Tikz code is attached here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,chains,positioning,decorations.pathreplacing,arrows,calc}
\usepackage{pgfplots}
\usepackage{circuitikz}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[
init/.style={
draw,
circle,
inner sep=8pt,
font=\Huge,
join = by -latex
},
squa/.style={
draw,
font=\Large,
join = by -latex
},
start chain=3,node distance=13mm
]
\node[on chain=3]
(x3) [label=below:$\vdots$]{$x_{3}$};
\node[on chain=3,join=by o-latex]
{$w_{k3}$};
\node[on chain=3,init,label=below:\parbox{2cm}{\centering Summing \\ junction}] (sigma)
{$\displaystyle\Sigma$};
\node[on chain=3,join=by -latex] {$u_{k}$};
\node[on chain=3,squa,label=above:{\parbox{2cm}{\centering Activate \\ function}}]
{$f_{k}(.)$};
\node[on chain=3,label=above:Output,join=by -latex]
{$y_{k}$};
\begin{scope}[start chain=2]
\node[on chain=2] at (0,0.7cm)
(x2) {$x_2$};
\node[on chain=2,join=by o-latex]
(w2) {$w_{k2}$};
\end{scope}
\begin{scope}[start chain=1]
\node[on chain=1] at (0,1.5cm)
(x1) {$x_1$};
\node[on chain=1]
(w1) {};
%   \node[on chain =1] at (-1.5cm,1.1cm) (dots) {\vdots};
\end{scope}
\begin{scope}[start chain=4]
\node[on chain=4] at (0,-1.5cm)
(xn) {$x_n$};
\node[on chain=4,label=below:Weights,join=by o-latex]
(w3) {$w_{kn}$};
\end{scope}
\node[label=above:\parbox{2cm}{\centering Bias \\ $b_{k}$}] at (sigma|-w1) (b) {};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\draw (x1) to [R=$w_{k1}$] (w1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\draw[-latex] (w1) -- (sigma);
\draw[-latex] (w2) -- (sigma);
\draw[-latex] (w3) -- (sigma);
\draw[o-latex] (b) -- (sigma);

\draw[decorate,decoration={brace,mirror}] (x1.north west) -- node[left=10pt] {Inputs} (xn.south west);
\end{tikzpicture}
\caption{}
\label{neuralnetwork}
\end{figure}
\end{document}


Could anyone help me to sort out this problem? Just for fun, an option with relative coordinates, all to the point of origin. Is a matter of taste but I prefer to compile all my tikz drawings, each one with its own code in a folder with their respective outputs in pdf format, and then import them to my main document in the same way as the images, with the advantage that it reduces compilation time and preserves the vector format, being able to scale them to the width of the page even import it within a node within a tkz code of the main document...

MWE:

\documentclass[tikz]{standalone}
\usepackage{circuitikz}
\usetikzlibrary{decorations.pathreplacing,arrows.meta}

\begin{document}
\begin{tikzpicture}[
%Environment Config
>={Triangle[length=3pt,angle=60:4]}, % Style for Arrows from arrows.meta
%Styles
init/.style={
draw,
circle,
inner sep=8pt,
align=center,
scale=1
},
squa/.style={
draw,
align=center,
scale=1
},
Brace/.style={% To automate declaring decorations in draw optios for braces.
decorate,
decoration={
brace,
raise=-7pt
}
}
]
\ctikzset{nodes width/.initial=0.1} % set the size for shorts.
\ctikzset{bipoles/length=0.75cm} % set the bilopes lenght like resistors, capacitors, etc...

%Start drawing the thing from 0,0 coordinate.
\foreach \k [count=\j from 1] in {1,2,3,dots,n}{% Counter is used to enable to put characters in each iteration.
\ifnum \j=4
\draw
(0,0-\j*1cm) % Starting from 0,0
node[anchor=0](X\j){\vdots}; % A node for the fourth iteration
\else
\draw
(0,0-\j*1cm)
node[anchor=0](X\k){$X_{\k}$} % generate nodes X1,X2,X3,Xn
to [short,o-] ++ (0.5cm,0)
to [R,l=$W_{k\k}$] ++ (1.5cm,0) coordinate (wk\k); %generates Wk1, wk2, wk3, wkn coordinates.
\fi
}
% Put some shaped nodes relative to new points generated by coordinate instructión.
\draw (wk3)++(3.5cm,0) node(CSJ)[init]{Current \\ Summing \\ Junction};
% Draw each nx to CSJ
\foreach \m in {1,2,3,n}{
\draw[>->]
(wk\m)--++(0.5cm,0)
-- (CSJ)
node[pos=0,sloped,anchor=south west,scale=0.8]{$W_{k\m} X_{\m}(t)$}; %node in a path. position 0.25
}
\draw[] % Circuitikz part
(CSJ.0)
node[anchor=south west]{$\displaystyle\Sigma W_{ki} X_{i}(t)$}
to [short,-*] ++(2cm,0) coordinate (BI1) % Bifurcation 1
(BI1)
to[C,l_=$C_k$] ++(0,-2cm) coordinate (BI2) % Bifurcation 2
(BI2)
-| ++ (-0.5cm,-0.25cm) node[tlground,scale=2]{}
(BI2)
to [short,*-*] ++(1.5cm,0)
to [R,l_=$R_k$] ++ (0,2cm) coordinate (BI3) % Bifurcation 3
to [short,*-] (BI1)
(BI3)++(0,2cm)
node[squa](CS){Current \\ Source}
(CS)
-- (BI3)
(BI3)++(2cm,0)
node[squa](FK){$F_{k}(.)$}
(FK)
-- (BI3)
(FK)
to [short,-o] ++(1.75cm,0)
node[anchor=180](NKT){$n_k(t)$};
%Currents
\draw
(BI1)++(-0.5cm,0) node[currarrow,scale=1.5]{}
(BI1)++(0,-0.5cm) node[currarrow,scale=1.5,rotate=-90]{}
(BI1)++(0.75cm,0) node[currarrow,scale=1.5]{}
(BI2)++(0.75cm,0) node[currarrow,scale=1.5]{}
(BI3)++(0,0.75cm) node[currarrow,scale=1.5,rotate=-90,label={0:jk}]{}
(BI3)++(0.75cm,0) node[currarrow,scale=1.5,label={90:$r_k(t)$}]{}
(BI3)++(0,-1.75cm) node[currarrow,scale=1.5,rotate=-90]{};

%Finishing
\draw[Brace]
(Xn.270)++(-0.5cm,0) coordinate (temp) -- (temp|-X1.90);
\draw
(X3.180) node[anchor=0,align=center]{Synaptic \\ inputs}
(NKT.-90)++(0,-0.25cm) node[align=center]{Output};
\end{tikzpicture}
\end{document}

• @J Leaon V. When I run the code then the output is slightly different from the figure shown in the above Result. The ray coming from (BI3) is crossing $F_{k}(.)$ instead of making a gap for $F_{k}(.)$ as it is done in the picture shown in the Result. Jan 27, 2021 at 10:04
• How weird, I can't visualize the error you mention, I've compiled with: pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 21.1) LaTeX2e <2020-10-01> patch level 4, Package: tikz 2020/12/27 v3.1.8b (3.1.8b), Probably it is that I have only used a single draw instruction, for several independent lines you can divide this where it is required ... Jan 27, 2021 at 15:13