figure-label-smoothing.tex 6.31 KB
Newer Older
曹润柘 committed
1 2 3

\begin{tikzpicture}
	
zengxin committed
4 5 6
	\node[font=\scriptsize] (model) at (0,0) {Model Output:};
	\node[anchor=north west,font=\scriptsize] (label_smooth) at ([yshift=-1.8em]model.south west) {Label Smoothing:};
	\node[anchor=south west,font=\scriptsize] (one-hot) at ([yshift=2em]model.north west) {One-hot:};
zengxin committed
7
	%model out
zengxin committed
8
	\node [anchor=west,minimum width=1.2em,minimum height=0.2em,fill=ublue!80,inner sep=0pt] (model_label1) at ([xshift=1.5em,yshift=-0.5em]model.east) {};
曹润柘 committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
    \node [anchor=south,font=\scriptsize] (model_w1) at (model_label1.north) {$p_{1}$};
    \node [anchor=south west,minimum width=1.2em,minimum height=0.1em,fill=ublue!80,inner sep=0pt] (model_label2) at (model_label1.south east) {};
    \node [anchor=south,font=\scriptsize] (model_w2) at (model_label2.north) {$p_{2}$};
    \node [anchor=south west,minimum width=1.2em,minimum height=0.7em,fill=ublue!80,inner sep=0pt] (model_label3) at (model_label2.south east) {};
    \node [anchor=south,font=\scriptsize] (model_w3) at (model_label3.north) {{\color{red} $p_{3}$}};
    \node [anchor=south west,minimum width=1.2em,minimum height=0.4em,fill=ublue!80,inner sep=0pt] (model_label4) at (model_label3.south east) {};
    \node [anchor=south,font=\scriptsize] (model_w5) at (model_label4.north) {$p_{4}$};

    \node [anchor=south west,minimum width=1.2em,minimum height=0.1em,fill=ublue!80,inner sep=0pt] (model_label5) at (model_label4.south east) {};
    \node [anchor=south,font=\scriptsize] (model_w6) at (model_label5.north) {$p_{5}$};
    \node [anchor=south west,minimum width=1.2em,minimum height=0.3em,fill=ublue!80,inner sep=0pt] (model_label6) at (model_label5.south east) {};
    \node [anchor=south,font=\scriptsize] (model_w7) at (model_label6.north) {$p_{6}$};
    \node [anchor=south west,minimum width=1.2em,minimum height=0.2em,fill=ublue!80,inner sep=0pt] (model_label7) at (model_label6.south east) {};
    \node [anchor=south,font=\scriptsize] (model_w8) at (model_label7.north) {$p_{7}$};
    %no label smooth
zengxin committed
24
    \node [anchor=west,minimum width=1.2em,minimum height=0.05em,fill=orange!50,inner sep=0pt,font=\tiny] (one_hot_label1) at ([xshift=1.5em,yshift=3em]model.east) {};
zengxin committed
25 26 27
    \node [anchor=south,font=\scriptsize] (one_hot_w1) at (one_hot_label1.north) {$0$};
    \node [anchor=south west,minimum width=1.2em,minimum height=0.05em,fill=orange!50,inner sep=0pt,font=\tiny] (one_hot_label2) at (one_hot_label1.south east) {};
    \node [anchor=south,font=\scriptsize] (one_hot_w2) at (one_hot_label2.north) {$0$};
曹润柘 committed
28 29
    \node [anchor=south west,minimum width=1.2em,minimum height=1.5em,fill=orange!50,inner sep=0pt] (one_hot_label3) at (one_hot_label2.south east) {};
    \node [anchor=south,font=\scriptsize] (one_hot_w3) at (one_hot_label3.north) {{\color{red} $1$}};
zengxin committed
30 31
    \node [anchor=south west,minimum width=1.2em,minimum height=0.05em,fill=orange!50,inner sep=0pt,font=\tiny] (one_hot_label4) at (one_hot_label3.south east) {};
    \node [anchor=south,font=\scriptsize] (one_hot_w4) at (one_hot_label4.north) {$0$};
曹润柘 committed
32

zengxin committed
33 34 35 36 37 38
    \node [anchor=south west,minimum width=1.2em,minimum height=0.05em,fill=orange!50,inner sep=0pt,font=\tiny] (one_hot_label5) at (one_hot_label4.south east) {};
    \node [anchor=south,font=\scriptsize] (one_hot_w5) at (one_hot_label5.north) {$0$};
    \node [anchor=south west,minimum width=1.2em,minimum height=0.05em,fill=orange!50,inner sep=0pt,font=\tiny] (one_hot_label6) at (one_hot_label5.south east) {};
    \node [anchor=south,font=\scriptsize] (one_hot_w6) at (one_hot_label6.north) {$0$};
    \node [anchor=south west,minimum width=1.12em,minimum height=0.05em,fill=orange!50,inner sep=0pt,font=\tiny] (one_hot_label7) at (one_hot_label6.south east) {};
    \node [anchor=south,font=\scriptsize] (one_hot_w7) at (one_hot_label7.north) {$0$};
曹润柘 committed
39 40

    %label smoothing
zengxin committed
41
	\node [anchor=west,minimum width=1.2em,minimum height=0.2em,fill=red!50,inner sep=0pt] (label1) at ([xshift=1.5em,yshift=-3.2em]model.east) {};
曹润柘 committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55
    \node [anchor=south,font=\scriptsize] (w1) at (label1.north) {$0.1$};
    \node [anchor=south west,minimum width=1.2em,minimum height=0.2em,fill=red!50,inner sep=0pt] (label2) at (label1.south east) {};
    \node [anchor=south,font=\scriptsize] (w2) at (label2.north) {$0.1$};
    \node [anchor=south west,minimum width=1.2em,minimum height=0.8em,fill=red!50,inner sep=0pt] (label3) at (label2.south east) {};
    \node [anchor=south,font=\scriptsize] (w3) at (label3.north) {{\color{red} $0.4$}};
    \node [anchor=south west,minimum width=1.2em,minimum height=0.2em,fill=red!50,inner sep=0pt] (label4) at (label3.south east) {};
    \node [anchor=south,font=\scriptsize] (w5) at (label4.north) {$0.1$};

    \node [anchor=south west,minimum width=1.2em,minimum height=0.2em,fill=red!50,inner sep=0pt] (label5) at (label4.south east) {};
    \node [anchor=south,font=\scriptsize] (w6) at (label5.north) {$0.1$};
    \node [anchor=south west,minimum width=1.2em,minimum height=0.2em,fill=red!50,inner sep=0pt] (label6) at (label5.south east) {};
    \node [anchor=south,font=\scriptsize] (w7) at (label6.north) {$0.1$};
    \node [anchor=south west,minimum width=1.2em,minimum height=0.2em,fill=red!50,inner sep=0pt] (label7) at (label6.south east) {};
    \node [anchor=south,font=\scriptsize] (w8) at (label7.north) {$0.1$};
zengxin committed
56
    
曹润柘 committed
57 58 59 60 61 62 63 64 65

    \node[font=\scriptsize] (line1) at ([xshift=9em,yshift=-1.5em]model_label7.east) {$loss =-0.3 \log p_{3}-\sum_{i=1}^{7} 0.1 \log p_{i}$};
    \node[font=\scriptsize] (line2) at ([xshift=5.9em,yshift=3.5em]model_label7.east) {$loss =-\log p_{3}$};

    \begin{pgfonlayer}{background}
        \node [rectangle,inner sep=0.1em,rounded corners=1pt,very thick,dotted,draw=red] [fit = (one_hot_label1) (one_hot_w3) (one_hot_label7) (model_label1) (model_label7)] (box1) {};

        \node [rectangle,inner sep=0.2em,rounded corners=1pt,fill=purple!10,drop shadow,draw=purple] [fit = (line2)] (box3) {}; 
        \draw [->,dotted,very thick,red] ([yshift=-1em]box1.east) .. controls +(east:1) and +(west:1) .. (box3.west);
zengxin committed
66
        
曹润柘 committed
67 68 69 70 71 72 73
        \node [rectangle,inner sep=0.1em,rounded corners=1pt,very thick,dotted,draw=ugreen] [fit = (label1) (label7) (model_label1) (model_label7) (model_w3)] (box2) {};
        \node [rectangle,inner sep=0.2em,rounded corners=1pt,fill=green!10,drop shadow,draw=ugreen] [fit = (line1)] (box4) {};
        \draw [->,dotted,very thick,ugreen] ([yshift=1em]box2.east) .. controls +(east:1) and +(west:1) .. (box4.west);
        
    \end{pgfonlayer}

\end{tikzpicture}