Commit 4618854c by Lee

Add embedding figure

parent f6e47ea1
...@@ -9,3 +9,6 @@ ...@@ -9,3 +9,6 @@
*.blg *.blg
*.sav *.sav
*.pdf *.pdf
*.fdb_latexmk
*.fls
*.vrb
...@@ -145,12 +145,13 @@ ...@@ -145,12 +145,13 @@
\subsection{注意力机制} \subsection{注意力机制}
%%%------------------------------------------------------------------------------------------------------------ %%%------------------------------------------------------------------------------------------------------------
\begin{frame}{模块2:输出层} \begin{frame}{模块1:词嵌入层}
\begin{itemize} \begin{itemize}
\item Softmax \item 词嵌入
\end{itemize} \end{itemize}
%%% 图 %%% 图
\begin{center} \begin{center}
\hspace*{-0.6cm}
\begin{tikzpicture} \begin{tikzpicture}
\setlength{\base}{0.9cm} \setlength{\base}{0.9cm}
...@@ -224,57 +225,39 @@ ...@@ -224,57 +225,39 @@
\end{scope} \end{scope}
\begin{scope} \begin{scope}
\coordinate (start) at (8.5\base,-0.3\base); \coordinate (start) at (5.8\base,0.3\base);
\node [anchor=south west] (one) at (start) {\scriptsize{$\begin{bmatrix} 0 \\ 0 \\ 0 \\ \vdots \\ 0 \\ {\color{ugreen} 1} \\ 0 \\ 0 \end{bmatrix}$}};
\node [anchor=center,minimum width=5.7em,minimum height=1.3em,draw,rounded corners=0.3em] (hidden) at (start) {}; \node [anchor=north] (w) at ([yshift=3pt]one.south) {\scriptsize{\color{ugreen} you}};
\node [anchor=west,minimum width=1em,minimum size=1em,fill=ugreen!20] (cell01) at ([xshift=0.2em]hidden.west) {\scriptsize{.2}}; \node [anchor=north west] (words) at ([xshift=10pt]one.north east) {\scriptsize{$\begin{matrix} \langle\textrm{eos}\rangle \\ \langle\textrm{sos}\rangle \\ \textrm{Do} \\ \vdots \\ \textrm{know} \\ \textrm{you} \\ \textrm{?} \\ \textrm{have} \end{matrix}$}};
\node [anchor=west,minimum width=1em,minimum size=1em,fill=ugreen!10] (cell02) at (cell01.east) {\scriptsize{-1}}; \node [anchor=north west] (mat) at ([xshift=-6pt]words.north east) {\scriptsize{$
\node [anchor=west,minimum width=1em,minimum size=1em,fill=white] (cell03) at (cell02.east) {\scriptsize{$\cdots$}}; \begin{bmatrix}
\node [anchor=west,minimum width=1em,minimum size=1em,fill=ugreen!50] (cell04) at (cell03.east) {\scriptsize{5}}; .1 & -4 & \cdots & 2 \\
5 & 2 & \cdots & .2 \\
\node [anchor=south,minimum width=10.9em,minimum height=1.3em,draw,rounded corners=0.3em] (target) at ([yshift=2.4em]hidden.north) {}; 2 & .1 & \cdots & .3 \\
\node [anchor=west,minimum width=1em,minimum size=1em,fill=ugreen!10] (cell11) at ([xshift=0.2em]target.west) {\scriptsize{-2}}; \vdots & \vdots & \ddots & \vdots \\
\node [anchor=west,minimum width=1em,minimum size=1em,fill=ugreen!10] (cell12) at (cell11.east) {\scriptsize{-1}}; 0 & .8 & \cdots & 4 \\
\node [anchor=west,minimum width=1em,minimum size=1em,fill=ugreen!70] (cell13) at (cell12.east) {\scriptsize{6}}; -1 & -2 & \cdots & -3 \\
\node [anchor=west,minimum width=1em,minimum size=1em,fill=white] (cell14) at (cell13.east) {\scriptsize{$\cdots$}}; .7 & .5 & \cdots & 3 \\
\node [anchor=west,minimum width=1em,minimum size=1em,fill=ugreen!30] (cell15) at (cell14.east) {\scriptsize{.7}}; -2 & .3 & \cdots & .1
\node [anchor=west,minimum width=1em,minimum size=1em,fill=ugreen!10] (cell16) at (cell15.east) {\scriptsize{-3}}; \end{bmatrix}$
\node [anchor=west,minimum width=1em,minimum size=1em,fill=ugreen!10] (cell17) at (cell16.east) {\scriptsize{-1}}; }};
\node [anchor=west,minimum width=1em,minimum size=1em,fill=ugreen!20] (cell18) at (cell17.east) {\scriptsize{.2}};
\node [anchor=south,minimum width=1em,minimum height=0.2em,fill=ublue!80,inner sep=0pt] (label1) at ([yshift=3em]cell11.north) {};
\node [anchor=west,rotate=90,font=\scriptsize] (w1) at (label1.north) {$\langle$eos$\rangle$};
\node [anchor=south,minimum width=1em,minimum height=0.3em,fill=ublue!80,inner sep=0pt] (label2) at ([yshift=3em]cell12.north) {};
\node [anchor=west,rotate=90,font=\scriptsize] (w2) at (label2.north) {$\langle$sos$\rangle$};
\node [anchor=south,minimum width=1em,minimum height=1.5em,fill=ublue!80,inner sep=0pt] (label3) at ([yshift=3em]cell13.north) {};
\node [anchor=west,rotate=90,font=\scriptsize] (w3) at (label3.north) {Do};
\node [anchor=south,font=\scriptsize] (w4) at ([yshift=3em]cell14.north) {$\cdots$};
\node [anchor=south,minimum width=1em,minimum height=0.5em,fill=ublue!80,inner sep=0pt] (label5) at ([yshift=3em]cell15.north) {};
\node [anchor=west,rotate=90,font=\scriptsize] (w5) at (label5.north) {I};
\node [anchor=south,minimum width=1em,minimum height=0.1em,fill=ublue!80,inner sep=0pt] (label6) at ([yshift=3em]cell16.north) {};
\node [anchor=west,rotate=90,font=\scriptsize] (w6) at (label6.north) {you};
\node [anchor=south,minimum width=1em,minimum height=0.3em,fill=ublue!80,inner sep=0pt] (label7) at ([yshift=3em]cell17.north) {};
\node [anchor=west,rotate=90,font=\scriptsize] (w7) at (label7.north) {?};
\node [anchor=south,minimum width=1em,minimum height=0.4em,fill=ublue!80,inner sep=0pt] (label8) at ([yshift=3em]cell18.north) {};
\node [anchor=west,rotate=90,font=\scriptsize] (w8) at (label8.north) {have};
\filldraw [fill=red!20,draw=white] (target.south west) -- (target.south east) -- ([xshift=-0.2em,yshift=0.1em]hidden.north east) -- ([xshift=0.2em,yshift=0.1em]hidden.north west);
\draw [->,thick] ([xshift=0.2em,yshift=0.1em]hidden.north west) -- (target.south west);
\draw [->,thick] ([xshift=-0.2em,yshift=0.1em]hidden.north east) -- (target.south east);
\node [anchor=south,rounded corners=0.3em] (softmax) at ([yshift=0.5em]target.north) {\scriptsize{$p(\hat{s})_i=\frac{e^{\hat{s}_i}}{\sum_j e^{\hat{s}_j}}$}};
\begin{pgfonlayer}{background} \begin{pgfonlayer}{background}
\filldraw [fill=blue!20,draw=white] ([yshift=0.1em]cell11.north west) {[rounded corners=0.3em] -- (softmax.west)} -- (label1.south west) -- (label8.south east) {[rounded corners=0.3em] -- (softmax.east)} -- ([yshift=0.1em]cell18.north east) -- ([yshift=0.1em]cell11.north west); \node [draw=ugreen,fill=green!20!white,rounded corners=0.3em,minimum width=3.8cm,minimum height=0.9em,anchor=south west] (emb) at ([shift={(1.25cm,0.8cm)}]start) {};
\end{pgfonlayer} \end{pgfonlayer}
\node [anchor=south] () at ([yshift=0.6em]hidden.north) {\scriptsize{$\hat{s}=Ws$}}; \draw [decorate,decoration={brace,mirror}] ([shift={(6pt,2pt)}]mat.south west) to node [auto,swap,font=\scriptsize] {词嵌入矩阵} ([shift={(-6pt,2pt)}]mat.south east);
\draw [-latex'] ([xshift=-2pt,yshift=-0.65cm]one.east) to ([yshift=-0.65cm]words.west);
\draw [-latex'] (emb.east) -| ([yshift=0.4cm]mat.north east);
\draw [-latex'] ([yshift=-0.4cm]w.south) to ([yshift=2pt]w.south);
\node [draw=red,thick,densely dashed,rounded corners=3pt,fit=(cell01) (cell11) (label1) (label8) (target) (hidden) (w3)] (output) {}; \node [draw=ugreen,densely dashed,thick,rounded corners=3pt,fit=(one) (words) (mat) (w)] (input) {};
\end{scope} \end{scope}
\draw [->,thick,densely dashed,red] ([yshift=-0.2em]softmax3.east) .. controls +(east:2\base) and +(west:\base) .. (output.west); \draw [->,thick,densely dashed,ugreen] ([yshift=-0.2em]demb3.east) to [out=0,in=180] ([yshift=-1cm]input.west);
\end{tikzpicture} \end{tikzpicture}
\end{center} \end{center}
\end{frame} \end{frame}
%%%------------------------------------------------------------------------------------------------------------ %%%------------------------------------------------------------------------------------------------------------
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论