-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneural.tex
74 lines (63 loc) · 2.31 KB
/
neural.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
\documentclass[border=1mm]{standalone}
\usepackage{xstring}
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc}
\ExplSyntaxOn
\NewDocumentCommand{\setarray}{O{;}mm}
{
\seq_clear_new:c { g_alexb_array_#2_seq }
\seq_gset_split:cnn { g_alexb_array_#2_seq } { #1 } { #3 }
}
\NewDocumentCommand{\getfromarray}{mm}
{
\seq_item:cn { g_alexb_array_#1_seq } { #2 }
}
\cs_generate_variant:Nn \seq_gset_split:Nnn { c }
\cs_set_eq:NN \inteval \int_eval:n
\ExplSyntaxOff
\begin{document}
\pagestyle{empty}
\def\layersep{2.5cm}
\input{neural_params.tex}
\newcounter{distmul}
\newcounter{temp}
\begin{tikzpicture}[shorten >=1pt,->,draw=black!50, 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=green!50];
\tikzstyle{output neuron}=[neuron, fill=red!50];
\tikzstyle{hidden neuron}=[neuron, fill=blue!50];
\tikzstyle{annot} = [text width=4em, text centered]
% Draw the input layer nodes
\foreach \name / \y in {1,...,\innum}
\path[yshift=\innum*0.5cm]
node[input neuron, pin=left:Input \#\y] (H0-\name) at (0,-\y) {};
% Draw the hidden layer nodes
\foreach \id / \x in \networkstruct
\stepcounter{distmul}
\foreach \name / \y in {1,...,\x}
\path[yshift=\x*0.5cm]
node[hidden neuron] (H\thedistmul-\name) at (\thedistmul*\layersep,-\y cm) {};
;
% Draw the output layer node
\stepcounter{distmul}
\foreach \name / \y in {1,...,\outnum}
\path[yshift=\outnum*0.5cm]
node[output neuron,pin={[pin edge={->}]right:Output \#\y}] (H\thedistmul-\name) at (\thedistmul*\layersep,-\y cm) {};
% Connect every node in the input layer with every node in the
% hidden layer.
\foreach \source in {1,...,\innum}
\foreach \dest in {1,...,\getfromarray{Nco}{1}}
\path (H0-\source) edge (H1-\dest);
;
\stepcounter{temp}
\setcounter{distmul}{0}
\foreach \name / \x in \networkstruct
\stepcounter{temp}
\stepcounter{distmul}
\foreach \source in {1,...,\x}
\foreach \dest in {1,...,\getfromarray{Nco}{\thetemp}}
\path (H\thedistmul-\source) edge (H\thetemp-\dest);
\end{tikzpicture}
\end{document}