figure-ensemble-knowledge-distillation.tex 3.28 KB
Newer Older
1 2 3 4 5 6 7 8

  \begin{tikzpicture}

    \newlength{\YShift}
    \newlength{\XShift}
    \setlength{\YShift}{0.8\base}
    \setlength{\XShift}{0.8\base}

单韦乔 committed
9
    \tikzstyle{modelnode} = [rectangle,draw,rounded corners=2pt,inner sep=0pt,minimum height=4.5em,minimum width=2em,font=\small,anchor=north]
10 11 12 13 14 15 16 17 18 19 20 21 22

    \coordinate (stu01) at (0,0);
    \coordinate (stu02) at ([xshift=3em]stu01);
    \coordinate (stu03) at ([xshift=3em]stu02);
    \coordinate (stu04) at ([xshift=3em]stu03);
    \coordinate (stu05) at ([xshift=3em]stu04);
    \coordinate (tea01) at ([xshift=8em]stu05);
    \coordinate (tea02) at ([xshift=3em]tea01);

    % iterations
    \foreach \curr / \prev in {1/0,2/1,3/2}
    {
      % models
单韦乔 committed
23 24 25 26 27 28 29 30 31 32
      \node[modelnode,fill=yellow!20] (stu\curr1) at ([yshift=-2em]stu\prev1.south) {\rotatebox{90}{学生模型 $1$}};
      \node[modelnode,fill=yellow!20] (stu\curr2) at ([yshift=-2em]stu\prev2.south) {\rotatebox{90}{学生模型 $2$}};
      \node[modelnode,fill=yellow!20] (stu\curr3) at ([yshift=-2em]stu\prev3.south) {\rotatebox{90}{学生模型 $3$}};
      \node[modelnode,fill=yellow!20] (stu\curr4) at ([yshift=-2em]stu\prev4.south) {\rotatebox{90}{学生模型 $4$}};
      \node[modelnode,fill=yellow!20] (stu\curr5) at ([yshift=-2em]stu\prev5.south) {\rotatebox{90}{学生模型 $5$}};
      \node[modelnode] (tea\curr1) at ([yshift=-2em]tea\prev1.south) {\rotatebox{90}{\color{red!60} 教师模型 $1$}};
      \node[modelnode] (tea\curr2) at ([yshift=-2em]tea\prev2.south) {\rotatebox{90}{\color{blue!60} 教师模型 $2$}};

      % 集成 labels
      \draw[-latex'] ([xshift=2pt]stu\curr5.east) to node [auto] {\small 集成} ([xshift=-2pt]tea\curr1.west);
33 34 35
    }

    % iteration labels
单韦乔 committed
36 37
    \node[font=\small,anchor=east,purple!80] (iterate1) at ([xshift=-1em]stu21.west) {\rotatebox{90}{轮数 $1$}};
    \node[font=\small,anchor=east,purple!80] (iterate2) at ([xshift=-1em]stu31.west) {\rotatebox{90}{轮数 $2$}};
38 39

    % distillation labels
单韦乔 committed
40 41
    \node[font=\small,anchor=south west] (distill1) at ([yshift=0.8em]iterate1.north west) {知识蒸馏};
    \node[font=\small,anchor=south west] (distill2) at ([yshift=0.8em]iterate2.north west) {知识蒸馏};
42

单韦乔 committed
43
    % 学生模型 groups
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
    \begin{pgfonlayer}{background}
      \node[rectangle,draw,very thick,red!60,densely dotted,inner sep=2pt,rounded corners=2pt,fill=red!20] [fit = (stu21) (stu22) (stu23) ] (group21) {};
      \node[rectangle,draw,very thick,blue!60,densely dotted,inner sep=2pt,rounded corners=2pt,fill=blue!20] [fit = (stu24) (stu25) ] (group22) {};

      \node[rectangle,draw,very thick,blue!60,densely dotted,inner sep=2pt,rounded corners=2pt,fill=blue!20] [fit = (stu31) (stu32) ] (group31) {};
      \node[rectangle,draw,very thick,red!60,densely dotted,inner sep=2pt,rounded corners=2pt,fill=red!20] [fit = (stu33) (stu34) (stu35) ] (group32) {};
    \end{pgfonlayer}

    % distillation
    \draw[-latex',red!60,very thick] (tea11.south) .. controls +(south:1.5em) and +(north:2em) .. (group21.north);
    \draw[-latex',blue!60,very thick] (tea12.south) .. controls +(south:2em) and +(north:1.5em) .. (group22.north);

    \draw[-latex',red!60,very thick] (tea21.south) .. controls +(south:2em) and +(north:2.5em) .. (group32.north);
    \draw[-latex',blue!60,very thick] (tea22.south) .. controls +(south:2em) and +(north:1.5em) .. (group31.north);

  \end{tikzpicture}