我想绘制这样的图像:
只是我希望节点是普通的黑色圆圈而不是彩色的。另外我只有一个输出,而不是像图片中那样有两个。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,chains,positioning,decorations.pathreplacing,arrows}
\begin{document}
\begin{tikzpicture}[
init/.style={
draw,
circle,
inner sep=2pt,
font=\Huge,
join = by -latex
},
squa/.style={
draw,
inner sep=2pt,
font=\Large,
join = by -latex
},
start chain=2,node distance=13mm
]
\node[on chain=2]
(x2) {$z_2$};
\node[on chain=2,join=by o-latex]
{$w_2$};
\node[on chain=2,init] (sigma)
{$\displaystyle\Sigma$};
\node[on chain=2,squa,label=above:{\parbox{2cm}{\centering Activate \\ function}}]
{$f$};
\node[on chain=2,label=above:Output,join=by -latex]
{$y$};
\begin{scope}[start chain=1]
\node[on chain=1] at (0,1.5cm)
(x1) {$z_1$};
\node[on chain=1,join=by o-latex]
(w1) {$w_1$};
\end{scope}
\begin{scope}[start chain=3]
\node[on chain=3] at (0,-1.5cm)
(x3) {$z_3$};
\node[on chain=3,label=below:Weights,join=by o-latex]
(w3) {$w_3$};
\end{scope}
\node[label=above:\parbox{2cm}{\centering Bias \\ $b$}] at (sigma|-w1) (b) {};
\draw[-latex] (w1) -- (sigma);
\draw[-latex] (w3) -- (sigma);
\draw[o-latex] (b) -- (sigma);
\draw[decorate,decoration={brace,mirror}] (x1.north west) -- node[left=10pt] {Inputs} (x3.south west);
\end{tikzpicture}
\end{document}
但我无法修改它以获得我想要的结果。我首先尝试删除 z_i 节点,但这会弄乱整个图形。
答案1
这不是一个答案。它只是一个供您根据需要修改的答案,仅包含基本选项path
:node
更改颜色、添加/删除某个节点等。如果您可以/不能修改我的代码,请告诉我!
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[>=latex]
\path
(0,0) node[circle,draw,scale=2,inner sep=2pt] (S) {$\Sigma$}
+(90:2.5) node[circle,draw,inner sep=2.5pt] (b) {}
node[above=1mm] {$b_1^{(2)}$}
+(-3.5,1.5) node[circle,fill=green!50] (x1) {$x_1$}
+(-3.5,0) node[circle,fill=green!50] (x2) {$x_2$}
+(-3.5,-1.5) node[circle,fill=green!50] (x3) {$x_3$}
(2,0) node[draw] (g) {$g$} node[above=3mm]{Activation}
+(15:3) node[circle,fill=red!50] (y1) {$\hat{y}_1$}
+(-15:3) node[circle,fill=red!50] (y2) {$\hat{y}_2$};
\draw[->] (S)--(g);
\draw[->] (b)--(S);
\draw[->] (g)--(y1) node[pos=.6,above]{$\omega_{1,1}^{(3)}$};
\draw[->] (g)--(y2) node[pos=.6,below]{$\omega_{2,1}^{(3)}$};
\draw[->] (x1)--(S) node[pos=.4,above]{$\omega_{1,1}^{(2)}$};
\draw[->] (x2)--(S) node[pos=.4,above]{$\omega_{1,2}^{(2)}$};
\draw[->] (x3)--(S) node[pos=.4,above]{$\omega_{1,3}^{(2)}$};
\draw[blue] (1,0) circle(2);
\end{tikzpicture}
\end{document}