-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathfigure3-6-softmax_layer.tex
More file actions
74 lines (60 loc) · 2.42 KB
/
figure3-6-softmax_layer.tex
File metadata and controls
74 lines (60 loc) · 2.42 KB
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[tikz, border=50pt]{standalone}
\usepackage{tikz}
\usepackage{medl_colors}
\usetikzlibrary{shapes.multipart, shapes.geometric, arrows.meta}
\usetikzlibrary{matrix, calc, positioning,fit}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}
\newcommand\semicircleunit[4]
{
%circle 2
\begin{scope}
\clip(#1, #2+#3) rectangle(#1-#3, #2-#3);
\node [lightblueshape, circle, minimum size=#3*2 cm] (circle#4) at (#1,#2) {};
\draw[ubthickline] (#1,#2+#3) -- (#1,#2-#3);
\end{scope}
%circle 2
\begin{scope}
\clip(#1, #2+#3) rectangle(-#1+#3, #2-#3);
\node [lightblueshape, redlayer, circle, minimum size=#3*2 cm] (circle1#4) at (#1,#2) {};
\end{scope}
%formulas
\node[left of=circle#4, node distance=1.5cm, align=center, text=black, font=\bfseries, yshift=-2.5mm] (text1#4) { \Large $\underbrace{b_#4 + w_{(#4)}^\top x}$ \\ \Large $z_#4$};
\node[right of=circle#4, node distance=1.6cm, align=center, text=black, font=\bfseries] (text2#4) { \Large $a_#4 = \dfrac{e^{z_#4}}{\sum_{i=1}^K e^{z_i}}$};
%output
\draw [-Triangle, bthickline] (circle1#4) -- node[pos=1.3](text3#4) { \Huge $\hat{\phi}_#4(x) $} ++(7,0);
\path (#1,#2) ++(215:#3) coordinate (A#4);
}
%softmax layer
\node[bluelayer, inner xsep = 4cm, inner ysep=14cm] (largerec) at(0,-9.5){};
\semicircleunit{0}{0}{3.2}{1};
\semicircleunit{0}{-8}{3.2}{2};
\semicircleunit{0}{-19}{3.2}{K};
\draw [uthickline, loosely dashed] ([yshift=-.5cm]circle2.south) -- ([yshift=.5cm]circleK.north) node[] {};
%Input layer
\coordinate (c1) at (-10, 2.5);
\coordinate (c2) at (-10, .5);
\coordinate (c3) at (-10, -1.5);
\coordinate (c4) at (-10, -21.5);
\foreach \i in {1,2,3}
{
\foreach \j in {1,2,K}
{
\node[left of=c\i, node distance=5mm, align=center] (t\i) {\huge $x_\i$};
\draw [-Triangle, bthickline, thick] (c\i) -- (circle\j) {};
}
}
%Arrows from input to softmax
\node[left of=c4,node distance=5mm, align=center] (t4) {\huge $x_p$};
\node[right of=t4, node distance=13cm, yshift=-1.5cm]{\LARGE Softmax};
\foreach \i in {1,2,K}
{
\draw [-Triangle, bthickline, thick] (c4) -- (A\i) {};
}
\draw [uthickline, loosely dashed, shorten <=4cm, shorten >= 4cm] (t3) -- (t4) node[] {};
%output
\draw[uthickline] (9,1) -- (10,1) -- (10,-20.5) -- (9,-20.5);
\draw [-Triangle, bthickline, thick] (10, -10) -- node[pos=1.3] {\Huge $\hat{y}$} ++(2,0);
\end{tikzpicture}
\end{document}