-
Notifications
You must be signed in to change notification settings - Fork 26
/
nn-auto_net_arr+neuralnet+foreach+style+foreach.tex
53 lines (42 loc) · 1.79 KB
/
nn-auto_net_arr+neuralnet+foreach+style+foreach.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
\documentclass{standalone}
\usepackage{tikz}
\usepackage{verbatim}
% Basis: http://www.texample.net/tikz/examples/neural-network/
\begin{document}
\pagestyle{empty}
\def\layersep{2.5cm}
\begin{tikzpicture}[shorten >=1pt,->,draw=black!100, 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=white!100,draw=black];
\tikzstyle{output neuron}=[neuron, fill=white!100,draw=black];
\tikzstyle{hidden neuron}=[neuron, fill=white!100,draw=black];
\tikzstyle{annot} = [text width=4em, text centered]
% Draw the input layer nodes and the labels
\foreach \name / \y in {1,...,3}
% This is the same as writing \foreach \name / \y in {1/1,2/2,3/3,4/4}
\node[input neuron, pin=left:Input \y] (I-\name) at (0,-\y) {};
% Draw the hidden layer nodes
\foreach \name / \y in {1,...,4}
\path[yshift=0.5cm]
node[hidden neuron] (H-\name) at (\layersep,-\y cm) {};
% Draw the output layer node
\node[output neuron,pin={[pin edge={->}]right:Output}, right of=H-2] (O1) {};
\node[output neuron,pin={[pin edge={->}]right:Output}, right of=H-3] (O2) {};
% Connect every node in the input layer with every node in the
% hidden layer.
\foreach \source in {1,...,3}
\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 (O1);
\foreach \source in {1,...,4}
\path (H-\source) edge (O2);
% Annotate the layers at the top
\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}
% End of code
\end{document}