Files
doc_phd_thesis/043_EndToEndRobustSystem/Figures/NeuralNetwork.tikz
T

44 lines
2.0 KiB
Plaintext

\def\layersep{3cm}
\begin{tikzpicture}[shorten >=1pt,->, node distance=\layersep]
\tikzstyle{neuron}=[circle,fill=black!25,minimum size=17pt,inner sep=0pt]
\tikzstyle{input neuron}=[neuron, fill=\TikZColorFillDark];
\tikzstyle{hidden neuron}=[neuron, fill=\TikZColorFill];
\tikzstyle{output neuron}=[neuron, fill=\TikZColorFillProp ];
\tikzstyle{annot} = [text width=4em, text centered]
% Draw the hidden layer nodes
\foreach \name / \y in {1,...,6}
\path[yshift=0.5cm]
node[hidden neuron] (H-\name) at (\layersep,-\y cm) {};
\node[input neuron, pin={[pin edge={latex-,thick,black}]left:Input \#1}] (I-1) at (0,-1) {};
\node[input neuron, pin={[pin edge={latex-,thick,black}]left:Input \#2}] (I-2) at (0,-2) {};
\node[input neuron, pin={[pin edge={latex-,thick,black}]left:Input \#3}] (I-3) at (0,-3) {};
\node[input neuron, pin={[pin edge={latex-,thick,black}]left:Input \#4}] (I-4) at (0,-4) {};
\node[input neuron, pin={[pin edge={latex-,thick,black}]left:Input \#5}] (I-5) at (0,-5) {};
% Draw the output 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}
\node[output neuron, pin={[pin edge={-latex,thick,black}]right:M\y}] (O-\name) at (2*\layersep,-0.5-\y) {};
% Connect every node in the input layer with every node in the hidden layer.
\foreach \source in {1,...,5}
\foreach \dest in {1,...,6}
\path (I-\source) edge (H-\dest);
% Connect every node in the hidden layer with the output layer
\foreach \source in {1,...,6}
\foreach \dest in {1,...,4}
\path (H-\source) edge (O-\dest);
% Annotate the layers
\node[annot,above of=H-1, node distance=.8cm] (hl) {Hidden};
\node[annot,left of=hl] (il) {Input};
\node[annot,right of=hl] (ol) {Output};
\node[annot,above=0 of hl] {Layers};
\path[draw,-] (il.north west) -- (ol.north east);
\end{tikzpicture}