Commit 0de349d0 by wangchenglong

Update AML textbook merged notes

parent f136e8b3
......@@ -9,3 +9,5 @@
*.run.xml
*.synctex.gz
*.toc
*.xdv
.DS_Store
# 中文课程讲义 LaTeX 模板
# 高级机器学习教材合订版
主文件是 `aml_notes.tex`,建议使用 XeLaTeX 编译:
主文件是 `main.tex`,建议使用 XeLaTeX 编译:
```powershell
xelatex aml_notes.tex
xelatex aml_notes.tex
xelatex main.tex
bibtex main
xelatex main.tex
xelatex main.tex
```
第二次编译用于生成完整目录和交叉引用。图片可以放在 `figures/``images/` 目录中,然后用 `\includegraphics` 插入。
常用修改位置:
- 课程信息:修改 `\coursename``\semester``\teacher``\school`
- 新增章节:使用 `\chapter{章节标题}`
- 新增小节:使用 `\section{小节标题}``\subsection{小节标题}`
- 插入表格:参考模板中的 `table``longtable` 示例。
- 插入图片:把图片放入 `figures/`,参考模板中的 `figure` 示例。
如果使用 Overleaf,也请选择 XeLaTeX 作为编译器。
章节内容分别位于 `section1``section5` 目录中,合订版通过 `main.tex` 统一引入各章正文、图片与参考文献。
File added
% !TeX program = xelatex
% Advanced Machine Learning textbook master file.
\documentclass[UTF8,a4paper,zihao=-4,oneside,openany]{ctexbook}
\usepackage[
top=2.6cm,
bottom=2.6cm,
left=2.7cm,
right=2.7cm,
headheight=15pt
]{geometry}
\usepackage{setspace}
\setstretch{1.25}
\setlength{\parindent}{2em}
\setlength{\parskip}{0.2em}
\setlength{\emergencystretch}{3em}
\sloppy
\usepackage{amsmath,amssymb,bm}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{array}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[normalem]{ulem}
\usepackage[mode=tex]{standalone}
\usepackage{import}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{
arrows.meta,
automata,
backgrounds,
calc,
chains,
decorations.pathmorphing,
decorations.pathreplacing,
fillbetween,
fit,
intersections,
matrix,
patterns,
positioning,
shadows,
shapes,
shapes.arrows,
shapes.geometric
}
\usepackage[most]{tcolorbox}
\usepackage{xcolor}
\definecolor{CourseInk}{HTML}{1F2933}
\definecolor{CourseBlue}{HTML}{24577A}
\definecolor{CourseGreen}{HTML}{2D6A4F}
\definecolor{CourseGold}{HTML}{A16207}
\definecolor{CourseGray}{HTML}{F4F6F8}
\definecolor{CourseLine}{HTML}{D9E2EC}
\definecolor{CoursePurple}{HTML}{6D28D9}
\definecolor{ugreen}{HTML}{2E8B57}
\definecolor{kellygreen}{HTML}{4CBB17}
\definecolor{lightcyan}{HTML}{D9F5F7}
\definecolor{lightgreen}{HTML}{DFF3D8}
\definecolor{lightpink}{HTML}{F7D9E8}
\definecolor{lolgreen}{RGB}{103,213,181}
\definecolor{lolorange}{RGB}{246,179,82}
\definecolor{lolpurple}{RGB}{200,158,196}
\definecolor{axiscolor}{HTML}{334155}
\definecolor{positioncolor}{HTML}{2563EB}
\definecolor{velocitycolor}{HTML}{D97706}
\definecolor{guidecolor}{HTML}{94A3B8}
\definecolor{positionbg}{HTML}{F5F8FF}
\definecolor{velocitybg}{HTML}{FFF9F0}
\definecolor{stateblue}{HTML}{2563EB}
\definecolor{velocityteal}{HTML}{0F766E}
\definecolor{markorange}{HTML}{EA580C}
\definecolor{axisgray}{HTML}{374151}
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}
\newcommand{\mathbbm}[1]{\mathbf{#1}}
\graphicspath{
{section1/}{section2/}{section3/}{section4/}{section5/}
{section1/figures/}{section2/figures/}{section3/figures/}{section4/figures/}{section5/figures/}
}
\makeatletter
\def\input@path{%
{section1/}{section2/}{section3/}{section4/}{section5/}%
{section1/figures/}{section2/figures/}{section3/figures/}{section4/figures/}{section5/figures/}%
{section1/chapters/}{section3/section/}{section5/chapters/}%
}
\newcommand{\AMLFigure}[2][0.96\linewidth]{%
\begingroup
\let\AtBeginDocument\@gobble
\def\input@path{{section4/figures/}{figures/}{./}}%
\input{section4/figures/figure_style.tex}%
\includestandalone[width=#1]{section4/figures/#2}%
\endgroup
}
\makeatother
\tcbset{
enhanced,
boxrule=0.6pt,
arc=2mm,
left=3mm,
right=3mm,
top=2mm,
bottom=2mm,
breakable
}
\newtcolorbox{learninggoals}{
colback=CourseGray,
colframe=CourseBlue,
title=学习目标,
fonttitle=\bfseries
}
\newtcolorbox{importantnote}{
colback=white,
colframe=CourseGreen,
title=重点提示,
fonttitle=\bfseries
}
\newtcolorbox{examplebox}[1][]{
colback=white,
colframe=CourseGold,
title=例题 #1,
fonttitle=\bfseries
}
\newtcolorbox{exercisebox}{
colback=CourseGray,
colframe=CourseLine,
title=课后练习,
fonttitle=\bfseries\color{CourseInk}
}
\newtcolorbox{intuition}{
colback=CourseGray,
colframe=CoursePurple,
title=直观理解,
fonttitle=\bfseries
}
\newcommand{\coursename}{高级机器学习}
\newcommand{\semester}{2026}
\newcommand{\teacher}{授课教师}
\newcommand{\school}{学校 / 机构名称}
\newcommand{\lessondate}{\today}
\newcommand{\blankline}{\par\noindent\rule{\linewidth}{0.4pt}\par}
\newcommand{\keyword}[1]{\textbf{\color{CourseBlue}#1}}
\newcommand{\mindex}[1]{\textit{#1}}
\newcommand{\imageplaceholder}[2][5cm]{%
\fbox{%
\begin{minipage}[c][#1][c]{0.78\linewidth}
\centering
\textbf{图片占位}\\[0.45em]
{\small #2}
\end{minipage}%
}%
}
\newcommand{\todochen}[1]{%
\par\noindent
{\color{CourseGold}\small$\blacktriangleright$\ \textbf{[待陈丹补充 / 语音音频]}\ #1}\par}
\newcommand{\chapterinfo}[2][]{%
\begin{tcolorbox}[
colback=CourseGray,
colframe=CourseLine,
boxrule=0.5pt,
arc=1.5mm,
left=3mm,
right=3mm,
top=1.5mm,
bottom=1.5mm,
before skip=-0.4em,
after skip=1.0em
]
{\small\noindent\textbf{\color{CourseBlue}作者:}#2%
\if\relax\detokenize{#1}\relax
\else\\[0.25em]\textbf{\color{CourseBlue}参考:}#1%
\fi}
\end{tcolorbox}
}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\small 高级机器学习}
\fancyhead[R]{\small \leftmark}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
\usepackage[numbers,sort&compress]{natbib}
\bibliographystyle{plainnat}
\usepackage[
colorlinks=true,
linkcolor=CourseBlue,
urlcolor=CourseGreen,
citecolor=CourseGold
]{hyperref}
\ctexset{
chapter = {
name = {第,章},
number = \chinese{chapter},
format = \huge\bfseries\color{CourseBlue},
beforeskip = 0pt,
afterskip = 22pt
},
section = {
format = \Large\bfseries\color{CourseInk}
},
subsection = {
format = \large\bfseries\color{CourseInk}
}
}
\begin{document}
\begin{titlepage}
\centering
\vspace*{1.5cm}
{\zihao{1}\bfseries\color{CourseBlue}\coursename\par}
\vspace{0.8cm}
{\zihao{3}\bfseries 教材合订版\par}
\vspace{1.2cm}
\vfill
\begin{tabular}{rl}
\textbf{教师:} & \teacher \\
\textbf{学期:} & \semester \\
\textbf{单位:} & \school \\
\textbf{日期:} & \lessondate \\
\end{tabular}
\vspace*{1.2cm}
\end{titlepage}
\frontmatter
\pagestyle{plain}
\tableofcontents
\cleardoublepage
\mainmatter
\pagestyle{fancy}
\subimport{section1/}{chapter.tex}
\subimport{section2/}{chapter.tex}
\subimport{section3/}{chapter.tex}
\subimport{section4/}{chapter.tex}
\subimport{section5/}{chapter.tex}
\backmatter
% \renewcommand{\bibname}{参考文献}
% \addcontentsline{toc}{chapter}{参考文献}
\bibliography{references_merged}
\end{document}
This source diff could not be displayed because it is too large. You can view the blob instead.
# 中文课程讲义 LaTeX 模板
主文件是 `aml_notes.tex`,建议使用 XeLaTeX 编译:
```powershell
xelatex aml_notes.tex
xelatex aml_notes.tex
```
第二次编译用于生成完整目录和交叉引用。图片可以放在 `figures/``images/` 目录中,然后用 `\includegraphics` 插入。
常用修改位置:
- 课程信息:修改 `\coursename``\semester``\teacher``\school`
- 新增章节:使用 `\chapter{章节标题}`
- 新增小节:使用 `\section{小节标题}``\subsection{小节标题}`
- 插入表格:参考模板中的 `table``longtable` 示例。
- 插入图片:把图片放入 `figures/`,参考模板中的 `figure` 示例。
如果使用 Overleaf,也请选择 XeLaTeX 作为编译器。
% !TeX program = xelatex
% 高级机器学习中文讲义
% 编译建议:XeLaTeX 或 LuaLaTeX。Windows / macOS / Linux 均可使用 ctex 自动处理中文字体。
% \documentclass[UTF8,fontset=none,a4paper,zihao=-4,oneside,openany]{ctexbook}
\documentclass[UTF8,a4paper,zihao=-4,oneside,openany]{ctexbook}
% 页面与基础排版
\usepackage[
top=2.6cm,
bottom=2.6cm,
left=2.7cm,
right=2.7cm,
headheight=15pt
]{geometry}
\usepackage{setspace}
\setstretch{1.25}
\setlength{\parindent}{2em}
\setlength{\parskip}{0.2em}
% 数学、表格、图片
\usepackage{amsmath,amssymb}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{
arrows.meta,
automata,
backgrounds,
calc,
chains,
decorations.pathmorphing,
decorations.pathreplacing,
fit,
matrix,
patterns,
positioning,
shadows,
shapes,
shapes.arrows,
shapes.geometric
}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{array}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{caption}
\usepackage{subcaption}
\graphicspath{{figures/}{images/}}
% 与“参考样例”保持一致:数字编号引用,并对同一处的多篇文献排序、压缩
\usepackage[numbers,sort&compress]{natbib}
\bibliographystyle{plainnat}
% 颜色与强调框
\usepackage[most]{tcolorbox}
\usepackage{xcolor}
\definecolor{CourseInk}{HTML}{1F2933}
\definecolor{CourseBlue}{HTML}{24577A}
\definecolor{CourseGreen}{HTML}{2D6A4F}
\definecolor{CourseGold}{HTML}{A16207}
\definecolor{CourseGray}{HTML}{F4F6F8}
\definecolor{CourseLine}{HTML}{D9E2EC}
\definecolor{ugreen}{HTML}{2E8B57}
\definecolor{kellygreen}{HTML}{4CBB17}
\definecolor{lightcyan}{HTML}{D9F5F7}
\definecolor{lightgreen}{HTML}{DFF3D8}
\definecolor{lightpink}{HTML}{F7D9E8}
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}
\tcbset{
enhanced,
boxrule=0.6pt,
arc=2mm,
left=3mm,
right=3mm,
top=2mm,
bottom=2mm,
breakable
}
\newtcolorbox{learninggoals}{
colback=CourseGray,
colframe=CourseBlue,
title=学习目标,
fonttitle=\bfseries
}
\newtcolorbox{importantnote}{
colback=white,
colframe=CourseGreen,
title=重点提示,
fonttitle=\bfseries
}
\newtcolorbox{examplebox}[1][]{
colback=white,
colframe=CourseGold,
title=例题 #1,
fonttitle=\bfseries
}
\newtcolorbox{exercisebox}{
colback=CourseGray,
colframe=CourseLine,
title=课后练习,
fonttitle=\bfseries\color{CourseInk}
}
% 页眉页脚与链接
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\small 高级机器学习讲义}
\fancyhead[R]{\small \leftmark}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
\usepackage[
colorlinks=true,
linkcolor=CourseBlue,
urlcolor=CourseGreen,
citecolor=CourseGold
]{hyperref}
% 章节样式
\ctexset{
chapter = {
name = {第,讲},
number = \chinese{chapter},
format = \huge\bfseries\color{CourseBlue},
beforeskip = 0pt,
afterskip = 22pt
},
section = {
format = \Large\bfseries\color{CourseInk}
},
subsection = {
format = \large\bfseries\color{CourseInk}
}
}
% 常用命令
\newcommand{\coursename}{高级机器学习}
\newcommand{\semester}{2026}
\newcommand{\teacher}{授课教师}
\newcommand{\school}{学校 / 机构名称}
\newcommand{\lessondate}{\today}
\newcommand{\blankline}{\par\noindent\rule{\linewidth}{0.4pt}\par}
\newcommand{\keyword}[1]{\textbf{\color{CourseBlue}#1}}
\begin{document}
% 封面
\begin{titlepage}
\centering
\vspace*{1.5cm}
{\zihao{1}\bfseries\color{CourseBlue}\coursename\par}
\vspace{0.8cm}
{\zihao{3}\bfseries 第一部分:机器学习数学基础\par}
\vspace{1.2cm}
\IfFileExists{figures/cover.jpg}{
\includegraphics[width=0.78\linewidth,height=0.32\textheight,keepaspectratio]{figures/cover.jpg}
}{
\fbox{
\begin{minipage}[c][0.24\textheight][c]{0.78\linewidth}
\centering
将封面图命名为 \texttt{cover.jpg} 并放入 \texttt{figures/} 目录后,会自动显示在这里。
\end{minipage}
}
}
\vfill
\begin{tabular}{rl}
\textbf{教师:} & \teacher \\
\textbf{学期:} & \semester \\
\textbf{单位:} & \school \\
\textbf{日期:} & \lessondate \\
\end{tabular}
\vspace*{1.2cm}
\end{titlepage}
% 目录
\frontmatter
\pagestyle{plain}
\tableofcontents
\cleardoublepage
% 正文
\mainmatter
\pagestyle{fancy}
\input{chapters/part1_ml_foundations}
\backmatter
\renewcommand{\bibname}{参考文献}
\addcontentsline{toc}{chapter}{参考文献}
\bibliography{references}
\end{document}
% !TeX root = ../main.tex
% 第一章正文入口。
\input{chapters/part1_ml_foundations}
This source diff could not be displayed because it is too large. You can view the blob instead.
\input{figures/figure-theme.tex}
\begin{center}
\begin{tikzpicture}[aml figure]
\amlfigurepalette
\foreach \r/\dy in {5.2/0.70,4.2/0.50,3.2/0.33,2.3/0.20,1.4/0.10,0.65/0.02}{
\draw[FigureLine,rotate=25,line width=.8pt] (0,\dy) ellipse ({\r} and {\r*0.45});
}
\coordinate (p1) at (-4.4,-2.0);
\coordinate (p2) at (-3.5,-1.0);
\coordinate (p3) at (-2.5,-1.35);
\coordinate (p4) at (-1.8,-0.65);
\coordinate (p5) at (-1.15,-0.82);
\coordinate (p6) at (-0.70,-0.38);
\coordinate (p7) at (-0.35,-0.30);
\coordinate (p8) at (-0.08,-0.08);
\foreach \i in {1,...,7}{
\draw[-stealth,FigureCoral,line width=1.2pt] (p\i) -- (p\the\numexpr\i+1\relax);
}
\fill[FigureInk] (0,0) ellipse (0.10 and 0.05);
\node[font=\footnotesize,fill=FigureWarm,rounded corners=1pt,inner sep=2pt] at (0.72,0.25){最小值};
\node[font=\footnotesize,FigureCoral] at (-3.8,-2.25){参数更新路径};
\end{tikzpicture}
\end{center}
\begin{center}
\begin{tikzpicture}
\begin{scope}
\begin{axis}[
width=4.7cm,height=4.7cm,
title={\small 线性可分},
xlabel={$x_1$}, ylabel={$x_2$},
xmin=0,xmax=8,ymin=0,ymax=8,
xtick={0,2,4,6,8}, ytick={0,2,4,6,8},
title style={yshift=-0.4em},
ylabel style={yshift=-0.4em},
]
\addplot[only marks,blue,very thick,mark=square] coordinates{
(1.0,3.3) (1.4,3.8) (1.8,4.6) (2.3,5.1) (2.7,5.8)
(3.1,6.3) (3.5,5.7) (3.9,6.9) (4.4,6.4) (4.9,7.1)};
\addplot[only marks,red,very thick,mark=x,mark size=4pt] coordinates{
(2.7,0.9) (3.2,1.6) (3.8,2.0) (4.4,2.5) (5.0,2.9)
(5.6,3.4) (6.1,3.8) (6.7,4.3) (7.2,5.0)};
\addplot[black,semithick,domain=0:8]{0.72*x+1.3};
\end{axis}
\end{scope}
\begin{scope}[xshift=5.2cm]
\begin{axis}[
width=4.7cm,height=4.7cm,
title={\small 圆形边界},
xlabel={$x_1$}, ylabel={$x_2$},
xmin=0,xmax=8,ymin=0,ymax=8,
xtick={0,2,4,6,8}, ytick={0,2,4,6,8},
title style={yshift=-0.4em},
ylabel style={yshift=-0.4em},
]
\addplot[black,semithick,domain=0:360,samples=80] ({4+1.7*cos(x)},{4+1.7*sin(x)});
\addplot[only marks,red,very thick,mark=x,mark size=4pt] coordinates{
(3.2,3.6) (3.5,4.6) (4.0,5.0) (4.6,4.7) (5.0,3.9)
(4.5,3.1) (3.8,3.0) (3.1,4.2)};
\addplot[only marks,blue,very thick,mark=square] coordinates{
(0.9,6.1) (1.4,6.5) (2.2,6.8) (3.0,7.1) (4.1,7.3)
(5.0,7.0) (6.4,6.4) (7.2,5.6) (7.0,2.0) (6.4,1.2)
(5.3,0.8) (4.1,0.6) (2.8,1.0) (1.6,2.1) (1.0,3.4)};
\end{axis}
\end{scope}
\begin{scope}[xshift=10.4cm]
\begin{axis}[
width=4.7cm,height=4.7cm,
title={\small 复杂边界},
xlabel={$x_1$}, ylabel={$x_2$},
xmin=0,xmax=8,ymin=0,ymax=8,
xtick={0,2,4,6,8}, ytick={0,2,4,6,8},
title style={yshift=-0.4em},
ylabel style={yshift=-0.4em},
]
\addplot[black,semithick,smooth] coordinates{
(1.0,4.3) (1.7,4.1) (2.5,3.7) (3.1,3.0) (3.9,2.8)
(4.6,3.3) (5.4,3.1) (6.2,3.6) (6.8,4.2)};
\addplot[black,semithick,smooth] coordinates{
(2.2,3.7) (3.0,4.4) (3.9,5.1) (4.8,5.5) (5.7,5.2)};
\addplot[only marks,red,very thick,mark=x,mark size=4pt] coordinates{
(2.0,3.8) (2.8,3.5) (3.4,4.1) (4.0,3.6) (4.8,4.5)
(5.3,3.8) (5.6,5.1)};
\addplot[only marks,blue,very thick,mark=square] coordinates{
(0.9,5.1) (1.5,5.7) (2.4,6.4) (3.3,6.0) (4.3,6.7)
(5.4,6.2) (6.5,6.9) (7.3,5.8) (1.2,2.0) (2.2,1.1)
(3.2,1.7) (4.3,2.2) (5.5,2.0) (6.6,2.6) (7.2,3.4)};
\end{axis}
\end{scope}
\end{tikzpicture}
\end{center}
\input{figures/figure-theme.tex}
\begin{center}
\begin{tikzpicture}[aml figure]
\amlfigurepalette
\begin{axis}[
aml axis,
width=8.4cm,height=8.0cm,
xlabel={$x_1$}, ylabel={$x_2$},
xmin=0,xmax=8,ymin=0,ymax=8,
xtick={0,1,2,3,4,5,6,7,8},
ytick={0,1,2,3,4,5,6,7,8},
legend style={at={(0.5,1.08)},anchor=south,draw=none,legend columns=2},
]
\addplot[only marks,blue,very thick,mark=square] coordinates{
(0.6,5.7) (0.9,4.8) (1.1,6.8) (1.5,5.2) (1.8,7.1)
(2.2,6.0) (2.4,7.5) (2.8,5.6) (3.2,6.4) (3.5,7.8)
(3.7,6.9) (4.0,7.3) (4.3,6.2) (4.6,7.6)};
\addlegendentry{食物类}
\addplot[only marks,red,very thick,mark=x,mark size=4pt] coordinates{
(3.0,0.8) (3.4,1.5) (3.8,2.1) (4.1,1.1) (4.5,2.4)
(4.9,1.7) (5.2,0.9) (5.6,2.7) (6.0,1.3) (6.5,3.0)
(6.9,1.1) (7.3,4.1)};
\addlegendentry{非食物类}
\addplot[FigureInk,semithick,domain=0:8]{1.55*x-1.0};
\addplot[FigureTeal,semithick,dashed,domain=0:8]{0.55*x+1.6};
\addplot[FigureGold,semithick,dash dot,domain=0:8]{-0.35*x+5.0};
\node[rotate=56,anchor=south] at (axis cs:2.0,2.2) {\footnotesize 超平面 1};
\node[rotate=29,anchor=south] at (axis cs:5.7,4.9) {\footnotesize 超平面 2};
\node[rotate=-20,anchor=south] at (axis cs:2.3,4.0) {\footnotesize 超平面 3};
\end{axis}
\end{tikzpicture}
\end{center}
% Shared visual language for figures in Chapter 1.
\providecolor{FigureInk}{HTML}{263640}
\providecolor{FigureBlue}{HTML}{347A9E}
\providecolor{FigureTeal}{HTML}{3B8176}
\providecolor{FigureCoral}{HTML}{C65F54}
\providecolor{FigureGold}{HTML}{C49332}
\providecolor{FigureLilac}{HTML}{746DA3}
\providecolor{FigureMist}{HTML}{EDF3F5}
\providecolor{FigureWarm}{HTML}{F8F0E4}
\providecolor{FigureLine}{HTML}{B8C5CC}
\providecolor{FigureMuted}{HTML}{6F7F88}
\tikzset{
aml figure/.style={
line cap=round,
line join=round,
>={Stealth[length=5pt,width=4pt]},
every node/.append style={text=FigureInk}
},
aml soft node/.style={
draw=FigureInk!65,
fill=FigureMist,
line width=.7pt,
rounded corners=2pt
},
aml warm node/.style={
draw=FigureGold!75!FigureInk,
fill=FigureWarm,
line width=.7pt,
rounded corners=2pt
},
aml flow/.style={->,draw=FigureInk!75,line width=.8pt},
aml accent flow/.style={->,draw=FigureTeal,line width=1pt}
}
\pgfplotsset{
aml axis/.style={
axis line style={draw=FigureInk!75},
tick style={draw=FigureInk!65},
tick label style={text=FigureInk},
label style={text=FigureInk},
grid=major,
grid style={draw=FigureLine!55,line width=.25pt},
legend style={draw=none,fill=white,fill opacity=.88,text opacity=1}
}
}
% Remap the standard colors used by the source figures inside each picture.
\providecommand{\amlfigurepalette}{%
\colorlet{blue}{FigureBlue}%
\colorlet{red}{FigureCoral}%
\colorlet{green}{FigureTeal}%
\colorlet{ugreen}{FigureTeal}%
\colorlet{orange}{FigureGold}%
\colorlet{purple}{FigureLilac}%
\colorlet{cyan}{FigureBlue}%
\colorlet{gray}{FigureLine}%
}
\input{figures/figure-theme.tex}
\begin{center}
\begin{tikzpicture}[aml figure]
\amlfigurepalette
\begin{axis}[
aml axis,
width=11cm,height=5.6cm,
xlabel={模型复杂度},
ylabel={误差},
xmin=0,xmax=10,ymin=0,ymax=20,
xmajorticks=false,
ymajorticks=false,
legend style={at={(0.70,0.78)},anchor=west,draw=none},
]
\addplot[blue,line width=1.5pt,smooth] coordinates{
(0,18) (0.7,9) (1.5,5.5) (2.5,3.6) (4,2.2)
(5.5,1.5) (7,1.0) (9.5,0.8)};
\addlegendentry{训练误差}
\addplot[red,line width=1.5pt,smooth] coordinates{
(0,18) (0.7,10) (1.5,6.5) (2.5,4.4) (4,3.2)
(5.5,3.1) (7,4.6) (8.5,6.7) (9.5,8.5)};
\addlegendentry{验证误差}
\draw[dashed,FigureTeal,line width=.8pt] (axis cs:5.1,0) -- (axis cs:5.1,20);
\node[anchor=south,FigureTeal] at (axis cs:5.1,17.2) {\footnotesize 合适复杂度};
\end{axis}
\end{tikzpicture}
\end{center}
x y
5.124345363663242 1
2.8882435863499247 1
2.9718282477365445 1
2.4270313778438295 1
4.365407629324679 1
1.1984613031197173 1
5.24481176421648 1
2.738793099104897 1
3.8190390960570983 1
3.25062962452259 1
4.9621079370449745 1
1.439859290502346 1
3.1775827959864924 1
3.1159456453315846 1
4.633769442335438 1
2.400108732685969 1
3.3275717924495645 1
2.622141582078628 1
3.5422137467155927 1
4.082815213715822 1
2.3993808227870788 1
4.644723709839614 1
4.401590720592796 1
4.002494338901868 1
4.400855949264412 1
2.816272140825667 1
3.377109774481352 1
2.5642305657409312 1
3.232111920373984 1
4.030355466738186 1
2.8083392482746907 1
3.1032464731440226 1
2.8128272998804005 1
2.6547943585012805 1
2.828753869163181 1
3.487335401081099 1
2.382689651364722 1
3.7344156978170924 1
5.159802177109871 1
4.242044160577335 1
3.308164447638385 1
2.6123710359151637 1
2.7528417062491624 1
5.192454601027746 1
3.550807754776029 1
2.8630043534306466 1
3.690915484667466 1
5.600255136478842 1
3.620158952481629 1
4.117203109707419 1
3.8001703199558277 1
3.1477501535064816 1
2.35748180197786 1
3.1506572775871224 1
3.291105766625222 1
4.0866231911821975 1
4.338983413874505 1
4.431102081303557 1
3.7855873252542587 1
4.385141164270728 1
2.745602059003347 1
4.752868155233288 1
4.012929820418009 1
3.2019071648972846 1
3.988518146537497 1
3.4244282869789444 1
4.631629387451427 1
5.019816816422199 1
5.685575406533161 1
2.1035036645118623 1
2.0558861945704106 1
2.9955341370535487 1
3.6600370694478306 1
4.376168921116225 1
3.8156349472416053 1
1.477798784175997 1
3.193795987371628 1
4.327974642607246 1
3.7300947353643834 1
4.262011180312025 1
3.277671857389641 1
3.2992419310700027 1
3.686561390988284 1
3.9100516472082565 1
3.6982997201267698 1
3.6190086458074586 1
2.829337713710969 1
3.8775637863209194 1
3.621821270991437 1
4.629483907911919 1
4.698917879901507 1
3.685156417483944 1
3.1247150499098857 1
2.861269592545778 1
3.923494354064113 1
3.577340068348559 1
3.1561463244289243 1
3.543596856834247 1
2.8799991560518707 1
4.198032034072219 1
x y
2.052871435214002 2
3.724507704805499 2
2.9034916417908 2
3.093578523237067 2
1.4050881542589582 2
2.669382433058668 2
3.2405564510962748 2
1.5462993981920654 2
2.233781493996378 2
2.5326145466933587 2
1.1268826797532443 2
2.815159392042292 2
3.3461606475850334 2
1.6404840591680137 2
2.8505459786641074 2
1.1877165887625682 2
2.4613044907339487 2
0.8842276452967053 2
3.621417708235664 2
2.9089005379368276 2
2.4753830441242215 2
1.7248383808308403 2
3.7737559301587766 2
4.467101749254734 2
0.6420181355532479 2
3.7361640304528203 2
4.127650753148906 2
2.8380116965744757 2
1.300731967664814 2
3.3633453175440216 2
2.3190796979218495 2
1.8960793722067426 2
1.2699418643330382 2
3.0505374959762155 2
3.2928068659193475 2
1.8764692703202084 2
3.0205763370733707 2
1.3556586103768573 2
3.301861031871345 2
2.5465672984241454 2
2.3134302280926513 2
2.398254127470855 2
3.3688861570058677 2
3.2504116398650083 2
3.029465324352709 2
2.637701209997386 2
2.577821127912706 2
3.1183802619985244 2
2.732494559178738 2
3.1825514068644853 2
2.18988322648194 2
0.06516223589286119 2
3.538824601859414 2
4.686979646974258 2
2.941364443568582 2
2.3998447667165004 2
2.3635552561039668 2
2.3809458122251903 2
2.5174094083000047 2
1.3779812712531117 2
1.982905542079772 2
1.502973172349737 2
2.7487991613877707 2
2.2033588476291373 2
2.9952113239779603 2
2.325296840257499 2
3.486335187821242 2
2.713533901335442 2
4.690699728969733 2
0.6036390771089075 2
1.853083311745092 2
3.401486891648711 2
5.028325706806398 2
2.25136522228454 2
2.543668993178389 2
2.273685757486395 2
3.831457112587592 2
2.212692136523981 2
3.1800698398781044 2
2.180198401101329 2
1.2274412447540057 2
2.8135477204634323 2
3.0031848134353263 2
3.793225882532262 2
2.3895529735826835 2
1.882637936287639 2
3.062761096619026 2
2.7407370922377323 2
2.780665077122639 2
2.426887296252722 2
3.66033856999377 2
2.869492716375724 2
4.404658708340981 2
3.6110566985605046 2
3.15904979610021 2
0.8725616593837426 2
3.102319280295629 2
2.9202822036470595 2
3.3109516728035557 2
3.544442094707259 2
x y
6.599121808211073 3
7.824005618450408 3
6.43769456898091 3
8.954878075009034 3
5.668048333482751 3
5.239311439601217 3
5.3492787341759 3
6.109444415836951 3
5.880884601440272 3
8.956078903703641 3
6.673500501921816 3
5.657324210622564 3
8.114382976779792 3
6.413476061178407 3
5.763146623458603 3
7.8758389276492995 3
7.623362176578032 3
6.565043317044772 3
8.407540000241228 3
7.129101579710725 3
8.6169495988573 3
7.502740881999904 3
8.55880554061986 3
7.109402696425428 3
5.780255603020967 3
9.449368649061398 3
6.454225832017432 3
6.8011621371111035 3
6.299601495078745 3
6.796605551035442 3
7.2426694410817944 3
7.201830178874004 3
7.661020287598693 3
8.792158208975566 3
6.879535428211493 3
5.766879264553573 3
5.817681873490367 3
6.334245481800873 3
5.325804192381068 3
7.825029824438986 3
6.5017864363689215 3
6.689015021697149 3
6.998108517161996 3
5.603379575404568 3
6.138683639223958 3
7.6747115256879725 3
7.618539130786293 3
6.556828069299362 3
8.810534914125457 3
5.694273077442262 3
6.655012789845021 3
6.769160256864531 3
4.20691499985346 3
8.93752881361608 3
7.366332014540058 3
5.955410618092208 3
9.051173442857444 3
7.585662000172382 3
7.429526140021965 3
6.393001601799954 3
7.106222724035217 3
5.474319683770642 3
7.795026094424845 3
6.625561681156779 3
7.134048196554623 3
8.202054862199706 3
7.284748110849058 3
7.262467445463269 3
7.276499304822184 3
6.266728396104687 3
7.836004719434269 3
8.543359110804484 3
7.758805660097931 3
7.884908814464883 3
6.122718481081812 3
6.132212777127075 3
5.55912397570816 3
8.232253070828436 3
6.745820132392632 3
8.399843942480986 3
6.2180883173131996 3
6.5624910171714195 3
7.095425087191257 3
7.921450068659511 3
7.060750195799507 3
7.211124755007717 3
7.016527567305616 3
7.177187720275961 3
5.883529982115256 3
7.080927100973279 3
6.813421006488534 3
6.943175519114153 3
7.492336555936649 3
6.319321858991114 3
6.91549197259537 3
6.702638117226496 3
7.417302004974863 3
7.78477065101559 3
6.044574737626311 3
7.585910431102616 3
x y
0.5 0.0044318484119380075
0.6224489795918368 0.0063513463131534146
0.7448979591836735 0.008966748444677233
0.8673469387755102 0.012470747171139728
0.9897959183673469 0.017085915686358193
1.1122448979591837 0.023060692208763875
1.2346938775510203 0.030661593077694442
1.3571428571428572 0.04016108044090312
1.4795918367346939 0.051820828999617916
1.6020408163265305 0.06587060018907169
1.7244897959183674 0.08248351897454742
1.846938775510204 0.10174920793009684
1.9693877551020407 0.12364688773086303
2.0918367346938775 0.14802110351235884
2.2142857142857144 0.1745630742814002
2.336734693877551 0.20280068705640536
2.4591836734693877 0.2320997956849513
2.5816326530612246 0.2616787100740331
2.704081632653061 0.29063660944969527
2.826530612244898 0.31799518388693393
2.9489795918367347 0.3427512620862568
3.071428571428571 0.3639367217154836
3.193877551020408 0.3806808152989237
3.316326530612245 0.3922693707583609
3.4387755102040813 0.3981952754136922
3.561224489795918 0.39819527541369226
3.683673469387755 0.3922693707583609
3.806122448979592 0.3806808152989237
3.9285714285714284 0.3639367217154837
4.051020408163265 0.3427512620862568
4.173469387755102 0.31799518388693404
4.295918367346939 0.29063660944969527
4.418367346938775 0.2616787100740331
4.540816326530612 0.23209979568495137
4.663265306122449 0.20280068705640536
4.785714285714286 0.1745630742814002
4.908163265306122 0.14802110351235895
5.030612244897959 0.12364688773086303
5.153061224489796 0.10174920793009688
5.275510204081632 0.08248351897454748
5.3979591836734695 0.06587060018907169
5.520408163265306 0.051820828999617916
5.642857142857142 0.040161080440903156
5.76530612244898 0.030661593077694442
5.887755102040816 0.023060692208763875
6.0102040816326525 0.017085915686358217
6.13265306122449 0.012470747171139728
6.255102040816326 0.008966748444677233
6.377551020408163 0.00635134631315342
6.5 0.0044318484119380075
x y
-0.5 0.0044318484119380075
-0.37755102040816324 0.0063513463131534146
-0.25510204081632654 0.00896674844467722
-0.13265306122448983 0.012470747171139728
-0.010204081632653073 0.017085915686358193
0.11224489795918369 0.023060692208763875
0.23469387755102034 0.030661593077694442
0.3571428571428571 0.04016108044090312
0.47959183673469385 0.051820828999617916
0.6020408163265305 0.06587060018907169
0.7244897959183674 0.08248351897454742
0.846938775510204 0.10174920793009684
0.9693877551020407 0.12364688773086303
1.0918367346938775 0.14802110351235884
1.2142857142857142 0.17456307428140014
1.336734693877551 0.2028006870564054
1.4591836734693877 0.2320997956849513
1.5816326530612246 0.2616787100740331
1.704081632653061 0.29063660944969527
1.8265306122448979 0.31799518388693393
1.9489795918367347 0.3427512620862568
2.071428571428571 0.3639367217154836
2.193877551020408 0.3806808152989237
2.316326530612245 0.3922693707583609
2.4387755102040813 0.3981952754136922
2.561224489795918 0.39819527541369226
2.683673469387755 0.3922693707583609
2.806122448979592 0.3806808152989237
2.9285714285714284 0.3639367217154837
3.0510204081632653 0.3427512620862568
3.173469387755102 0.31799518388693393
3.2959183673469385 0.2906366094496954
3.4183673469387754 0.2616787100740331
3.540816326530612 0.23209979568495137
3.663265306122449 0.20280068705640536
3.7857142857142856 0.1745630742814002
3.908163265306122 0.14802110351235895
4.030612244897959 0.12364688773086303
4.153061224489796 0.10174920793009688
4.275510204081632 0.08248351897454748
4.3979591836734695 0.06587060018907169
4.520408163265306 0.051820828999617916
4.642857142857142 0.040161080440903156
4.76530612244898 0.030661593077694442
4.887755102040816 0.023060692208763875
5.0102040816326525 0.017085915686358217
5.13265306122449 0.012470747171139728
5.255102040816326 0.008966748444677233
5.377551020408163 0.00635134631315342
5.5 0.0044318484119380075
x y
4.0 0.0044318484119380075
4.122448979591836 0.006351346313153403
4.244897959183674 0.008966748444677233
4.36734693877551 0.012470747171139728
4.489795918367347 0.017085915686358172
4.612244897959184 0.023060692208763875
4.73469387755102 0.030661593077694442
4.857142857142857 0.040161080440903094
4.979591836734694 0.051820828999617916
5.1020408163265305 0.06587060018907169
5.224489795918368 0.08248351897454748
5.346938775510204 0.10174920793009688
5.469387755102041 0.12364688773086303
5.591836734693878 0.14802110351235895
5.714285714285714 0.1745630742814002
5.836734693877551 0.20280068705640536
5.959183673469388 0.23209979568495137
6.081632653061225 0.2616787100740331
6.204081632653061 0.29063660944969527
6.326530612244898 0.31799518388693404
6.448979591836735 0.3427512620862568
6.571428571428571 0.3639367217154836
6.6938775510204085 0.3806808152989237
6.816326530612245 0.3922693707583609
6.938775510204081 0.3981952754136922
7.061224489795919 0.3981952754136922
7.183673469387755 0.3922693707583609
7.3061224489795915 0.3806808152989237
7.428571428571429 0.3639367217154836
7.551020408163265 0.3427512620862568
7.673469387755102 0.31799518388693404
7.795918367346939 0.29063660944969527
7.918367346938775 0.2616787100740331
8.040816326530612 0.23209979568495137
8.16326530612245 0.20280068705640536
8.285714285714285 0.17456307428140042
8.408163265306122 0.14802110351235895
8.53061224489796 0.12364688773086303
8.653061224489797 0.10174920793009673
8.775510204081632 0.08248351897454748
8.89795918367347 0.06587060018907169
9.020408163265305 0.051820828999618006
9.142857142857142 0.040161080440903156
9.26530612244898 0.030661593077694442
9.387755102040817 0.023060692208763823
9.510204081632653 0.017085915686358217
9.63265306122449 0.012470747171139728
9.755102040816325 0.008966748444677257
9.877551020408163 0.00635134631315342
10.0 0.0044318484119380075
\input{figures/figure-theme.tex}
\begingroup
\begin{tikzpicture}[aml figure]
\amlfigurepalette
\def\nodesep{1.5em}
\def\noderowsep{2em}
\tikzstyle{pnode} = [minimum width=6.5em,minimum height=2em,inner sep=3pt,draw=FigureInk!65,fill=FigureMist,line width=.7pt,rounded corners=2pt]
%%%%%%%%%%
%% CBOW
\begin{scope}
%% word vectors
\node [pnode,anchor=east] (e2) at (-\nodesep,0) {\footnotesize{$\mathbf{e}_{i-1}=\boldsymbol{1}_{w_{i-1}} \mathbf{C}$}};
\node [pnode,anchor=east] (e1) at ([xshift=-\nodesep]e2.west) {\footnotesize{$\mathbf{e}_{i-2}=\boldsymbol{1}_{w_{i-2}} \mathbf{C}$}};
\node [pnode,anchor=west] (e4) at (\nodesep,0) {\footnotesize{$\mathbf{e}_{i+1}=\boldsymbol{1}_{w_{i+1}} \mathbf{C}$}};
\node [pnode,anchor=west] (e5) at ([xshift=\nodesep]e4.east) {\footnotesize{$\mathbf{e}_{i+2}=\boldsymbol{1}_{w_{i+2}} \mathbf{C}$}};
%% input words
\node [anchor=north] (w1) at ([yshift=-0.8*\noderowsep]e1.south) {$w_{i-2}$};
\node [anchor=north] (w2) at ([yshift=-0.8*\noderowsep]e2.south) {$w_{i-1}$};
\node [anchor=north] (w4) at ([yshift=-0.8*\noderowsep]e4.south) {$w_{i+1}$};
\node [anchor=north] (w5) at ([yshift=-0.8*\noderowsep]e5.south) {$w_{i+2}$};
%% hidden states
\node [pnode,anchor=south,minimum width=18.0em,minimum height=2.5em] (hidden) at ([xshift=\nodesep,yshift=\noderowsep]e2.north east) {$\mathbf{h} = \frac{1}{4} \left( \sum_{j=i-2}^{i-1} \mathbf{e}_{j} + \sum_{j=i+1}^{i+2} \mathbf{e}_{j} \right)$};
%% softmax
\node [pnode,anchor=south,minimum width=18.0em,minimum height=2.5em] (softmax) at ([yshift=\noderowsep]hidden.north) {$\mathbf{y} = \mathrm{Softmax}(\mathbf{h} \mathbf{U} + \mathbf{b})$};
%% output
\node [anchor=south] (output) at ([yshift=0.8*\noderowsep]softmax.north) {$\Pr(w_{i}|w_{i-2},w_{i-1},w_{i+1},w_{i+2})=y(w_{i})$};
%% connections
\draw [->,thick] ([yshift=1pt]w1.north) -- ([yshift=-1pt]e1.south);
\draw [->,thick] ([yshift=1pt]w2.north) -- ([yshift=-1pt]e2.south);
\draw [->,thick] ([yshift=1pt]w4.north) -- ([yshift=-1pt]e4.south);
\draw [->,thick] ([yshift=1pt]w5.north) -- ([yshift=-1pt]e5.south);
\draw [->,thick] ([yshift=1pt]e1.north) .. controls +(north:2em) and +(south:1.5em) .. ([xshift=-5em,yshift=-1pt]hidden.south);
\draw [->,thick] ([yshift=1pt,xshift=-0em]e2.north) .. controls +(north:1.5em) and +(south:1.5em) .. ([xshift=-1.5em,yshift=-1pt]hidden.south);
\draw [->,thick] ([yshift=1pt,xshift=0em]e4.north) .. controls +(north:1.5em) and +(south:1.5em) .. ([xshift=1.5em,yshift=-1pt]hidden.south);
\draw [->,thick] ([yshift=1pt]e5.north) .. controls +(north:2em) and +(south:1.5em) .. ([xshift=5em,yshift=-1pt]hidden.south);
\draw [->,thick] ([yshift=1pt]hidden.north) -- ([yshift=-1pt]softmax.south);
\draw [->,thick] ([yshift=1pt]softmax.north) -- ([yshift=-1pt]output.south);
%% label
\node [anchor=north] (labela) at ([xshift=\nodesep,yshift=-1.6*\noderowsep]e2.south east) {(a) CBOW};
\node [anchor=south] (embeddinglabel) at (e1.north west) {\textbf{Embedding}};
\end{scope}
%%%%%%%%%%
%% skip-gram
\begin{scope}[yshift=-16em]
%% softmax
\node [pnode,anchor=east,align=left] (softmax2) at (-\nodesep,0) {\footnotesize{$\mathbf{y}_{-1}=\mathrm{Softmax}($}\\\footnotesize{$\mathbf{h} \mathbf{V}_{-1} + \mathbf{b}_{-1})$}};
\node [pnode,anchor=east,align=left] (softmax1) at ([xshift=-\nodesep]softmax2.west) {\footnotesize{$\mathbf{y}_{-2}=\mathrm{Softmax}($}\\\footnotesize{$\mathbf{h} \mathbf{V}_{-2} + \mathbf{b}_{-2})$}};
\node [pnode,anchor=west,align=left] (softmax4) at (\nodesep,0) {\footnotesize{$\mathbf{y}_{1}=\mathrm{Softmax}($}\\\footnotesize{$\mathbf{h} \mathbf{V}_{1} + \mathbf{b}_{1})$}};
\node [pnode,anchor=west,align=left] (softmax5) at ([xshift=\nodesep]softmax4.east) {\footnotesize{$\mathbf{y}_{2}=\mathrm{Softmax}($}\\\footnotesize{$\mathbf{h} \mathbf{V}_{2} + \mathbf{b}_{2})$}};
%% output
\node [anchor=south,align=left] (output1) at ([yshift=0.8*\noderowsep]softmax1.north) {\ \ \ \footnotesize{$\Pr(w_{i-2}|w_i)$}\\\footnotesize{$=y_{-2}(w_{i-2})$}};
\node [anchor=south,align=left] (output2) at ([yshift=0.8*\noderowsep]softmax2.north) {\ \ \ \footnotesize{$\Pr(w_{i-1}|w_i)$}\\\footnotesize{$=y_{-1}(w_{i-1})$}};
\node [anchor=south,align=left] (output4) at ([yshift=0.8*\noderowsep]softmax4.north) {\ \ \ \footnotesize{$\Pr(w_{i+1}|w_i)$}\\\footnotesize{$=y_{1}(w_{i+1})$}};
\node [anchor=south,align=left] (output5) at ([yshift=0.8*\noderowsep]softmax5.north) {\ \ \ \footnotesize{$\Pr(w_{i+2}|w_i)$}\\\footnotesize{$=y_{2}(w_{i+2})$}};
%% hidden states
\node [pnode,anchor=north] (hidden) at ([xshift=\nodesep,yshift=-1.2*\noderowsep]softmax2.south east) {$\mathbf{h} = w_i \mathbf{C}$};
%% input
\node [anchor=north] (input) at ([yshift=-0.8*\noderowsep]hidden.south) {$w_i$};
%% connections
\draw [->,thick] ([yshift=1pt]softmax1.north) -- ([yshift=-1pt]output1.south);
\draw [->,thick] ([yshift=1pt]softmax2.north) -- ([yshift=-1pt]output2.south);
\draw [->,thick] ([yshift=1pt]softmax4.north) -- ([yshift=-1pt]output4.south);
\draw [->,thick] ([yshift=1pt]softmax5.north) -- ([yshift=-1pt]output5.south);
\draw [->,thick] ([xshift=1em,yshift=1pt]hidden.north west) .. controls +(north:2em) and +(south:2.5em) .. ([yshift=-1pt]softmax1.south);
\draw [->,thick] ([xshift=-1em,yshift=1pt]hidden.north) .. controls +(north:2.5em) and +(south:1.5em) .. ([yshift=-1pt]softmax2.south);
\draw [->,thick] ([xshift=1em,yshift=1pt]hidden.north) .. controls +(north:2.5em) and +(south:1.5em) .. ([yshift=-1pt]softmax4.south);
\draw [->,thick] ([xshift=-1em,yshift=1pt]hidden.north east) .. controls +(north:2em) and +(south:2.5em) .. ([yshift=-1pt]softmax5.south);
\draw [->,thick] ([yshift=1pt]input.north) -- ([yshift=-1pt]hidden.south);
%% label
\node [anchor=north] (labelb) at ([xshift=0,yshift=-0.5em]input.south) {(b) Skip-gram};
\node [anchor=east] (embeddinglabel) at (hidden.west) {\textbf{Embedding}};
\end{scope}
\end{tikzpicture}
\endgroup
%\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\begin{tikzpicture}
\begin{scope}
\begin{axis}[
width=6.5cm, height=5cm,
%symbolic x coords={1-15,16-25,26-35,>35},
ytick={0,4,8,...,20},
xtick={200,400,...,1200},
xlabel={Data size},
ylabel={Vocabulary size},
xlabel style={align=center},
ylabel style={yshift=-1.2em},
%y tick style={opacity=0},
x tick label style={font=\footnotesize},
y tick label style={font=\footnotesize},
tick align=inside,
%major grid style={draw=blue,dashed},
legend pos=outer north east,
%legend style={anchor=north west,yshift=-1cm},
%legend style={yshift=-4.5em,xshift=-6em,legend cell align=left,legend plot pos=right},
xmin=-20,
xmax=1220,
ymin=-2,
ymax=22]
%\addplot [sharp plot,very thick,ublue,mark=o] coordinates{(4.72,1.48) (9.45, 2.37) (14.18, 3.09) (18.91, 3.74) (23.64, 4.32) (28.37, 4.85) (33.09, 5.35) (37.82, 5.82) (42.55, 6.27) (47.28, 6.7) (51.58, 6.7) (55.88, 7.1) (60.17, 7.49) (64.47, 7.87) (68.77, 8.24) (73.07, 8.59) (77.37, 8.93) (81.67, 9.26) (85.97, 9.3)};
%\addplot [sharp plot,thick,blue,mark=square] coordinates{(6,1.69) (12, 2.64) (18, 3.40) (24, 4.04) (30, 4.6) (36, 5.1) (42, 5.55) (48, 5.96) (54, 6.34) (60, 6.7) (66, 7.0) (72, 7.34) (78, 7.62) (84, 7.88) (90, 8.12) (96, 8.35) (102, 8.56) (108, 8.75) (114, 8.94) (120, 9.12)};
\addplot [sharp plot,thick,blue,mark=square] coordinates{(0.1,0.04) (0.25, 0.09) (0.76, 0.21) (1.7, 0.36) (3.59, 0.58) (9.28, 1.07) (18.64, 1.74) (37.46, 2.83) (56.47, 3.73) (75.97, 4.5) (95.78, 5.19) (198.93, 8) (417.56, 12.03) (1102.31, 19.9)};
%\addplot [sharp plot,very thick,orange,mark=*] coordinates{(1-15,17.5) (16-25,24) (26-35,25) (>35,27)};
%\legend{\tiny{NMT},\tiny{SPB},\tiny{HPB},\tiny{PBSY}}
\end{axis}
\node[anchor=east] (ny) at (1.2em,9.8em){\footnotesize($\cdot 10^4$)};
\node[anchor=west] (nx) at (12.8em,0.4em){\footnotesize($\cdot 10^5$)};
\end{scope}
\begin{scope}[xshift=2.85in]
\begin{axis}[
width=6.5cm, height=5cm,
title={},
xlabel={Vocabulary size},
ylabel={OOV percentage},
ylabel style={yshift=-1.2em},
xmin=-1, xmax=21,
% ymin=0, ymax=10e-2,
ymin=0, ymax=100,
xtick={0,4,...,20},
% ytick={0,1e-2,2e-2,3e-2,4e-2,5e-2,6e-2,7e-2,8e-2,9e-2,10e-2},
ytick={20,40,...,100},
]
\addplot[
color=blue,
mark=square,
thick,
]
% coordinates {(27248,0.0867) (69248,0.0383) (100195,0.0268) (144777,0.0184) (180743,0.0148)};
% coordinates {(0.27,8.67) (0.38,6.27) (0.52,4.97) (0.69,3.83) (1.0,2.68) (1.44,1.84) (1.8,1.48)};
% coordinates {(0.27,60.1) (0.38,51.63) (0.52,41.22) (0.69,33.97) (1.0,28.64) (1.44,23.19) (1.8,1.48)};
coordinates {(0.04, 60.1) (0.09, 51.63) (0.21, 41.22) (0.36, 33.97) (0.58, 28.64) (1.07, 23.19) (1.74, 19.97) (2.83, 17.73) (3.73, 16.94) (4.5, 16.52) (5.19, 16.26) (8, 15.71) (12.03, 15.44) (19.9, 15.27)};
\end{axis}
\node[anchor=east] (ny) at (1.2em,9.8em){\footnotesize($\%$)};
\node[anchor=west] (nx) at (12.8em,0.4em){\footnotesize($\cdot 10^4$)};
\end{scope}
\end{tikzpicture}
%---------------------------------------------------------------------
\ No newline at end of file
\input{figures/figure-theme.tex}
\begin{tikzpicture}[aml figure,scale=1.0]
\amlfigurepalette
\tikzstyle{circlenode1}=[circle,minimum size=3pt, fill=blue, inner sep=0]
\tikzstyle{circlenode2}=[circle,minimum size=3pt, fill=red, inner sep=0]
\tikzstyle{circlenode3}=[circle,minimum size=2pt, fill=black, inner sep=0,black]
\begin{axis}[aml axis,ymin=0,ymax=14, ytick={0, 2,4,6,8,10,12,14},
xmin=0,xmax=12, xtick={0, 2,4,6,8,10,12},
scatter/classes={%
a={mark=*,draw=FigureInk,fill=FigureInk}}]
\addplot[scatter,only marks,%
scatter src=explicit symbolic]%
table[meta=label] {
x y label
0.6 3.3 a
2 2.5 a
4.3 12 a
4.7 3.3 a
4.5 1 a
5 6.8 a
6 10 a
8 1 a
3.6 13.5 a
1.5 8 a
7.5 9.8 a
};
% \addplot[domain=1.8:2,blue] {x*x};
% \addplot[domain=2:2.2,blue] {x*x+1};
% \draw[dotted] (axis cs:2,0) -- (axis cs:2,5);
% \addplot[holdot] coordinates{(2,4)};
% \addplot[soldot] coordinates{(2,5)};
% \draw[dotted] (axis cs:0,4.5) -- (axis cs:2,4.5);
% \draw[->] (axis cs:1.9, 1.9*1.9+0.1) -- (axis cs:1.95, 1.95*1.95+0.1);
\draw[->, thick] (axis cs:0, 0) -- (axis cs:5.5, 12.65) ;
\node[anchor=north west, font=\footnotesize] at (axis cs:6, 13) {Direction 1};
\node[circlenode3] (node3) at (axis cs:4.7, 5.7){};
\node[,anchor=north east,font=\footnotesize] at (axis cs:4.9, 5.7){Proj.};
\node[] (node1)at ($(axis cs:1.3, 0)!(axis cs:4.7, 5.7)!(axis cs:6.3, 11.5)$) {};
\draw[->,thick] (node3) -- (node1);
\draw[red,dotted] (axis cs:5, 6.8) -- ($(axis cs:0, 0)!(axis cs:5, 6.8)!(axis cs:5, 11.5)$);
\node[circlenode2] at ($(axis cs:0, 0)!(axis cs:5, 6.8)!(axis cs:5, 11.5)$){};
\draw[red,dotted] (axis cs:6, 10) -- ($(axis cs:0, 0)!(axis cs:6, 10)!(axis cs:5, 11.5)$);
\node[circlenode2] at ($(axis cs:0, 0)!(axis cs:6, 10)!(axis cs:5, 11.5)$){};
\draw[red,dotted] (axis cs:7.5, 9.8) -- ($(axis cs:0, 0)!(axis cs:7.5, 9.8)!(axis cs:5, 11.5)$);
\node[circlenode2] at ($(axis cs:0, 0)!(axis cs:7.5, 9.8)!(axis cs:5, 11.5)$){};
\draw[red,dotted] (axis cs:8, 1) -- ($(axis cs:0, 0)!(axis cs:8, 1)!(axis cs:5, 11.5)$);
\node[circlenode2] at ($(axis cs:0, 0)!(axis cs:8, 1)!(axis cs:5, 11.5)$){};
\draw[red,dotted] (axis cs:4.5, 1) -- ($(axis cs:0, 0)!(axis cs:4.5, 1)!(axis cs:5, 11.5)$);
\node[circlenode2] at ($(axis cs:0, 0)!(axis cs:4.5, 1)!(axis cs:5, 11.5)$){};
\draw[red,dotted] (axis cs:0.6, 3.3 ) -- ($(axis cs:0, 0)!(axis cs:0.6, 3.3)!(axis cs:5, 11.5)$);
\node[circlenode2] at ($(axis cs:0, 0)!(axis cs:0.6, 3.3)!(axis cs:5, 11.5)$){};
\draw[red,dotted] (axis cs:4.7, 3.3 ) -- ($(axis cs:0, 0)!(axis cs:4.7, 3.3)!(axis cs:5, 11.5)$);
\node[circlenode2] at ($(axis cs:0, 0)!(axis cs:4.7, 3.3)!(axis cs:5, 11.5)$){};
\draw[red,dotted] (axis cs:4.3, 12 ) -- ($(axis cs:0, 0)!(axis cs:4.3, 12)!(axis cs:5, 11.5)$);
\node[circlenode2] at ($(axis cs:0, 0)!(axis cs:4.3, 12)!(axis cs:5, 11.5)$){};
\draw[red,dotted] (axis cs:3.6, 13.5 ) -- ($(axis cs:0, 0)!(axis cs:3.6, 13.5)!(axis cs:5, 11.5)$);
\node[circlenode2] at ($(axis cs:0, 0)!(axis cs:3.6, 13.5)!(axis cs:5, 11.5)$){};
\draw[red,dotted] (axis cs:1.5, 8 ) -- ($(axis cs:0, 0)!(axis cs:1.5, 8)!(axis cs:5, 11.5)$);
\node[circlenode2] at ($(axis cs:0, 0)!(axis cs:1.5, 8)!(axis cs:5, 11.5)$){};
\draw[red,dotted] (axis cs:2,2.5 ) -- ($(axis cs:0, 0)!(axis cs:2,2.5)!(axis cs:5, 11.5)$);
\node[circlenode2] at ($(axis cs:0, 0)!(axis cs:2,2.5)!(axis cs:5, 11.5)$){};
\draw[->, thick] (axis cs:0, 0) -- (axis cs:11, 6) ;
\draw[blue,dotted] (axis cs:2, 2.5) -- ($(axis cs:0, 0)!(axis cs:2, 2.5)!(axis cs:11,6)$);
\node[circlenode1] at ($(axis cs:0, 0)!(axis cs:2, 2.5)!(axis cs:11, 6)$){};
\node[] (node2)at ($(axis cs:-3.5, 0)!(axis cs:4.7, 5.7)!(axis cs:7.5,6)$) {};
\draw[->,thick] (node3) -- (node2);
%\draw[blue,dotted] (axis cs:3.6, 5.6) -- ($(axis cs:0, 0)!(axis cs:3.6, 5.6)!(axis cs:11, 6)$);
%\node[circlenode1] at ($(axis cs:0, 0)!(axis cs:3.6, 5.6)!(axis cs:11, 6)$){};
\draw[blue,dotted] (axis cs:5, 6.8) -- ($(axis cs:0, 0)!(axis cs:5, 6.8)!(axis cs:11, 6)$);
\node[circlenode1] at ($(axis cs:0, 0)!(axis cs:5, 6.8)!(axis cs:11, 6)$){};
\draw[blue,dotted] (axis cs:6, 10) -- ($(axis cs:0, 0)!(axis cs:6, 10)!(axis cs:11, 6)$);
\node[circlenode1] at ($(axis cs:0, 0)!(axis cs:6, 10)!(axis cs:11, 6)$){};
\draw[blue,dotted] (axis cs:7.5, 9.8) -- ($(axis cs:0, 0)!(axis cs:7.5, 9.8)!(axis cs:11, 6)$);
\node[circlenode1] at ($(axis cs:0, 0)!(axis cs:7.5, 9.8)!(axis cs:11, 6)$){};
\draw[blue,dotted] (axis cs:4.5, 1) -- ($(axis cs:0, 0)!(axis cs:4.5, 1)!(axis cs:11, 6)$);
\node[circlenode1] at ($(axis cs:0, 0)!(axis cs:4.5, 1)!(axis cs:11, 6)$){};
\draw[blue,dotted] (axis cs:0.6, 3.3 ) -- ($(axis cs:0, 0)!(axis cs:0.6, 3.3)!(axis cs:11, 6)$);
\node[circlenode1] at ($(axis cs:0, 0)!(axis cs:0.6, 3.3)!(axis cs:11, 6)$){};
\draw[blue,dotted] (axis cs:8, 1 ) -- ($(axis cs:0, 0)!(axis cs:8, 1)!(axis cs:11, 6)$);
\node[circlenode1] at ($(axis cs:0, 0)!(axis cs:8, 1)!(axis cs:11, 6)$){};
\draw[blue,dotted] (axis cs:4.7, 3.3 ) -- ($(axis cs:0, 0)!(axis cs:4.7, 3.3)!(axis cs:11, 6)$);
\node[circlenode1] at ($(axis cs:0, 0)!(axis cs:4.7, 3.3)!(axis cs:11, 6)$){};
\draw[blue,dotted] (axis cs:4.3, 12 ) -- ($(axis cs:0, 0)!(axis cs:4.3, 12)!(axis cs:11, 6)$);
\node[circlenode1] at ($(axis cs:0, 0)!(axis cs:4.3, 12)!(axis cs:11, 6)$){};
\draw[blue,dotted] (axis cs:3.6, 13.5 ) -- ($(axis cs:0, 0)!(axis cs:3.6, 13.5)!(axis cs:11, 6)$);
\node[circlenode1] at ($(axis cs:0, 0)!(axis cs:3.6, 13.5)!(axis cs:11, 6)$){};
\draw[blue,dotted] (axis cs:1.5,8 ) -- ($(axis cs:0, 0)!(axis cs:1.5,8)!(axis cs:11, 6)$);
\node[circlenode1] at ($(axis cs:0, 0)!(axis cs:1.5,8)!(axis cs:11, 6)$){};
\node[anchor=north east,font=\footnotesize] at (axis cs:11.5,7.5) {Direction 2};
% \node[anchor=east] (source) at (axis cs:2.1,5){\text\ F(x)};
% \node[anchor=east] (source) at (axis cs:1.95,3.5){\text\ F(x)};
% \node[anchor=north](source) at (axis cs:1.8,4.6){$\omega$};
% \node[anchor=south](source) at (axis cs:2,3.2){$X^{+/-}(\omega)$};
\end{axis}
\end{tikzpicture}
\begin{center}
\begin{tikzpicture}
%----------------------------------------------------------------------------------------
% variables
\def\nodesize{1.2em}
\tikzstyle{nnode} = [circle,minimum size=\nodesize,inner sep=0,fill=ugreen!20]
%----------------------------------------------------------------------------------------
% code (or representation)
\node [nnode] (code1) at (0,0) {\scriptsize{0}};
\node [nnode,anchor=north] (code2) at ([yshift=-0.3*\nodesize]code1.south) {\scriptsize{5}};
\node [nnode,anchor=north] (code3) at ([yshift=-0.3*\nodesize]code2.south) {\scriptsize{-1}};
\node [nnode,anchor=north] (code4) at ([yshift=-0.3*\nodesize]code3.south) {\scriptsize{.8}};
\begin{pgfonlayer}{background}
\node [draw,inner sep=3pt,fill=white] [fit = (code1) (code4)] (codebox) {};
\end{pgfonlayer}
\node [anchor=south] (codelabel) at ([yshift=1.5em]codebox.north) {Code $\mathbf{h}$};
\node [anchor=north] (bottleneck) at ([yshift=2pt]codelabel.south) {(Bottleneck)};
%----------------------------------------------------------------------------------------
% encoder
\node [nnode,anchor=east,fill=blue!20] (input2) at ([xshift=-7*\nodesize]code1.west) {\scriptsize{3}};
\node [nnode,anchor=south,fill=blue!20] (input1) at ([yshift=0.3*\nodesize]input2.north) {\scriptsize{7}};
\node [nnode,anchor=north,fill=blue!20] (input3) at ([yshift=-0.3*\nodesize]input2.south) {\scriptsize{.1}};
\node [nnode,anchor=north,fill=blue!20] (input4) at ([yshift=-0.3*\nodesize]input3.south) {\scriptsize{2}};
\node [nnode,anchor=north,fill=blue!20] (input5) at ([yshift=-0.3*\nodesize]input4.south) {\scriptsize{0}};
\node [nnode,anchor=north,fill=blue!20] (input6) at ([yshift=-0.3*\nodesize]input5.south) {\scriptsize{.1}};
\begin{pgfonlayer}{background}
\node [draw,inner sep=3pt,fill=white] [fit = (input1) (input6)] (inputbox) {};
\end{pgfonlayer}
\node [anchor=south] (inputlabel) at ([yshift=0.5em]inputbox.north) {Input $\mathbf{x}$};
\filldraw [fill=blue!20,draw=white] ([xshift=-5pt]codebox.south west) -- ([xshift=-5pt]codebox.north west) -- ([xshift=5pt]inputbox.north east) -- ([xshift=5pt]inputbox.south east) -- ([xshift=-5pt]codebox.south west);
\node [anchor=east] (encoderlabel) at ([xshift=-1.8em,yshift=0.5em]codebox.west) {\Large{Encoder}};
\node [anchor=north west] (encodereqn) at ([xshift=0em]encoderlabel.south west) {$\mathbf{h}=\mathrm{Enc}_{\theta}(\mathbf{x})$};
%----------------------------------------------------------------------------------------
% decoder
\node [nnode,anchor=west,fill=red!20] (output2) at ([xshift=7*\nodesize]code1.east) {\scriptsize{3}};
\node [nnode,anchor=south,fill=red!20] (output1) at ([yshift=0.3*\nodesize]output2.north) {\scriptsize{7}};
\node [nnode,anchor=north,fill=red!20] (output3) at ([yshift=-0.3*\nodesize]output2.south) {\scriptsize{.1}};
\node [nnode,anchor=north,fill=red!20] (output4) at ([yshift=-0.3*\nodesize]output3.south) {\scriptsize{0}};
\node [nnode,anchor=north,fill=red!20] (output5) at ([yshift=-0.3*\nodesize]output4.south) {\scriptsize{1}};
\node [nnode,anchor=north,fill=red!20] (output6) at ([yshift=-0.3*\nodesize]output5.south) {\scriptsize{.5}};
\begin{pgfonlayer}{background}
\node [draw,inner sep=3pt,fill=white] [fit = (output1) (output6)] (outputbox) {};
\end{pgfonlayer}
\node [anchor=south] (outputlabel) at ([yshift=0.5em]outputbox.north) {Reconstruction $\widetilde{\mathbf{x}}$};
\filldraw [fill=red!20,draw=white] ([xshift=5pt]codebox.south east) -- ([xshift=5pt]codebox.north east) -- ([xshift=-5pt]outputbox.north west) -- ([xshift=-5pt]outputbox.south west) -- ([xshift=5pt]codebox.south east);
\node [anchor=west] (decoderlabel) at ([xshift=1.2em,yshift=0.5em]codebox.east) {\Large{Decoder}};
\node [anchor=north west] (decodereqn) at ([xshift=0em]decoderlabel.south west) {$\widetilde{\mathbf{x}}=\mathrm{Dec}_{\omega}(\mathbf{h})$};
%----------------------------------------------------------------------------------------
% the training objective
\node [anchor=south] (objective) at ([yshift=6em,xshift=-2em]codebox.north) {$(\hat{\theta},\hat{\omega}) = \argmin\limits_{(\theta,\omega)} \sum\limits_{i=1}^{m} L ($};
\node [anchor=west,inner sep=2pt,minimum height=1.5em,fill=blue!20] (obj2) at ([yshift=4pt]objective.east) {$\mathbf{x}^{(i)}$};
\node [anchor=west,inner sep=3pt,minimum height=1.5em] (obj3) at ([yshift=-4pt]obj2.east) {$,$};
\node [anchor=west,inner sep=3pt,minimum height=1.5em,fill=red!20] (obj4) at ([yshift=4pt]obj3.east) {$\widetilde{\mathbf{x}}^{(i)}$};
\node [anchor=west,inner sep=2pt,minimum height=1.5em] (obj5) at ([yshift=-2pt]obj4.east) {$)$};
\draw [<-] (inputlabel.north) .. controls +(north:3em) and +(south:3em) .. (obj2.south);
\draw [<-] (outputlabel.north) .. controls +(north:3em) and +(south:3em) .. (obj4.south);
\node [anchor=south west] (objlabel) at ([yshift=-0.5em]objective.north west) {Training Objective:};
\end{tikzpicture}
\end{center}
\begin{center}
\begin{tikzpicture}[scale=1]
\begin{axis}[
axis x line=bottom,
axis y line=left,
line width=1.2pt,
xlabel near ticks,
width=12cm, height=6cm,
xlabel={Complexity},
y label style={font=\large},
xmin=-0.1,xmax=10,
ymin=0,ymax=20.5,
xmajorticks=false,
ymajorticks=false,
legend style={xshift=-1em,yshift=1em,anchor=north east,legend cell align=left},
]
\addplot[-latex,color=blue, line width=4pt, smooth,line cap=round,opacity=.55] coordinates {(0.2,20)(0.5,14.2)(1,10)(1.5,7.6)(2,6.04)(3,4.5)(4,3.7)(5,3.2)(6,2.8)(7,2.7)(8,2.6)(9.5,2.6)};
\addplot[-latex,color=ugreen, line width=4pt, smooth,line cap=round,opacity=.55] coordinates {(0.2,2.5)(1,2.6)(2,2.7)(3,3)(4,3.5)(5,4)(6,5.1)(7,6.5)(8,8.3)(8.8,10)(9.5,11.8)};
\addplot[-latex,color=red, line width=4pt, smooth,line cap=round,opacity=.55] coordinates {(0.35,20)(0.54,16.4)(1,11.88)(1.5,9.5)(2,8.2)(3,6.6)(4,5.7)(5,5.4)(6,6)(7,7.4)(8,9.2)(9.5,12.6)};
%\addplot[color=red, mark=x,draw=none,line width=1.6pt] coordinates {(0,1)(0.5,1)(1,1)(2,1)(3,1)(4,1)(5,1)(6,1)(7,1)(8,1)(9,1)};
\end{axis}
\node[color=blue,opacity=.6] (bias) at (2em,4.5em) {Bias};
\node[color=red,opacity=.6] (error) at (18em,5.3em) {Test Error};
\node[color=ugreen,opacity=.6] (variance) at (22em,3.2em) {Variance};
\end{tikzpicture}
\end{center}
\input{figures/figure-theme.tex}
\begin{center}
\begin{tikzpicture}[aml figure]
\amlfigurepalette
\begin{scope}
\node [anchor=south west,minimum width=20em] (source) at (0,0) {Source-side sequence: $\mathbf{x}=x_1...x_m$};
\node [anchor=south west,minimum width=20em] (target) at ([yshift=16em]source.north west) {Target-side sequence: $\mathbf{y}=y_1...y_n$};
\node [anchor=center,minimum width=9.6em,minimum height=1.8em,draw=FigureInk!65,fill=FigureMist,line width=.7pt,rounded corners=0.3em] (hidden) at ([yshift=8em]source.north) {};
\node [anchor=west,minimum width=1.5em,minimum size=1.5em,fill=ugreen!20] (cell01) at ([xshift=0.2em]hidden.west) {\footnotesize{.2}};
\node [anchor=west,minimum width=1.5em,minimum size=1.5em,fill=ugreen!10] (cell02) at (cell01.east) {\footnotesize{-1}};
\node [anchor=west,minimum width=1.5em,minimum size=1.5em,fill=ugreen!70] (cell03) at (cell02.east) {\footnotesize{6}};
\node [anchor=west,minimum width=1.5em,minimum size=1.5em,fill=ugreen!50] (cell04) at (cell03.east) {\footnotesize{5}};
\node [anchor=west,minimum width=1.5em,minimum size=1.5em,fill=ugreen!30] (cell05) at (cell04.east) {\footnotesize{.7}};
\node [anchor=west,minimum width=1.5em,minimum size=1.5em,fill=ugreen!10] (cell06) at (cell05.east) {\footnotesize{-2}};
\node [anchor=west] (representation) at ([xshift=0.5em]cell06.east) {Representation: $\mathbf{H}$};
\filldraw [fill=FigureCoral!16,draw=white] (source.north west) -- (source.north east) -- ([xshift=-0.2em,yshift=-0.1em]hidden.south east) -- ([xshift=0.2em,yshift=-0.1em]hidden.south west);
\filldraw [fill=FigureBlue!16,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] (source.north west) -- ([xshift=0.2em,yshift=-0.1em]hidden.south west);
\draw [->,thick] (source.north east) -- ([xshift=-0.2em,yshift=-0.1em]hidden.south east);
\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,align=center] (enclabel) at ([yshift=2em]source.north) {\Large{\textbf{Encoder}}\\($\mathbf{H}=\mathrm{Encode}(\mathbf{x})$)};
\node [anchor=north,align=center] (declabel) at ([yshift=-2em]target.south) {\Large{\textbf{Decoder}}\\($\mathbf{y}=\mathrm{Decode}(\mathbf{H})$)};
\end{scope}
\end{tikzpicture}
\end{center}
% !Mode:: "TeX:UTF-8"
% !TEX encoding = UTF-8 Unicode
\input{figures/figure-theme.tex}
\begin{center}
\begin{tikzpicture}[aml figure]
\amlfigurepalette
%----------------------------------------------------------------------------------------
% variables
\def\rowsep{0.5cm}
\def\colsep{0.4cm}
\def\ballsize{0.1cm}
\def\stepsize{0.5cm}
\tikzstyle{pnode} = [circle,minimum size=\ballsize,inner sep=2pt,fill=FigureMuted,draw=FigureInk!45,line width=.4pt]
%----------------------------------------------------------------------------------------
% rnn
\begin{scope}
\node [anchor=west,pnode] (p1) at (0,0) {};
\node [anchor=west,pnode] (p2) at ([xshift=\stepsize]p1.east) {};
\node [anchor=west,pnode] (p3) at ([xshift=\stepsize]p2.east) {};
\node [anchor=west,pnode] (p4) at ([xshift=\stepsize]p3.east) {};
\node [anchor=west,pnode,fill=blue] (p5) at ([xshift=\stepsize]p4.east) {};
\draw [->,thick] ([yshift=0.1em,xshift=-0.1em]p2.north) .. controls +(north:0.5cm) and +(north:0.5cm) .. ([yshift=0.1em]p1.north);
\draw [->,thick] ([yshift=0.1em,xshift=-0.1em]p3.north) .. controls +(north:0.5cm) and +(north:0.5cm) .. ([yshift=0.1em,xshift=0.1em]p2.north);
\draw [->,thick] ([yshift=0.1em,xshift=-0.1em]p4.north) .. controls +(north:0.5cm) and +(north:0.5cm) .. ([yshift=0.1em,xshift=0.1em]p3.north);
\draw [->,thick,blue] ([yshift=0.1em,xshift=-0.1em]p5.north) .. controls +(north:0.5cm) and +(north:0.5cm) .. ([yshift=0.1em,xshift=0.1em]p4.north);
\node [anchor=north] (rnnlabel) at ([yshift=-1em]p3.south) {(a) RNN};
\end{scope}
%----------------------------------------------------------------------------------------
% cnn
\begin{scope} [xshift=1.8in]
\node [anchor=west,pnode] (p1) at (0,0) {};
\node [anchor=west,pnode] (p2) at ([xshift=\stepsize]p1.east) {};
\node [anchor=west,pnode,fill=blue] (p3) at ([xshift=\stepsize]p2.east) {};
\node [anchor=west,pnode] (p4) at ([xshift=\stepsize]p3.east) {};
\node [anchor=west,pnode] (p5) at ([xshift=\stepsize]p4.east) {};
\draw [->,thick,blue] ([yshift=0.1em,xshift=-0.1em]p3.north) .. controls +(north:0.5cm) and +(north:0.5cm) .. ([yshift=0.1em]p2.north);
\draw [->,thick,blue] ([yshift=0.1em,xshift=0.1em]p3.north) .. controls +(north:0.5cm) and +(north:0.5cm) .. ([yshift=0.1em]p4.north);
\node [anchor=north] (rnnlabel) at ([yshift=-1em]p3.south) {(b) CNN ($r=3$)};
\end{scope}
%----------------------------------------------------------------------------------------
% self-attention
\begin{scope} [xshift=3.6in]
\node [anchor=west,pnode] (p1) at (0,0) {};
\node [anchor=west,pnode] (p2) at ([xshift=\stepsize]p1.east) {};
\node [anchor=west,pnode] (p3) at ([xshift=\stepsize]p2.east) {};
\node [anchor=west,pnode] (p4) at ([xshift=\stepsize]p3.east) {};
\node [anchor=west,pnode,fill=blue] (p5) at ([xshift=\stepsize]p4.east) {};
\draw [->,thick,blue] ([yshift=0.1em,xshift=-0.2em]p5.north) .. controls +(north:0.2cm) and +(north:0.2cm) .. ([yshift=0.1em]p4.north);
\draw [->,thick,blue] ([yshift=0.1em,xshift=-0.1em]p5.north) .. controls +(north:0.35cm) and +(north:0.35cm) .. ([yshift=0.1em]p3.north);
\draw [->,thick,blue] ([yshift=0.1em,xshift=0.1em]p5.north) .. controls +(north:0.5cm) and +(north:0.5cm) .. ([yshift=0.1em]p2.north);
\draw [->,thick,blue] ([yshift=0.1em,xshift=0.2em]p5.north) .. controls +(north:0.65cm) and +(north:0.65cm) .. ([yshift=0.1em]p1.north);
\node [anchor=north] (rnnlabel) at ([yshift=-1em]p3.south) {(c) Self-attention};
\end{scope}
\end{tikzpicture}
\end{center}
\input{figures/figure-theme.tex}
\begin{center}
\begin{tikzpicture}[aml figure,scale=0.45]
\amlfigurepalette
%-----small lr
\begin{scope}[xshift=0cm]
\foreach \a/\y in {0.5/0, 1/0.08, 1.6/0.15, 2.4/0.3, 3/0.34, 4/0.5, 5/0.7}{
\draw[FigureLine,rotate=25,line width=0.7pt] (0,\y) ellipse ({\a} and {\a*0.5});
}
\coordinate (n1) at (-4.4,-2);
\coordinate (n2) at (-4,-1.5);
\coordinate (n3) at (-3.4,-1.8);
\coordinate (n4) at (-3.3,-1.4);
\coordinate (n5) at (-2.8,-1.6);
\coordinate (n6) at (-2.7,-1.3);
\coordinate (n7) at (-2.3,-1.4);
\coordinate (n8) at (-2.2,-1.12);
\coordinate (n9) at (-1.85,-1.25);
\coordinate (n10) at (-1.65,-1.04);
\coordinate (n11) at (-1.25,-1.05);
\foreach \i in {1,...,10}{
\draw[-stealth,FigureGold,line width=0.75pt] ([xshift=0.06em]n\i) -- (n\the\numexpr\i+1\relax);
}
\draw[color=FigureInk,fill=FigureInk,rotate=25] (0,0) ellipse (0.1 and 0.05);
\node[anchor=center] (l1) at (-0.5,-4){(a) 学习率过小};
\end{scope}
%-----large lr
\begin{scope}[xshift=10.5cm]
\foreach \a/\y in {0.5/0, 1/0.08, 1.6/0.15, 2.4/0.3, 3/0.34, 4/0.5, 5/0.7}{
\draw[FigureLine,rotate=25,line width=0.7pt] (0,\y) ellipse ({\a} and {\a*0.5});
}
\coordinate (n1) at (-4.4,-2);
\coordinate (n2) at (-3,0.1);
\coordinate (n3) at (-1.5,-1.6);
\coordinate (n4) at (-1.1,0.8);
\coordinate (n5) at (0,-1.1);
\coordinate (n6) at (-0.5,0.9);
\coordinate (n7) at (0.2,-1);
\coordinate (n8) at (-0.3,0.9);
\coordinate (n9) at (0.3,-0.9);
\coordinate (n10) at (-0.1,0.9);
\foreach \i in {1,...,9}{
\draw[-stealth,FigureCoral,line width=0.75pt] ([xshift=0.06em]n\i) -- (n\the\numexpr\i+1\relax);
}
\draw[color=FigureInk,fill=FigureInk,rotate=25] (0,0) ellipse (0.1 and 0.05);
\node[anchor=center] (l2) at (-0.5,-4){(b) 学习率过大};
\end{scope}
%-----proper lr
\begin{scope}[xshift=21cm]
\foreach \a/\y in {0.5/0, 1/0.08, 1.6/0.15, 2.4/0.3, 3/0.34, 4/0.5, 5/0.7}{
\draw[FigureLine,rotate=25,line width=0.7pt] (0,\y) ellipse ({\a} and {\a*0.5});
}
\coordinate (n1) at (-4.4,-2);
\coordinate (n2) at (-3.6,-1);
\coordinate (n3) at (-2.4,-1.4);
\coordinate (n4) at (-2.1,-0.6);
\coordinate (n5) at (-1.4,-0.9);
\coordinate (n6) at (-1.3,-0.4);
\coordinate (n7) at (-0.92,-0.6);
\coordinate (n8) at (-0.74,-0.3);
\coordinate (n9) at (-0.46,-0.4);
\coordinate (n10) at (-0.28,-0.2);
\foreach \i in {1,...,9}{
\draw[-stealth,FigureTeal,line width=0.75pt] ([xshift=0.06em]n\i) -- (n\the\numexpr\i+1\relax);
}
\draw[color=FigureInk,fill=FigureInk,rotate=25] (0,0) ellipse (0.1 and 0.05);
\node[anchor=center] (l3) at (-0.5,-4){(c) 学习率合适};
\end{scope}
\end{tikzpicture}
\end{center}
\input{figures/figure-theme.tex}
\begin{center}
\begin{tikzpicture}[aml figure]
\amlfigurepalette
%----------------------------------------------------------------------------------------
% variables
\def\nodesep{4em}
\def\noderowsep{3.0em}
\tikzstyle{nnode} = [circle,minimum size=3em,draw=FigureBlue,line width=1pt,fill=FigureMist]
%----------------------------------------------------------------------------------------
% layer 1 (hidden 1)
\node [anchor=center,nnode] (neuron) at (0,0) {};
\node [anchor=north] (x2) at ([yshift=-\noderowsep]neuron.south) {$x_2$};
\node [anchor=east] (x1) at ([xshift=-\nodesep]x2.west) {$x_1$};
\node [anchor=west] (x3) at ([xshift=\nodesep]x2.east) {$1$};
\node [anchor=south] (y) at ([yshift=\noderowsep]neuron.north) {$y$};
\draw [->,very thick] ([yshift=0pt]x1.north east) -- ([yshift=-2pt]neuron.-120) node [pos=0.5,left,xshift=-0.3em] (w1) {$w_1$};
\draw [->,very thick] ([yshift=1pt]x2.north) -- ([yshift=-2pt]neuron.-90) node [pos=0.5,left,xshift=0.0em] (w1) {$w_2$};
\draw [->,very thick] ([yshift=0pt]x3.north west) -- ([yshift=-2pt]neuron.-60) node [pos=0.5,right,xshift=0.5em] (b) {$b$};
\draw [->,very thick] ([yshift=2pt]neuron.north) -- ([yshift=0pt]y.south);
\node [anchor=north west] (label01) at ([xshift=6em,yshift=-2em]y.north east) {\textbf{neuron}: };
\node [anchor=north west] (eqn) at (label01.south west) {${\displaystyle y = \begin{cases} 1 & x_1 \cdot w_1 + x_2 \cdot w_2 + b> 0 \\ 0 & \textrm{otherwise} \end{cases}}$};
\begin{pgfonlayer}{background}
\node [draw=FigureGold!80!FigureInk,inner sep=4pt,fill=FigureWarm,line width=.7pt,rounded corners=2pt] [fit = (label01) (eqn)] (neuronbox) {};
\end{pgfonlayer}
\draw [->,FigureTeal,line width=.9pt,dotted] ([yshift=2em]neuronbox.west) .. controls +(west:4em) and +(east:5em) .. ([yshift=0.5em,xshift=-1em]neuron.east);
\end{tikzpicture}
\end{center}
\input{figures/figure-theme.tex}
\begin{tikzpicture}[aml figure,node distance = 0,scale = 1]
\amlfigurepalette
\begin{scope}[xshift=0cm,yshift=0cm]
\tikzstyle{txt} = [minimum width = 1.6cm,minimum height=1cm,text width=2cm,align=left]
\node(row1)[minimum width = 3.1cm, text width=2cm,align=right]{Tokens};
\node(row2)[minimum width = 3.1cm, below of = row1, yshift = -1cm,text width=2cm,align=right]{POS tags};
\node(row3)[minimum width = 3.1cm, below of = row2, yshift = -1.1cm,text width=2cm,align=right]{Chunk tags};
\node(text1_1)[txt]at([xshift = 0.9cm]row1.east){Most};
\node(text1_2)[txt]at([xshift = 0.2cm,yshift = -0.05cm]text1_1.east){are};
\node(text1_3)[txt]at([xshift = -0.1cm,yshift = 0.02cm]text1_2.east){expected};
\node(text1_4)[txt]at([xshift = 0.6cm,yshift = 0.02cm]text1_3.east){to};
\node(text1_5)[txt]at([xshift = -0.2cm,yshift = 0.02cm]text1_4.east){fall};
\node(text1_6)[txt]at([xshift = 0cm]text1_5.east){below};
\node(text1_7)[txt]at([xshift = 0.4cm,yshift = -0.2cm]text1_6.east){previous-month};
\node(text1_8)[txt]at([xshift = 0.6cm,yshift = 0.2cm]text1_7.east){levels};
\node(text1_9)[txt]at([xshift = 0.1cm,yshift = -0.08cm]text1_8.east){.};
\node(text2_1)[txt, below of = text1_1, yshift = -1cm]{JJS};
\node(text2_2)[txt, below of = text1_2, yshift = -0.95cm]{VBP};
\node(text2_3)[txt, below of = text1_3, yshift = -0.97cm]{VBN};
\node(text2_4)[txt, below of = text1_4, yshift = -0.99cm]{TO};
\node(text2_5)[txt, below of = text1_5, yshift = -1.01cm]{VB};
\node(text2_6)[txt, below of = text1_6, yshift = -1.01cm]{IN};
\node(text2_7)[txt, below of = text1_7, yshift = -0.81cm]{JJ};
\node(text2_8)[txt, below of = text1_8, yshift = -1.01cm]{NNS};
\node(text2_9)[txt, below of = text1_9, yshift = -0.93cm]{.};
\node(text3_1)[txt, below of = text2_1, yshift = -1cm]{B-NP};
\node(text3_2)[txt, below of = text2_2, yshift = -1cm]{B-VP};
\node(text3_3)[txt, below of = text2_3, yshift = -1cm]{I-VP};
\node(text3_4)[txt, below of = text2_4, yshift = -1cm]{I-VP};
\node(text3_5)[txt, below of = text2_5, yshift = -1cm]{I-VP};
\node(text3_6)[txt, below of = text2_6, yshift = -1cm]{B-PP};
\node(text3_7)[txt, below of = text2_7, yshift = -1cm]{B-NP};
\node(text3_8)[txt, below of = text2_8, yshift = -1cm]{I-NP};
\node(text3_9)[txt, below of = text2_9, yshift = -1cm]{O};
\node(text4_1)[txt, below of = text3_1, yshift = -0.4cm, xshift = 0.2cm]{\small{NP}};
\node(text4_2)[txt, below of = text3_3, yshift = -0.4cm, xshift = 0.9cm]{\small{VP}};
\node(text4_3)[txt, below of = text3_6, yshift = -0.4cm, xshift = 0.2cm]{\small{PP}};
\node(text4_4)[txt, below of = text3_7, yshift = -0.4cm, xshift = 1cm]{\small{NP}};
\begin{pgfonlayer}{background}
\node[fit=(text1_1)(text1_9),fill=FigureMist,rounded corners=2pt,inner sep=3pt] {};
\node[fit=(text2_1)(text2_9),fill=FigureBlue!11,rounded corners=2pt,inner sep=3pt] {};
\node[fit=(text3_1)(text3_9),fill=FigureTeal!12,rounded corners=2pt,inner sep=3pt] {};
\end{pgfonlayer}
\node(sign1)at([xshift = -0.4cm]row1.east){:};
\node(sign2)at([xshift = -0.4cm]row2.east){:};
\node(sign3)at([xshift = -0.4cm,yshift = 0.0cm]row3.east){:};
\draw[-,FigureGold,line width=1.2pt]([xshift=-1.1cm,yshift=0.3cm]text3_1.south)to([xshift=-0.1cm,yshift=0.3cm]text3_1.south);
\draw[-,FigureGold,line width=1.2pt]([xshift=-1.1cm,yshift=0.3cm]text3_2.south)to([xshift=-0.2cm,yshift=0.3cm]text3_5.south);
\draw[-,FigureGold,line width=1.2pt]([xshift=-1.1cm,yshift=0.3cm]text3_6.south)to([xshift=-0.1cm,yshift=0.3cm]text3_6.south);
\draw[-,FigureGold,line width=1.2pt]([xshift=-1.cm,yshift=0.3cm]text3_7.south)to([xshift=-0.1cm,yshift=0.3cm]text3_8.south);
\end{scope}
\end{tikzpicture}
% !Mode:: "TeX:UTF-8"
% !TEX encoding = UTF-8 Unicode
\input{figures/figure-theme.tex}
\begin{tikzpicture}[aml figure]
\amlfigurepalette
\def\nodewidth{0.55cm}
\def\nodeheight{0.55cm}
\tikzstyle{enode} = [minimum width=\nodewidth,minimum height=\nodeheight,inner sep=2pt,draw=FigureLine,fill=FigureMist,line width=.45pt,rounded corners=1pt]
%%% pre-training encoders
\begin{scope}
\node [enode,anchor=west] (w0) at (0,0) {$x_0$};
\node [enode,anchor=west] (w1) at ([xshift=\nodewidth]w0.east) {$x_1$};
\node [enode,anchor=west] (w2) at ([xshift=\nodewidth]w1.east) {$x_2$};
\node [enode,anchor=west] (w3) at ([xshift=\nodewidth]w2.east) {$x_3$};
\node [enode,anchor=west] (w4) at ([xshift=\nodewidth]w3.east) {$x_4$};
\node [enode,anchor=north] (w3mask) at ([yshift=0.4em]w3.south) {\footnotesize{(masked)}};
\node [enode,anchor=south] (e0) at ([yshift=\nodeheight]w0.north) {$\mathbf{e}_0$};
\node [enode,anchor=west] (e1) at ([xshift=\nodewidth]e0.east) {$\mathbf{e}_1$};
\node [enode,anchor=west] (e2) at ([xshift=\nodewidth]e1.east) {$\mathbf{e}_2$};
\node [enode,anchor=west] (e3) at ([xshift=\nodewidth]e2.east) {$\mathbf{e}_3$};
\node [enode,anchor=west] (e4) at ([xshift=\nodewidth]e3.east) {$\mathbf{e}_4$};
\draw [->] (w0.north) -- ([yshift=0]e0.south);
\draw [->] (w1.north) -- ([yshift=0]e1.south);
\draw [->] (w2.north) -- ([yshift=0]e2.south);
\draw [->] (w3.north) -- ([yshift=0]e3.south);
\draw [->] (w4.north) -- ([yshift=0]e4.south);
\node [anchor=south,minimum width=10*\nodewidth,minimum height=2*\nodeheight,draw=FigureBlue,fill=FigureBlue!13,line width=.8pt,rounded corners=2pt] (encoder) at ([yshift=\nodeheight]e2.north) {\large{Encoder}};
\draw [->] ([yshift=0pt]e0.north) -- ([yshift=\nodeheight-2pt]e0.north);
\draw [->] ([yshift=0pt]e1.north) -- ([yshift=\nodeheight-2pt]e1.north);
\draw [->] ([yshift=0pt]e2.north) -- ([yshift=\nodeheight-2pt]e2.north);
\draw [->] ([yshift=0pt]e3.north) -- ([yshift=\nodeheight-2pt]e3.north);
\draw [->] ([yshift=0pt]e4.north) -- ([yshift=\nodeheight-2pt]e4.north);
\draw [->] ([yshift=3*\nodeheight+2pt]e0.north) -- ([yshift=3*\nodeheight+1.2*\nodeheight-2pt]e0.north);
\draw [->] ([yshift=3*\nodeheight+2pt]e1.north) -- ([yshift=3*\nodeheight+1.2*\nodeheight-2pt]e1.north);
\draw [->] ([yshift=3*\nodeheight+2pt]e2.north) -- ([yshift=3*\nodeheight+1.2*\nodeheight-2pt]e2.north);
\draw [->] ([yshift=3*\nodeheight+2pt]e3.north) -- ([yshift=3*\nodeheight+1.2*\nodeheight-2pt]e3.north);
\draw [->] ([yshift=3*\nodeheight+2pt]e4.north) -- ([yshift=3*\nodeheight+1.2*\nodeheight-2pt]e4.north);
\node [anchor=south,minimum width=10*\nodewidth,minimum height=\nodeheight,draw=FigureGold,fill=FigureWarm,line width=.8pt,rounded corners=2pt] (softmax) at ([yshift=1.2*\nodeheight]encoder.north) {Softmax};
\node [anchor=south west] (supervision1) at ([yshift=1.5*\nodeheight]softmax.north west) {\footnotesize{model reconstructs the masked token}};
\node [anchor=south west] (supervision2) at ([yshift=-0.4em]supervision1.north west) {\footnotesize{E.g., evaluate how well the}};
\node [anchor=south west] (supervision3) at ([yshift=-0.3em]supervision2.north west) {Self-supervision};
\draw [->,thick] ([yshift=1.5*\nodeheight,xshift=-0.8cm]softmax.north) .. controls +(south:0.6cm) and +(north:0.7cm) .. ([yshift=2pt]softmax.north);
\node [anchor=north] (caption) at ([yshift=-\nodeheight]w2.south) {\small{(a) Pre-training}};
\end{scope}
%%% applying pre-trained encoders
\begin{scope}[xshift=7cm]
\node [enode,anchor=west] (w0) at (0,0) {$x_0$};
\node [enode,anchor=west] (w1) at ([xshift=\nodewidth]w0.east) {$x_1$};
\node [enode,anchor=west] (w2) at ([xshift=\nodewidth]w1.east) {$x_2$};
\node [enode,anchor=west] (w3) at ([xshift=\nodewidth]w2.east) {$x_3$};
\node [enode,anchor=west] (w4) at ([xshift=\nodewidth]w3.east) {$x_4$};
\node [enode,anchor=south] (e0) at ([yshift=\nodeheight]w0.north) {$\mathbf{e}_0$};
\node [enode,anchor=west] (e1) at ([xshift=\nodewidth]e0.east) {$\mathbf{e}_1$};
\node [enode,anchor=west] (e2) at ([xshift=\nodewidth]e1.east) {$\mathbf{e}_2$};
\node [enode,anchor=west] (e3) at ([xshift=\nodewidth]e2.east) {$\mathbf{e}_3$};
\node [enode,anchor=west] (e4) at ([xshift=\nodewidth]e3.east) {$\mathbf{e}_4$};
\draw [->] (w0.north) -- ([yshift=0]e0.south);
\draw [->] (w1.north) -- ([yshift=0]e1.south);
\draw [->] (w2.north) -- ([yshift=0]e2.south);
\draw [->] (w3.north) -- ([yshift=0]e3.south);
\draw [->] (w4.north) -- ([yshift=0]e4.south);
\node [anchor=south,minimum width=10*\nodewidth,minimum height=2*\nodeheight,draw=FigureTeal,fill=FigureTeal!13,line width=.8pt,rounded corners=2pt] (encoder) at ([yshift=\nodeheight]e2.north) {\large{Pre-trained Encoder}};
\draw [->] ([yshift=0]e0.north) -- ([yshift=\nodeheight-2pt]e0.north);
\draw [->] ([yshift=0]e1.north) -- ([yshift=\nodeheight-2pt]e1.north);
\draw [->] ([yshift=0]e2.north) -- ([yshift=\nodeheight-2pt]e2.north);
\draw [->] ([yshift=0]e3.north) -- ([yshift=\nodeheight-2pt]e3.north);
\draw [->] ([yshift=0]e4.north) -- ([yshift=\nodeheight-2pt]e4.north);
\draw [->] ([yshift=3*\nodeheight+2pt]e0.north) -- ([yshift=3*\nodeheight+1.2*\nodeheight-2pt]e0.north);
\draw [->] ([yshift=3*\nodeheight+2pt]e1.north) -- ([yshift=3*\nodeheight+1.2*\nodeheight-2pt]e1.north);
\draw [->] ([yshift=3*\nodeheight+2pt]e2.north) -- ([yshift=3*\nodeheight+1.2*\nodeheight-2pt]e2.north);
\draw [->] ([yshift=3*\nodeheight+2pt]e3.north) -- ([yshift=3*\nodeheight+1.2*\nodeheight-2pt]e3.north);
\draw [->] ([yshift=3*\nodeheight+2pt]e4.north) -- ([yshift=3*\nodeheight+1.2*\nodeheight-2pt]e4.north);
\node [anchor=south,minimum width=10*\nodewidth,minimum height=\nodeheight,draw=FigureCoral,fill=FigureCoral!12,line width=.8pt,rounded corners=2pt] (softmax) at ([yshift=1.2*\nodeheight]encoder.north) {Prediction Network};
\node [anchor=south] (supervision1) at ([yshift=1.5*\nodeheight]softmax.north) {Output for Downstream Tasks};
\draw [->,thick] ([yshift=2pt]softmax.north) -- (supervision1.south);
\node [anchor=north] (caption) at ([yshift=-\nodeheight]w2.south) {\small{(b) Applying the Pre-trained Encoder}};
\end{scope}
\end{tikzpicture}
% !Mode:: "TeX:UTF-8"
% !TEX encoding = UTF-8 Unicode
\input{figures/figure-theme.tex}
\begin{tikzpicture}[aml figure]
\amlfigurepalette
\tikzstyle{cnode} = [minimum width=6em,minimum height=4em,inner sep=5pt,fill=FigureWarm,rounded corners=2pt]
\tikzstyle{snode} = [minimum width=8em,minimum height=8em,inner sep=5pt,fill=FigureMist,rounded corners=3pt]
%% embedding table
\node [cnode,anchor=center,draw=FigureCoral,line width=.9pt] (C) at (0,0) {{\color{FigureInk} $\mathbf{C} = \scriptsize{\begin{bmatrix} \bullet & \bullet \\ \bullet & \bullet \\ \bullet & \bullet \end{bmatrix}}$}};
%% system A
\node [snode,anchor=south,draw=FigureBlue,line width=1pt] (systemA) at ([yshift=-0.6em]C.south) {};
\node [anchor=south] (systemAfunc) at ([yshift=0.7em]C.north) {\Large{$F_{\theta,\mathbf{C}}(\cdot)$}};
\node [anchor=south] (systemAlabel) at ([yshift=0.2em]systemA.north) {\small{via language modeling}};
\node [anchor=south] (systemAlabel2) at ([yshift=-0.2em]systemAlabel.north) {\small{Optimizing $\mathbf{C}$ and $\theta$}};
\node [anchor=north] (systemAcaption) at ([yshift=-0.5em]systemA.south) {{\large Training Word Vectors}};
%% optimized embedding table
\node [cnode,anchor=west,draw=FigureCoral,line width=.9pt] (oC) at ([xshift=12em]C.east) {{\color{FigureInk} $\widehat{\mathbf{C}} = \scriptsize{\begin{bmatrix} \bullet & \bullet \\ \bullet & \bullet \\ \bullet & \bullet \end{bmatrix}}$}};
%% system B
\node [snode,anchor=south,draw=FigureTeal,line width=1pt] (systemB) at ([yshift=-0.6em]oC.south) {};
\node [anchor=south] (systemBfunc) at ([yshift=0.7em]oC.north) {\Large{$G_{\pi,\widehat{\mathbf{C}}}(\cdot)$}};
\node [anchor=south] (systemBlabel) at ([yshift=0.3em]systemB.north) {\small{on the new task}};
\node [anchor=south] (systemBlabel2) at ([yshift=-0.2em]systemBlabel.north) {\small{Using optimized $\widehat{\mathbf{C}}$}};
\node [anchor=north] (systemBcaption) at ([yshift=-0.5em]systemB.south) {{\large Applying Word Vectors}};
%% arrow
\draw [->,very thick,dotted] ([xshift=0.2em]C.east) -- ([xshift=-0.2em]oC) node [pos=0.5,above] {\scriptsize{optimized word vectors $\widehat{\mathbf{C}}$}};
\end{tikzpicture}
\begin{center}
\begin{tikzpicture}[scale=1]
\begin{axis}[
xlabel near ticks,
width=10cm, height=6cm,
xlabel={Performance},
xmin=0,xmax=10,
ymin=0,ymax=3.5,
xmajorticks=false,
ymajorticks=false,
legend style={xshift=-1em,yshift=-0.8em,legend cell align=left},
]
\addplot[color=blue,only marks,mark size=1.0pt,] table {figures/nlpbook/data/f1.dat};
\addplot[color=blue,fill=blue!50,opacity=0.5] table {figures/nlpbook/data/ff1.dat};
\addplot[color=blue,only marks,mark size=2.0pt] coordinates {(3.5,1)};
\addplot[color=blue!50] coordinates {(3.5,0.4)(3.5,1)};
\addplot[color=red,only marks,mark size=1.0pt,] table {figures/nlpbook/data/f2.dat};
\addplot[color=red,fill=red!50,opacity=0.5] table {figures/nlpbook/data/ff2.dat};
\addplot[color=red,only marks,mark size=2.0pt] coordinates {(2.5,2)};
\addplot[color=red!50] coordinates {(2.5,0.4)(2.5,2)};
\addplot[color=ugreen,only marks,mark size=1.0pt,] table {figures/nlpbook/data/f3.dat};
\addplot[color=ugreen,fill=ugreen!50,opacity=0.5] table {figures/nlpbook/data/ff3.dat};
\addplot[color=ugreen,only marks,mark size=2.0pt] coordinates {(7,3)};
\addplot[color=ugreen!50] coordinates {(7,0.4)(7,3)};
\end{axis}
\node[inner sep=0pt] (a) at (-1,1.25){system {\color{blue} A}};
\node[anchor=south,inner sep=0pt] (b) at ([yshift=2.3em]a.north){system {\color{red} B}};
\node[anchor=south,inner sep=0pt] (b) at ([yshift=2.3em]b.north){system {\color{ugreen} C}};
\end{tikzpicture}
\end{center}
\input{figures/figure-theme.tex}
\begin{center}
\begin{tikzpicture}[aml figure]
\amlfigurepalette
%----------------------------------------------------------------------------------------
% variables
\def\nodesep{1.7em}
\def\noderowsep{2.5em}
\tikzstyle{nnode} = [minimum width=1.5em,fill=FigureBlue!62,inner sep=0pt,label=above:#1,rounded corners=.8pt]
\begin{scope}
\node[nnode=0,minimum height=0.05em] (n1) at (0,0){};
\node[nnode=0,minimum height=0.05em,anchor=south] (n2) at ([xshift=\nodesep]n1.south){};
\node[nnode=1,minimum height=4.1em,anchor=south] (n3) at ([xshift=\nodesep]n2.south){};
\node[nnode=0,minimum height=0.05em,anchor=south] (n4) at ([xshift=\nodesep]n3.south){};
\node[nnode=0,minimum height=0.05em,anchor=south] (n5) at ([xshift=\nodesep]n4.south){};
\node[nnode=0,minimum height=0.05em,anchor=south] (n6) at ([xshift=\nodesep]n5.south){};
\node[nnode=0,minimum height=0.05em,anchor=south] (n7) at ([xshift=\nodesep]n6.south){};
\node[nnode=0,minimum height=0.05em,anchor=south] (n8) at ([xshift=\nodesep]n7.south){};
\node[nnode=0,minimum height=0.05em,anchor=south] (n9) at ([xshift=\nodesep]n8.south){};
\node[nnode=0,minimum height=0.05em,anchor=south] (n10) at ([xshift=\nodesep]n9.south){};
\node[anchor=east] at ([xshift=-1em,yshift=0.2em]n1.west){$p_k$};
\end{scope}
\begin{scope}[yshift=-10em]
\node[nnode=.02,minimum height=0.2em,fill=black!50] (n1) at (0,0){};
\node[nnode=.02,minimum height=0.2em,anchor=south,fill=black!50] (n2) at ([xshift=\nodesep]n1.south){};
\node[nnode,minimum height=3.1em,anchor=south] (n31) at ([xshift=\nodesep]n2.south){};
\node[nnode,minimum height=0.2em,anchor=south,fill=black!50] (n32) at ([xshift=\nodesep]n2.south){};
\node[nnode=.82,minimum height=1em,minimum width=1.45em,anchor=south,fill=white,draw=blue!40,dash pattern=on 2pt off 1pt] (n33) at ([xshift=\nodesep,yshift=3.1em]n2.south){};
\node[nnode=.02,minimum height=0.2em,anchor=south,fill=black!50] (n4) at ([xshift=\nodesep]n31.south){};
\node[nnode=.02,minimum height=0.2em,anchor=south,fill=black!50] (n5) at ([xshift=\nodesep]n4.south){};
\node[nnode=.02,minimum height=0.2em,anchor=south,fill=black!50] (n6) at ([xshift=\nodesep]n5.south){};
\node[nnode=.02,minimum height=0.2em,anchor=south,fill=black!50] (n7) at ([xshift=\nodesep]n6.south){};
\node[nnode=.02,minimum height=0.2em,anchor=south,fill=black!50] (n8) at ([xshift=\nodesep]n7.south){};
\node[nnode=.02,minimum height=0.2em,anchor=south,fill=black!50] (n9) at ([xshift=\nodesep]n8.south){};
\node[nnode=.02,minimum height=0.2em,anchor=south,fill=black!50] (n10) at ([xshift=\nodesep]n9.south){};
\node[anchor=east] at ([xshift=-1em,yshift=0.2em]n1.west){$\hat{p}_k(\epsilon=0.2)$};
\node[inner sep=0pt,anchor=west] (eps) at ([xshift=2em,yshift=1em]n33.east){$\epsilon$};
\node[inner sep=0pt,anchor=west] (arrow) at ([xshift=0.2em]eps.east){$\to$};
\node[minimum width=1.5em, minimum height=0.2em, inner sep=0pt,fill=black!50,anchor=west] (n1) at ([xshift=0.5em,]arrow.east) {};
\node[minimum width=1.2em, minimum height=0.2em, inner sep=0pt,anchor=west] (n2) at ([xshift=0.5em]n1.east) {...};
\node[minimum width=1.5em, minimum height=0.2em, inner sep=0pt,fill=black!50,anchor=west] (n3) at ([xshift=0.5em]n2.east) {};
\draw[decorate,decoration={brace,amplitude=3mm}] ([yshift=0.1em]n1.north west) -- node[yshift=1.5em] {$\frac{\epsilon}{n} \times n$}([yshift=0.1em]n3.north east);
\begin{pgfonlayer}{background}
\node [draw=FigureGold!80!FigureInk,inner sep=6pt,fill=FigureWarm,line width=.7pt,rounded corners=2pt,minimum height=3em,yshift=1em] [fit = (eps) (n3)] (box) {};
\end{pgfonlayer}
\draw [->, thick,dotted] (n33.center) .. controls +(east:2em) and +(west:1.5em) .. ([xshift=-0.1em]box.west);
\draw [->, thick,dotted] ([yshift=-0.1em]n3.south) .. controls +(south:2em) and +(north:2em) .. ([yshift=1.2em]n10.north);
\end{scope}
\end{tikzpicture}
\end{center}
\input{figures/figure-theme.tex}
\begin{center}
\begin{tikzpicture}[aml figure,scale=1]
\amlfigurepalette
\pgfmathsetseed{10}
\begin{scope}
\node [anchor=south west,minimum height=1em,minimum width=1em,inner sep=0.1pt] (n1) at (0,0) {};
\end{scope}
\begin{scope}[xshift=0cm]
\begin{axis}[
aml axis,
width=5.1cm, height=5.1cm,
title={Underfitting},
xlabel={$x_1$},
ylabel={$x_2$},
y label style={at={(axis description cs:0.25,.5)},anchor=south},
xmin=0, xmax=8,
ymin=0, ymax=8,
xtick={0,2,4,6,8},
ytick={0,2,4,6,8},
]
\addplot[only marks,color=blue,very thick, mark=square,samples=12, domain=0.5:7.5,]{(0.5*x+3+rand};
\addplot[only marks,color=red, very thick, mark=x,samples=12, domain=0.5:7.5, mark size=4pt]{(0.5*x+0.6+rand};
\addplot[only marks,color=blue,very thick, mark=square,samples=12, domain=1:7]{(0.5*x+5+rand};
\addplot[only marks,color=red, very thick, mark=x,samples=12, domain=1:7, mark size=4pt]{(0.5*x-1.4+rand};
\addplot[color=red, very thick, mark=x,mark size=4pt,draw=none] coordinates {(1.3,1.9)(1.4,3.4)(4.8,5.6)(7.4,5)};
\addplot[color=blue, very thick, mark=square] coordinates {(3.4,2.4)};
\addplot[color=black, very thick, smooth] coordinates {(0,1.4)(3,1.8)(6,3)(8,7)};
\end{axis}
\end{scope}
\begin{scope}[xshift=4.8cm]
\pgfmathsetseed{10}
\begin{axis}[
aml axis,
width=5.1cm, height=5.1cm,
title={Fitting just right},
xlabel={$x_1$},
ylabel={$x_2$},
y label style={at={(axis description cs:0.25,.5)},anchor=south},
xmin=0, xmax=8,
ymin=0, ymax=8,
xtick={0,2,4,6,8},
ytick={0,2,4,6,8},
]
\addplot[only marks,color=blue, very thick, mark=square,samples=12, domain=0.5:7.5,]{(0.5*x+3+rand};
\addplot[only marks,color=red, very thick, mark=x,samples=12, domain=0.5:7.5, mark size=4pt]{(0.5*x+0.6+rand};
\addplot[only marks,color=blue,very thick, mark=square,samples=12, domain=1:7,]{(0.5*x+5+rand};
\addplot[only marks,color=red, very thick, mark=x,samples=12, domain=1:7, mark size=4pt]{(0.5*x-1.4+rand};
\addplot[color=red, very thick, mark=x,mark size=4pt,draw=none] coordinates {(1.3,1.9)(1.4,3.4)(4.8,5.6)(7.4,5)};
\addplot[color=blue, very thick, mark=square] coordinates {(3.4,2.4)};
\addplot[color=black, very thick, smooth] coordinates {(0,2.5)(3,3)(5,3.9)(8,6.2)};
\end{axis}
\end{scope}
\begin{scope}[xshift=9.6cm]
\pgfmathsetseed{10}
\begin{axis}[
aml axis,
width=5.1cm, height=5.1cm,
title={Overfitting},
xlabel={$x_1$},
ylabel={$x_2$},
y label style={at={(axis description cs:0.25,.5)},anchor=south},
xmin=0, xmax=8,
ymin=0, ymax=8,
xtick={0,2,4,6,8},
ytick={0,2,4,6,8},
]
\addplot[only marks,color=blue,very thick, mark=square,samples=12, domain=0.5:7.5,]{(0.5*x+3+rand};
\addplot[only marks,color=red, very thick, mark=x,samples=12, domain=0.5:7.5, mark size=4pt]{(0.5*x+0.6+rand};
\addplot[only marks,color=blue,very thick, mark=square,samples=12, domain=1:7,, ]{(0.5*x+5+rand};
\addplot[only marks,color=red, very thick, mark=x,samples=12, domain=1:7, mark size=4pt]{(0.5*x-1.4+rand};
\addplot[color=red, very thick, mark=x,mark size=4pt,draw=none] coordinates {(1.3,1.9)(1.4,3.4)(4.8,5.6)(7.4,5)};
\addplot[color=blue, very thick, mark=square, ] coordinates {(3.4,2.4)};
\addplot[color=black, very thick, smooth] coordinates {(0,1.4)(0.8,1.8)(1,3.8)(1.6,4)(3,2)(3.8,2.2)(4,3)(5,3.6)(5.6,4.8)(4.2,5.4)(4.4,6)(5,6)(6,5.2)(7,5.6)(8,6.4)};
\end{axis}
\end{scope}
\end{tikzpicture}
\end{center}
% !Mode:: "TeX:UTF-8"
% !TEX encoding = UTF-8 Unicode
\input{figures/figure-theme.tex}
\begin{tikzpicture}[aml figure]
\amlfigurepalette
\def\nodewidth{1.8cm}
\def\nodeheight{0.8cm}
\tikzstyle{enode} = [minimum width=\nodewidth,minimum height=\nodeheight,inner sep=1pt,draw=FigureInk!65,line width=.7pt,rounded corners=2pt,fill=FigureMist]
%%% unsupervised pre-training
\begin{scope}
\node [enode,anchor=west,very thick] (unsupervisednode1) at (0,0) {\scriptsize{Unsupervised}};
\node [enode,anchor=west,very thick] (unsupervisednode2) at ([xshift=0.3cm]unsupervisednode1.east) {\footnotesize{Supervised}};
\draw [->,thick] ([xshift=1pt]unsupervisednode1.east) -- ([xshift=-1pt]unsupervisednode2.west);
\node [anchor=south] (node1label) at (unsupervisednode1.north) {\footnotesize{Pre-training}};
\node [anchor=south] (node2label) at (unsupervisednode2.north) {\footnotesize{Training}};
\node [enode,anchor=north,minimum height=3.5*\nodeheight,rounded corners=3pt,fill=red!30,align=left] (unsuperviseddata1) at ([yshift=-0.2em]unsupervisednode1.south) {};
\node [anchor=north] (unsuperviseddata1cap1) at ([yshift=-3pt]unsuperviseddata1.north) {\footnotesize{Unlabeled}};
\node [anchor=north west] (unsuperviseddata1cap2) at ([yshift=2pt]unsuperviseddata1cap1.south west) {\footnotesize{Data}};
\node [enode,anchor=north,minimum height=1.6*\nodeheight,rounded corners=3pt,fill=ugreen!30,align=left] (unsuperviseddata2) at ([yshift=-0.2em]unsupervisednode2.south) {};
\node [anchor=north] (unsuperviseddata2cap1) at ([yshift=-3pt]unsuperviseddata2.north) {\footnotesize{Labeled}};
\node [anchor=north west] (unsuperviseddata2cap2) at ([yshift=2pt]unsuperviseddata2cap1.south west) {\footnotesize{Data}};
\node [anchor=north] (caption) at ([xshift=0.2cm,yshift=-3.2cm]unsupervisednode1.south east) {\footnotesize{(a) Unsupervised Pre-training}};
\end{scope}
%%% supervised pre-training
\begin{scope}[xshift=4.7cm]
\node [enode,anchor=west,very thick] (supervisednode1) at (0,0) {\footnotesize{Supervised}};
\node [enode,anchor=west,very thick] (supervisednode2) at ([xshift=0.3cm]supervisednode1.east) {\footnotesize{Supervised}};
\draw [->,thick] ([xshift=1pt]supervisednode1.east) -- ([xshift=-1pt]supervisednode2.west);
\node [anchor=south] (node1label) at (supervisednode1.north) {\footnotesize{Pre-training}};
\node [anchor=south] (node2label) at (supervisednode2.north) {\footnotesize{Tuning}};
\node [enode,anchor=north,minimum height=2.0*\nodeheight,rounded corners=3pt,fill=blue!30,align=left] (superviseddata1) at ([yshift=-0.2em]supervisednode1.south) {};
\node [anchor=north] (superviseddata1cap1) at ([yshift=-3pt]superviseddata1.north) {\footnotesize{Labeled}};
\node [anchor=north west] (superviseddata1cap2) at ([yshift=2pt]superviseddata1cap1.south west) {\footnotesize{Data}};
\node [anchor=north] (task1) at (superviseddata1.south) {\scriptsize{Task 1}};
\node [enode,anchor=north,minimum height=1.3*\nodeheight,rounded corners=3pt,fill=ugreen!30,align=left] (superviseddata2) at ([yshift=-0.2em]supervisednode2.south) {};
\node [anchor=north] (superviseddata2cap1) at ([yshift=-3pt]superviseddata2.north) {\footnotesize{Labeled}};
\node [anchor=north west] (superviseddata2cap2) at ([yshift=2pt]superviseddata2cap1.south west) {\footnotesize{Data}};
\node [anchor=north] (task2) at (superviseddata2.south) {\scriptsize{Task 2}};
\node [anchor=north] (caption) at ([xshift=0.2cm,yshift=-3.2cm]supervisednode1.south east) {\footnotesize{(b) Supervised Pre-training}};
\end{scope}
%%% self-supervised pre-training
\begin{scope}[xshift=9.4cm]
\node [enode,anchor=west,very thick] (unsupervisednode1) at (0,0) {};
\node [anchor=north west] (tlabel) at (unsupervisednode1.north west) {\footnotesize{Self-}};
\node [anchor=north west] (tlabel2) at ([yshift=4pt]tlabel.south west) {\footnotesize{Supervised}};
\node [enode,anchor=west,very thick] (unsupervisednode2) at ([xshift=0.3cm]unsupervisednode1.east) {\footnotesize{Supervised}};
\node [enode,anchor=south,very thick] (tuningnode) at ([yshift=0.7cm]unsupervisednode2.north) {};
\node [anchor=north west] (tprompt) at (tuningnode.north west) {\footnotesize{Zero/Few}};
\node [anchor=north west] (tprompt2) at ([yshift=4pt]tprompt.south west) {\scriptsize{Shot Learning}};
\draw [->,thick,dashed] ([xshift=1pt]unsupervisednode1.east) -- ([xshift=-1pt]unsupervisednode2.west);
\draw [->,thick,dashed] ([xshift=1pt,yshift=0.5em]unsupervisednode1.east) .. controls +(east:0.3cm) and +(west:0.3cm) .. ([xshift=-1pt]tuningnode.west);
\node [anchor=south] (node1label) at (unsupervisednode1.north) {\footnotesize{Pre-training}};
\node [anchor=south] (node2label) at (unsupervisednode2.north) {\footnotesize{Tuning}};
\node [anchor=south] (tuningnodelabel) at (tuningnode.north) {\footnotesize{Prompting}};
\node [enode,anchor=north,minimum height=3.5*\nodeheight,rounded corners=3pt,fill=red!30,align=left] (unsuperviseddata1) at ([yshift=-0.2em]unsupervisednode1.south) {};
\node [anchor=north] (unsuperviseddata1cap1) at ([yshift=-3pt]unsuperviseddata1.north) {\footnotesize{Unlabeled}};
\node [anchor=north west] (unsuperviseddata1cap2) at ([yshift=2pt]unsuperviseddata1cap1.south west) {\footnotesize{Data}};
\node [enode,anchor=north,minimum height=1.3*\nodeheight,rounded corners=3pt,fill=ugreen!30,align=left] (unsuperviseddata2) at ([yshift=-0.2em]unsupervisednode2.south) {};
\node [anchor=north] (unsuperviseddata2cap1) at ([yshift=-3pt]unsuperviseddata2.north) {\footnotesize{Labeled}};
\node [anchor=north west] (unsuperviseddata2cap2) at ([yshift=2pt]unsuperviseddata2cap1.south west) {\footnotesize{Data}};
\node [anchor=north] (caption) at ([xshift=0.2cm,yshift=-3.2cm]unsupervisednode1.south east) {\footnotesize{(c) Self-supervised Pre-training}};
\end{scope}
\end{tikzpicture}
\input{figures/figure-theme.tex}
\begin{center}
\begin{tikzpicture}[aml figure]
\amlfigurepalette
%----------------------------------------------------------------------------------------
% variables
\def\nodesep{2.5em}
\def\noderowsep{2.5em}
\tikzstyle{nnode} = [circle,minimum size=1.8em,draw=FigureInk!70,line width=.7pt,fill=FigureMist]
%----------------------------------------------------------------------------------------
% dropout training
\begin{scope}
% layer 1
\node [anchor=center,nnode,draw=black] (node11) at (0,0) {};
\node [anchor=west,nnode,draw=gray!50] (node12) at ([xshift=\nodesep]node11.east) {};
\node [anchor=west,nnode,draw=black] (node13) at ([xshift=\nodesep]node12.east) {};
% layer 2
\node [anchor=south,nnode,draw=black] (node21) at ([yshift=\noderowsep]node11.north) {};
\node [anchor=west,nnode,draw=black] (node22) at ([xshift=\nodesep]node21.east) {};
\node [anchor=west,nnode,draw=gray!50] (node23) at ([xshift=\nodesep]node22.east) {};
% layer 3
\node [anchor=south,nnode,draw=black] (node31) at ([yshift=\noderowsep]node21.north) {};
\node [anchor=west,nnode,draw=gray!50] (node32) at ([xshift=\nodesep]node31.east) {};
\node [anchor=west,nnode,draw=black] (node33) at ([xshift=\nodesep]node32.east) {};
% connections (layer 1 -> layer 2)
\draw [->,thick] ([yshift=2pt]node11.90) -- ([yshift=-2pt]node21.-90);
\draw [->,thick] ([yshift=2pt]node11.75) -- ([yshift=-2pt]node22.-110);
\draw [->,thick,dotted,gray!50] ([yshift=2pt]node11.60) -- ([yshift=-2pt]node23.-130);
\draw [->,thick,dotted,gray!50] ([yshift=2pt]node12.105) -- ([yshift=-2pt]node21.-75);
\draw [->,thick,dotted,gray!50] ([yshift=2pt]node12.90) -- ([yshift=-2pt]node22.-90);
\draw [->,thick,dotted,gray!50] ([yshift=2pt]node12.75) -- ([yshift=-2pt]node23.-105);
\draw [->,thick] ([yshift=2pt]node13.120) -- ([yshift=-2pt]node21.-50);
\draw [->,very thick,blue] ([yshift=2pt]node13.105) -- ([yshift=-2pt]node22.-70);
\draw [->,thick,dotted,gray!50] ([yshift=2pt]node13.90) -- ([yshift=-2pt]node23.-90);
% connections (layer 2 -> layer 3)
\draw [->,thick] ([yshift=2pt]node21.90) -- ([yshift=-2pt]node31.-90);
\draw [->,thick,dotted,gray!50] ([yshift=2pt]node21.75) -- ([yshift=-2pt]node32.-110);
\draw [->,thick] ([yshift=2pt]node21.60) -- ([yshift=-2pt]node33.-130);
\draw [->,thick] ([yshift=2pt]node22.105) -- ([yshift=-2pt]node31.-75);
\draw [->,thick,dotted,gray!50] ([yshift=2pt]node22.90) -- ([yshift=-2pt]node32.-90);
\draw [->,thick] ([yshift=2pt]node22.75) -- ([yshift=-2pt]node33.-105);
\draw [->,thick,dotted,gray!50] ([yshift=2pt]node23.120) -- ([yshift=-2pt]node31.-50);
\draw [->,thick,dotted,gray!50] ([yshift=2pt]node23.105) -- ([yshift=-2pt]node32.-70);
\draw [->,thick,dotted,gray!50] ([yshift=2pt]node23.90) -- ([yshift=-2pt]node33.-90);
% labels
\node [anchor=south west,align=center] (pnodelabel) at ([yshift=1em,xshift=0.0em]node33.north east) {\small{{\color{blue} active neuron}}\\[-3pt]\small{{\color{blue} (present with $\rho$)}}};
\draw [->] ([xshift=2em,yshift=2pt]pnodelabel.south west) .. controls +(south:1.2em) and +(north:1.2em) .. ([xshift=0.3em,yshift=0.3em]node33.center);
\node [anchor=south west,align=center] (dnodelabel) at ([yshift=1em,xshift=0.0em]node23.north east) {\small{{\color{blue} dropped neuron}}};
\draw [->] ([xshift=2em,yshift=2pt]dnodelabel.south west) .. controls +(south:1.2em) and +(north:1.2em) .. ([xshift=0.3em,yshift=0.3em]node23.center);
\node [anchor=south,align=center,fill=white,inner sep =0pt] (wlabel) at ([yshift=0.5em,xshift=1.8em]node13.north) {\small{{\color{blue} weight $W_{32}$}}};
\node [anchor=north] (name) at ([yshift=-0.5em,xshift=2em]node12.south) {\small (a) Training the dropout network};
\end{scope}
%----------------------------------------------------------------------------------------
% dropout test
\begin{scope}[xshift=19em]
% layer 1
\node [anchor=center,nnode,draw=black] (node11) at (0,0) {};
\node [anchor=west,nnode,draw=black] (node12) at ([xshift=\nodesep]node11.east) {};
\node [anchor=west,nnode,draw=black] (node13) at ([xshift=\nodesep]node12.east) {};
% layer 2
\node [anchor=south,nnode,draw=black] (node21) at ([yshift=\noderowsep]node11.north) {};
\node [anchor=west,nnode,draw=black] (node22) at ([xshift=\nodesep]node21.east) {};
\node [anchor=west,nnode,draw=black] (node23) at ([xshift=\nodesep]node22.east) {};
% layer 3
\node [anchor=south,nnode,draw=black] (node31) at ([yshift=\noderowsep]node21.north) {};
\node [anchor=west,nnode,draw=black] (node32) at ([xshift=\nodesep]node31.east) {};
\node [anchor=west,nnode,draw=black] (node33) at ([xshift=\nodesep]node32.east) {};
% connections (layer 1 -> layer 2)
\draw [->,thick] ([yshift=2pt]node11.90) -- ([yshift=-2pt]node21.-90);
\draw [->,thick] ([yshift=2pt]node11.75) -- ([yshift=-2pt]node22.-110);
\draw [->,thick] ([yshift=2pt]node11.60) -- ([yshift=-2pt]node23.-130);
\draw [->,thick] ([yshift=2pt]node12.105) -- ([yshift=-2pt]node21.-75);
\draw [->,thick] ([yshift=2pt]node12.90) -- ([yshift=-2pt]node22.-90);
\draw [->,thick] ([yshift=2pt]node12.75) -- ([yshift=-2pt]node23.-105);
\draw [->,thick] ([yshift=2pt]node13.120) -- ([yshift=-2pt]node21.-50);
\draw [->,very thick,blue] ([yshift=2pt]node13.105) -- ([yshift=-2pt]node22.-70);
\draw [->,thick] ([yshift=2pt]node13.90) -- ([yshift=-2pt]node23.-90);
% connections (layer 2 -> layer 3)
\draw [->,thick] ([yshift=2pt]node21.90) -- ([yshift=-2pt]node31.-90);
\draw [->,thick] ([yshift=2pt]node21.75) -- ([yshift=-2pt]node32.-110);
\draw [->,thick] ([yshift=2pt]node21.60) -- ([yshift=-2pt]node33.-130);
\draw [->,thick] ([yshift=2pt]node22.105) -- ([yshift=-2pt]node31.-75);
\draw [->,thick] ([yshift=2pt]node22.90) -- ([yshift=-2pt]node32.-90);
\draw [->,thick] ([yshift=2pt]node22.75) -- ([yshift=-2pt]node33.-105);
\draw [->,thick] ([yshift=2pt]node23.120) -- ([yshift=-2pt]node31.-50);
\draw [->,thick] ([yshift=2pt]node23.105) -- ([yshift=-2pt]node32.-70);
\draw [->,thick] ([yshift=2pt]node23.90) -- ([yshift=-2pt]node33.-90);
% labels
\node [anchor=south west,align=left] (pnodelabel) at ([yshift=1em,xshift=0.0em]node33.north east) {\small{{\color{blue} all neurons}}\\[-3pt]\small{{\color{blue} are active}}};
\draw [->] ([xshift=2em,yshift=2pt]pnodelabel.south west) .. controls +(south:1.2em) and +(north:1.2em) .. ([xshift=0.3em,yshift=0.3em]node33.center);
\node [anchor=south,align=center,fill=white,inner sep =0pt] (wlabel) at ([yshift=0.5em,xshift=1.8em]node13.north) {\small{{\color{blue} weight $\rho W_{32}$}}};
\node [anchor=north] (name) at ([yshift=-0.5em,xshift=2em]node12.south) {\small (b) Testing with the dropout network};
\end{scope}
\end{tikzpicture}
\end{center}
\input{figures/figure-theme.tex}
\begin{center}
\begin{tikzpicture}[aml figure]
\amlfigurepalette
%----------------------------------------------------------------------------------------
% variables
\def\nodesep{2.5em}
\def\noderowsep{5em}
\tikzstyle{nnode} = [rectangle,minimum size=2em,inner sep=0,draw=FigureInk!70,line width=.7pt,rounded corners=2pt]
\tikzstyle{dnode} = [circle,minimum size=2em,inner sep=0,draw=FigureInk!70,line width=.7pt]
\tikzstyle{lnode} = [circle,minimum size=0.5em,inner sep=1pt,fill=blue]
%----------------------------------------------------------------------------------------
% forward pass
\begin{scope}[every path/.append style={draw=FigureBlue}]
% nodes
\node [anchor=center,nnode,fill=white] (node7) at (0,0) {$\mathbf{x}$};
\node [anchor=west,nnode,fill=white] (node8) at ([xshift=\nodesep]node7.east) {$\mathbf{w}_1$};
\node [anchor=south,nnode,fill=white] (node5) at ([xshift= 0.5*\nodesep,yshift=\noderowsep]node7.east) {$\cdot$};
\node [anchor=west,nnode,fill=white] (node6) at ([xshift=\nodesep]node5.east) {$\mathbf{b}_1$};
\node [anchor=south,nnode,fill=white] (node4) at ([xshift= 0.5*\nodesep,yshift=\noderowsep]node5.east) {$+$};
\node [anchor=south,nnode,fill=white] (node2) at ([yshift=\noderowsep]node4.north) {$\psi(\cdot)$};
\node [anchor=west,nnode,fill=white] (node3) at ([xshift=\nodesep]node2.east) {$\mathbf{w}_2$};
\node [anchor=south,nnode,fill=white] (node1) at ([xshift= 0.5*\nodesep,yshift=\noderowsep]node2.east) {$\cdot$};
\node [anchor=south] (nodeoutput) at ([yshift=0.5*\noderowsep]node1.north) {\footnotesize{$\mathbf{y}$ (Output)}};
\foreach \x in {1,...,8}{
\node [anchor=center,lnode] (label\x) at ([xshift=2pt,yshift=-2pt]node\x.north west) {\tiny{\color{white} $\x$}};
}
\node [anchor=east] (node5math) at (node5.west) {\small{$\mathbf{h}_3 = \mathbf{x} \cdot \mathbf{w}_1$}};
\node [anchor=east] (node4math) at (node4.west) {\small{$\mathbf{h}_2 = \mathbf{h}_3 + \mathbf{b}_1$}};
\node [anchor=east] (node2math) at (node2.west) {\small{$\mathbf{h}_1 = \psi(\mathbf{h}_2)$}};
\node [anchor=east] (node1math) at (node1.west) {\small{$\mathbf{y} = \mathbf{h}_1 \cdot \mathbf{w}_2$}};
% connections
\draw [->,very thick] ([yshift=2pt]node7.north) -- ([yshift=-2pt,xshift=-0.3em]node5.south);
\draw [->,very thick] ([yshift=2pt]node8.north) -- ([yshift=-2pt,xshift=+0.3em]node5.south);
\draw [->,very thick] ([yshift=2pt]node5.north) -- ([yshift=-2pt,xshift=-0.3em]node4.south);
\draw [->,very thick] ([yshift=2pt]node6.north) -- ([yshift=-2pt,xshift=+0.3em]node4.south);
\draw [->,very thick] ([yshift=2pt]node4.north) -- ([yshift=-2pt,xshift=+0.0em]node2.south);
\draw [->,very thick] ([yshift=2pt]node2.north) -- ([yshift=-2pt,xshift=-0.3em]node1.south);
\draw [->,very thick] ([yshift=2pt]node3.north) -- ([yshift=-2pt,xshift=+0.3em]node1.south);
\draw [->,very thick] ([yshift=2pt]node1.north) -- ([yshift=-0pt,xshift=+0.0em]nodeoutput.south);
% label
\node [anchor=east,lnode] (labelsmall1) at ([xshift=-8em]nodeoutput.west) {\tiny{\color{white} $1$}};
\node [anchor=north,lnode] (labelsmall2) at ([yshift=-2.0em]labelsmall1.south) {\tiny{\color{white} $8$}};
\draw [->,thick] ([yshift=1pt]labelsmall2.north) -- ([yshift=-1pt]labelsmall1.south);
\node [anchor=north] (subfigurelabel) at ([yshift=-1em]node8.south) {(a) Forward Pass};
\end{scope}
%----------------------------------------------------------------------------------------
% backward pass
\begin{scope}[xshift=20em,every path/.append style={draw=FigureCoral}]
% nodes
\node [anchor=center,nnode,fill=white] (node7) at (0,0) {$\mathbf{x}$};
\node [anchor=west,nnode,fill=white] (node8) at ([xshift=\nodesep]node7.east) {$\mathbf{w}_1$};
\node [anchor=south,nnode,fill=white] (node5) at ([xshift= 0.5*\nodesep,yshift=\noderowsep]node7.east) {$\cdot$};
\node [anchor=west,nnode,fill=white] (node6) at ([xshift=\nodesep]node5.east) {$\mathbf{b}_1$};
\node [anchor=south,nnode,fill=white] (node4) at ([xshift= 0.5*\nodesep,yshift=\noderowsep]node5.east) {$+$};
\node [anchor=south,nnode,fill=white] (node2) at ([yshift=\noderowsep]node4.north) {$\psi(\cdot)$};
\node [anchor=west,nnode,fill=white] (node3) at ([xshift=\nodesep]node2.east) {$\mathbf{w}_2$};
\node [anchor=south,nnode,fill=white] (node1) at ([xshift= 0.5*\nodesep,yshift=\noderowsep]node2.east) {$\cdot$};
\node [anchor=south] (nodeoutput) at ([yshift=0.5*\noderowsep]node1.north) {\footnotesize{Loss $L$}};
\foreach \x in {1,...,8}{
\node [anchor=center,lnode,fill=red] (label\x) at ([xshift=2pt,yshift=-2pt]node\x.north west) {\tiny{\color{white} $\x$}};
}
\node [anchor=east] (node5math) at (node5.west) {\small{$\mathbf{h}_3 = \mathbf{x} \cdot \mathbf{w}_1$}};
\node [anchor=east] (node4math) at (node4.west) {\small{$\mathbf{h}_2 = \mathbf{h}_3 + \mathbf{b}_1$}};
\node [anchor=east] (node2math) at (node2.west) {\small{$\mathbf{h}_1 = \psi(\mathbf{h}_2)$}};
\node [anchor=east] (node1math) at (node1.west) {\small{$\mathbf{y} = \mathbf{h}_1 \cdot \mathbf{w}_2$}};
% connections
\draw [<-,very thick] ([yshift=2pt]node7.north) -- ([yshift=-2pt,xshift=-0.3em]node5.south) node [pos=0.5,inner sep=2pt,fill=white,xshift=-2em] (g7) {\scriptsize{{\color{red} $\frac{\partial L}{\partial \mathbf{x}} = \frac{\partial L}{\partial \mathbf{h}_3} \cdot \mathbf{w}_1^{\rm{T}}$}}};
\draw [<-,very thick] ([yshift=2pt]node8.north) -- ([yshift=-2pt,xshift=+0.3em]node5.south) node [pos=0.5,inner sep=2pt,fill=white,xshift=2em] (g8) {\scriptsize{{\color{red} $\frac{\partial L}{\partial \mathbf{w}_1} = \mathbf{x}^{\rm{T}} \cdot \frac{\partial L}{\partial \mathbf{h}_3}$}}};
\draw [<-,very thick] ([yshift=2pt]node5.north) -- ([yshift=-2pt,xshift=-0.3em]node4.south) node [pos=0.5,inner sep=2pt,fill=white,xshift=-1em] (g5) {\scriptsize{{\color{red} $\frac{\partial L}{\partial \mathbf{h}_3} = \frac{\partial L}{\partial \mathbf{h}_2}$}}};
\draw [<-,very thick] ([yshift=2pt]node6.north) -- ([yshift=-2pt,xshift=+0.3em]node4.south) node [pos=0.5,inner sep=2pt,fill=white,xshift=1em] (g6) {\scriptsize{{\color{red} $\frac{\partial L}{\partial \mathbf{b}_1} = \frac{\partial L}{\partial \mathbf{h}_2}$}}};
\draw [<-,very thick] ([yshift=2pt]node4.north) -- ([yshift=-2pt,xshift=+0.0em]node2.south) node [pos=0.5,inner sep=2pt,fill=white,xshift=0em] (g4) {\scriptsize{{\color{red} $\frac{\partial L}{\partial \mathbf{h}_2} = \frac{\partial L}{\partial \mathbf{h}_1} \odot \psi'(\mathbf{h}_2)$}}};
\draw [<-,very thick] ([yshift=2pt]node2.north) -- ([yshift=-2pt,xshift=-0.3em]node1.south) node [pos=0.5,inner sep=2pt,fill=white,xshift=-2em] (g2) {\scriptsize{{\color{red} $\frac{\partial L}{\partial \mathbf{h}_1} = \frac{\partial L}{\partial \mathbf{y}} \cdot \mathbf{w}_2^{\rm{T}}$}}};
\draw [<-,very thick] ([yshift=2pt]node3.north) -- ([yshift=-2pt,xshift=+0.3em]node1.south) node [pos=0.5,inner sep=2pt,fill=white,xshift=2em] (g3) {\scriptsize{{\color{red} $\frac{\partial L}{\partial \mathbf{w}_2} = \mathbf{h}_1^{\rm{T}} \cdot \frac{\partial L}{\partial \mathbf{y}}$}}};
\draw [<-,very thick] ([yshift=2pt]node1.north) -- ([yshift=-0pt,xshift=+0.0em]nodeoutput.south) node [pos=0.5,inner sep=2pt,fill=white] (g5) {\scriptsize{{\color{red} $\frac{\partial L}{\partial \mathbf{y}}$}}};
% label
\node [anchor=east,lnode,fill=red] (labelsmall1) at ([xshift=-8em]nodeoutput.west) {\tiny{\color{white} $1$}};
\node [anchor=north,lnode,fill=red] (labelsmall2) at ([yshift=-2.0em]labelsmall1.south) {\tiny{\color{white} $8$}};
\draw [<-,thick] ([yshift=1pt]labelsmall2.north) -- ([yshift=-1pt]labelsmall1.south);
\node [anchor=north] (subfigurelabel) at ([yshift=-1em]node8.south) {(b) Backward Pass};
\end{scope}
\end{tikzpicture}
\end{center}
# 中文课程讲义 LaTeX 模板
主文件是 `aml_notes.tex`,建议使用 XeLaTeX 编译:
```powershell
xelatex aml_notes.tex
xelatex aml_notes.tex
```
第二次编译用于生成完整目录和交叉引用。图片可以放在 `figures/``images/` 目录中,然后用 `\includegraphics` 插入。
常用修改位置:
- 课程信息:修改 `\coursename``\semester``\teacher``\school`
- 新增章节:使用 `\chapter{章节标题}`
- 新增小节:使用 `\section{小节标题}``\subsection{小节标题}`
- 插入表格:参考模板中的 `table``longtable` 示例。
- 插入图片:把图片放入 `figures/`,参考模板中的 `figure` 示例。
如果使用 Overleaf,也请选择 XeLaTeX 作为编译器。
把课程讲义中需要使用的图片放在这个目录中。
示例:
- `cover.jpg`:封面图片,模板会自动读取。
- `example.png`:正文图片示例,模板会自动读取。
\begin{tikzpicture}[
font=\small,
box/.style={
draw=black,
rounded corners=4pt,
minimum width=2.8cm,
minimum height=1.15cm,
align=center,
line width=0.8pt
},
statebox/.style={
box,
fill=yellow!12,
minimum width=2.6cm
},
actorbox/.style={
box,
fill=blue!10,
minimum width=3.5cm,
minimum height=1.55cm
},
criticbox/.style={
box,
fill=green!12,
minimum width=3.5cm,
minimum height=1.55cm
},
envbox/.style={
box,
fill=orange!12,
minimum width=3.0cm,
minimum height=1.2cm
},
tdbox/.style={
box,
fill=gray!10,
minimum width=6.8cm,
minimum height=1.35cm
},
note/.style={
draw=black,
rounded corners=4pt,
fill=gray!5,
minimum width=5.0cm,
minimum height=0.95cm,
align=center,
line width=0.8pt
},
flow/.style={
draw=black,
-Latex,
line width=0.8pt
},
dashedflow/.style={
draw=black!75,
-Latex,
dashed,
line width=0.75pt
}
]
% =========================
% Nodes
% =========================
\node[statebox] (state) at (0,1.8) {当前棋盘状态\\$s_t$};
\node[actorbox] (actor) at (4.2,3.1) {Actor\\策略网络\\$\pi_{\theta}(a_t\mid s_t)$};
\node[criticbox] (critic) at (10.8,3.1) {Critic\\价值网络\\$V_{\phi}(s)$};
\node[envbox] (env) at (7.5,0.9) {五子棋环境};
\node[tdbox] (td) at (7.5,-2.0) {时序差分误差\\[0.08cm]
$\delta_t=r_t+\gamma V_{\phi}(s_{t+1})-V_{\phi}(s_t)$};
\node[note] (note1) at (4.2,5.1) {Actor 负责根据状态选择动作};
\node[note] (note2) at (10.8,5.1) {Critic 负责估计状态价值并评价动作};
% =========================
% Arrows: state input
% =========================
\draw[flow] (state.east) -- (actor.west);
\node at (2.0,2.15) {$s_t$};
\draw[flow]
(state.east)
.. controls (2.2,1.2) and (7.9,1.3)
.. (critic.west);
\node at (5.4,1.25) {$s_t$};
% =========================
% Action and environment
% =========================
\draw[flow] (actor.south east) -- (env.north west);
\node at (5.55,2.05) {动作 $a_t$};
\draw[flow] (env.north east) -- (critic.south west);
\node[align=center] at (9.45,2.0) {奖励 $r_t$\\下一状态 $s_{t+1}$};
% =========================
% TD error construction
% =========================
\draw[flow] (env.south) -- (td.north);
\node at (7.0,-0.45) {$r_t$};
\draw[flow] (critic.south) -- (td.north east);
\node[align=center] at (10.9,-0.2) {$V_{\phi}(s_t)$\\$V_{\phi}(s_{t+1})$};
% =========================
% Updates from TD error
% =========================
\draw[dashedflow]
(td.north west)
.. controls (5.4,-0.8) and (4.0,0.9)
.. (actor.south);
\node[align=center] at (4.3,-0.6) {策略更新\\Actor};
\draw[dashedflow]
(td.north east)
.. controls (9.8,-0.8) and (11.0,0.9)
.. (critic.south);
\node[align=center] at (10.8,-0.7) {价值更新\\Critic};
% =========================
% Optional environment loop
% =========================
\draw[dashedflow]
(env.west)
.. controls (5.2,0.1) and (1.8,0.1)
.. (state.south);
\node[align=center] at (3.2,0.35) {\footnotesize 下一状态用于下一轮决策};
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}[
font=\small,
box/.style={
draw=black,
rounded corners=4pt,
minimum width=2.8cm,
minimum height=1.0cm,
align=center,
line width=0.8pt
},
statebox/.style={
box,
fill=yellow!12,
minimum width=3.2cm,
minimum height=2.2cm
},
actorbox/.style={
box,
fill=blue!10,
minimum width=4.0cm,
minimum height=2.1cm
},
criticbox/.style={
box,
fill=green!12,
minimum width=4.2cm,
minimum height=2.1cm
},
tdbox/.style={
box,
fill=gray!10,
minimum width=6.2cm,
minimum height=1.8cm
},
note/.style={
draw=black,
rounded corners=4pt,
fill=gray!5,
minimum width=3.8cm,
minimum height=0.95cm,
align=center,
line width=0.8pt
},
flow/.style={
draw=black,
-Latex,
line width=0.8pt
},
dashedflow/.style={
draw=black!80,
-Latex,
dashed,
line width=0.75pt
}
]
% =========================
% Top: two states
% =========================
\node[statebox] (s0) at (2.2,4.8) {
落子前状态 $s_t$\\[0.15cm]
Critic 估计\\[0.08cm]
$V_{\phi}(s_t)=4.0$
};
\node[statebox] (s1) at (10.8,4.8) {
落子后状态 $s_{t+1}$\\[0.15cm]
Critic 估计\\[0.08cm]
$V_{\phi}(s_{t+1})=6.0$
};
% action arrow
\draw[flow] (s0.east) -- (s1.west);
\node[align=center] at (6.5,5.35) {Actor 选择动作\\$a_t=B=(8,8)$};
\node at (6.5,4.3) {即时奖励 $r_t=0$};
% =========================
% Middle: TD error
% =========================
\node[tdbox] (td) at (6.5,2.0) {
时序差分误差\\[0.10cm]
$\delta_t=r_t+\gamma V_{\phi}(s_{t+1})-V_{\phi}(s_t)$\\[0.10cm]
$=0+0.9\times 6.0-4.0=1.4>0$
};
\draw[flow] (s0.south) -- (td.north west);
\draw[flow] (s1.south) -- (td.north east);
% =========================
% Bottom left: Actor update
% =========================
\node[actorbox] (actor) at (3.0,-1.3) {
Actor 更新\\[0.15cm]
$\delta_t>0$,说明动作 $B$ 的表现\\
好于原来的预期\\[0.18cm]
提高动作 $B$ 的选择概率\\[0.08cm]
$0.40 \rightarrow 0.48$
};
% =========================
% Bottom right: Critic update
% =========================
\node[criticbox] (critic) at (10.0,-1.3) {
Critic 更新\\[0.15cm]
价值目标:\\[0.08cm]
$y_t=r_t+\gamma V_{\phi}(s_{t+1})$\\[0.08cm]
$=0+0.9\times 6.0=5.4$\\[0.18cm]
$V_{\phi}(s_t)$$4.0$\\
$5.4$ 调整
};
% \draw[dashedflow] (td.south west) .. controls (4.6,0.7) and (3.6,-0.1) .. (actor.north);
% \draw[dashedflow] (td.south east) .. controls (8.5,0.7) and (9.4,-0.1) .. (critic.north);
\draw[flow] (td.south west) -- (actor.north);
\draw[flow] (td.south east) -- (critic.north);
% =========================
% Bottom notes
% =========================
% \node[note] at (3.0,-3.3) {Actor 根据评价信号调整策略};
% \node[note] at (10.0,-3.3) {Critic 根据 TD 误差修正价值估计};
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}[
font=\small,
box/.style={
draw=black,
rounded corners=4pt,
minimum width=3.0cm,
minimum height=0.75cm,
align=center
},
envbox/.style={
box,
fill=orange!10
},
agentbox/.style={
box,
fill=green!10
},
policybox/.style={
box,
fill=blue!3,
minimum width=2.4cm,
minimum height=0.9cm
},
flow/.style={
draw=black,
-Latex,
line width=0.8pt
},
smallflow/.style={
draw=black!80,
-Latex,
line width=0.7pt
}
]
% =========================
% Nodes
% =========================
\node[envbox] (env) at (0,1.45) {环境};
\node[agentbox] (agent) at (0,-1.55) {智能体};
\node[policybox] (policy) at (0,0.0) {策略\\$\pi(a_t|s_t)$};
% =========================
% Outer interaction loop
% =========================
% action: agent -> environment, right side
\draw[flow]
(agent.east)
-- ++(2.2,0)
-- ++(0,3.0)
-- (env.east);
\node at (3.0,0.05) {动作$(a)$};
% reward: environment -> agent, left side outer
\draw[flow]
(env.west)
-- ++(-2.5,0)
-- ++(0,-3.0)
-- (agent.west);
\node at (-4.75,0.05) {奖励$(r)$};
% state: environment -> agent, left inner curved arrow
\draw[flow]
(env.west)
.. controls (-2.55,0.65) and (-2.55,-0.65)
.. (agent.west);
\node at (-3.05,0.05) {状态$(s)$};
% =========================
% Policy-Agent relation
% =========================
\draw[smallflow, dashed]
(policy.west)
.. controls (-1.85,-0.1) and (-1.85,-1)
.. (agent.north west);
\draw[smallflow, dashed]
(agent.north east)
.. controls (1.85,-1.05) and (1.85,-0.25)
.. (policy.east);
\end{tikzpicture}
\begin{tikzpicture}[
font=\small,
flow/.style={
draw=black,
-Latex,
line width=0.8pt
},
dashedflow/.style={
draw=black!75,
-Latex,
dashed,
line width=0.75pt
},
panel/.style={
draw=black,
rounded corners=4pt,
line width=0.8pt
},
titlebox/.style={
draw=black,
rounded corners=4pt,
fill=blue!5,
minimum height=0.75cm,
align=center
},
infobox/.style={
draw=black,
rounded corners=4pt,
fill=gray!5,
align=center,
line width=0.8pt
},
blackstone/.style={
circle,
draw=black,
fill=black,
minimum size=6.5mm,
inner sep=0pt
},
whitestone/.style={
circle,
draw=black,
fill=white,
minimum size=6.5mm,
inner sep=0pt
},
cand/.style={
circle,
draw=orange!80!black,
fill=orange!20,
line width=0.9pt,
minimum size=7mm,
inner sep=0pt,
font=\bfseries
},
bestcand/.style={
circle,
draw=green!50!black,
fill=green!25,
line width=1.1pt,
minimum size=7.4mm,
inner sep=0pt,
font=\bfseries
},
rowbox/.style={
draw=black!30,
rounded corners=2pt,
minimum height=0.62cm,
align=left
}
]
% =========================
% Left panel: board
% =========================
\draw[panel, fill=orange!8] (0.3,5.2) rectangle (5.9,11.0);
\node[titlebox, minimum width=4.3cm] at (3.1,11.55) {当前棋盘状态 $s_t$};
% board grid
\draw[line width=0.8pt] (1,6) rectangle (5,10);
\foreach \x in {1,2,3,4,5}{
\draw[line width=0.5pt] (\x,6) -- (\x,10);
}
\foreach \y in {6,7,8,9,10}{
\draw[line width=0.5pt] (1,\y) -- (5,\y);
}
% axis labels
\node at (1,5.65) {6};
\node at (2,5.65) {7};
\node at (3,5.65) {8};
\node at (4,5.65) {9};
\node at (5,5.65) {10};
\node at (0.55,6) {6};
\node at (0.55,7) {7};
\node at (0.55,8) {8};
\node at (0.55,9) {9};
\node at (0.55,10) {10};
\node at (3.0,10.55) {\footnotesize 局部棋盘示意};
% existing stones
\node[blackstone] at (2,7) {};
\node[blackstone] at (3,7) {};
\node[blackstone] at (4,8) {};
\node[whitestone] at (2,9) {};
\node[whitestone] at (4,7) {};
\node[whitestone] at (5,8) {};
% candidate positions
\node[cand] at (2,8) {A};
\node[bestcand] at (3,8) {B};
\node[cand] at (3,9) {C};
\node[cand] at (4,9) {D};
% legend
\node[blackstone] at (1.2,5.1) {};
\node[anchor=west] at (1.45,5.1) {\footnotesize 黑棋};
\node[whitestone] at (2.4,5.1) {};
\node[anchor=west] at (2.65,5.1) {\footnotesize 白棋};
\node[cand, minimum size=5.8mm] at (3.7,5.1) {};
\node[anchor=west] at (3.95,5.1) {\footnotesize 候选位置};
\node[bestcand, minimum size=6.2mm] at (5.05,5.1) {};
\node[anchor=west] at (5.3,5.1) {\footnotesize 采样动作};
% =========================
% Middle panel: policy model
% =========================
\draw[flow] (6.15,8.2) -- (7.3,8.2);
\node at (6.72,8.55) {\footnotesize 状态输入};
\draw[panel, fill=blue!4] (7.5,7.1) rectangle (10.8,9.3);
\node[titlebox, minimum width=2.8cm] at (9.15,9.75) {策略模型};
\node at (9.15,8.55) {$\pi_{\theta}(a\mid s_t)$};
\node[align=center] at (9.15,7.75) {\footnotesize 输出合法动作的\\\footnotesize 概率分布};
\draw[flow] (10.95,8.2) -- (12.1,8.2);
\node at (11.52,8.55) {\footnotesize 概率输出};
% =========================
% Right panel: probability distribution
% =========================
\draw[panel, fill=green!5] (12.3,5.2) rectangle (18.5,11.0);
\node[titlebox, minimum width=5.0cm] at (15.4,11.55) {落子概率分布};
\draw[rowbox, fill=white] (12.8,10.1) rectangle (18.0,10.7);
\node[anchor=west] at (13.05,10.4) {$A:(7,8)\qquad \pi_{\theta}(A\mid s_t)=0.15$};
\draw[rowbox, fill=green!15] (12.8,9.15) rectangle (18.0,9.75);
\node[anchor=west] at (13.05,9.45) {$B:(8,8)\qquad \pi_{\theta}(B\mid s_t)=0.40$};
\node[anchor=west, text=green!40!black] at (16.95,9.45) {\footnotesize 概率最高};
\draw[rowbox, fill=white] (12.8,8.2) rectangle (18.0,8.8);
\node[anchor=west] at (13.05,8.5) {$C:(8,9)\qquad \pi_{\theta}(C\mid s_t)=0.25$};
\draw[rowbox, fill=white] (12.8,7.25) rectangle (18.0,7.85);
\node[anchor=west] at (13.05,7.55) {$D:(9,9)\qquad \pi_{\theta}(D\mid s_t)=0.20$};
% bottom formula / note
\draw[infobox] (12.8,5.85) rectangle (18.0,6.85);
\node[align=center] at (15.4,6.48) {$a_t\sim\pi_{\theta}(\cdot\mid s_t)$};
\node[align=center, text=green!40!black] at (15.4,6.1) {\footnotesize 按概率分布采样动作};
% sampled action arrow from probability row B back to board B
\draw[dashedflow]
(12.8,9.45)
.. controls (10.8,10.9) and (6.7,10.8)
.. (3,8.35);
\node[text=green!40!black] at (8.0,10.45) {\footnotesize 本次采样选择位置 $B=(8,8)$};
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}[
font=\small,
flow/.style={
draw=black,
-Latex,
line width=0.8pt
},
panel/.style={
draw=black,
rounded corners=4pt,
line width=0.8pt
},
titlebox/.style={
draw=black,
rounded corners=4pt,
fill=blue!5,
minimum height=0.75cm,
minimum width=4.6cm,
align=center
},
info/.style={
draw=black!65,
rounded corners=3pt,
line width=0.6pt,
fill=gray!5
},
blackstone/.style={
circle,
draw=black,
fill=black,
minimum size=6.5mm,
inner sep=0pt
},
whitestone/.style={
circle,
draw=black,
fill=white,
minimum size=6.5mm,
inner sep=0pt
},
cand/.style={
circle,
draw=orange!80!black,
fill=orange!20,
line width=0.9pt,
minimum size=7mm,
inner sep=0pt,
font=\bfseries
},
bestcand/.style={
circle,
draw=green!50!black,
fill=green!25,
line width=1.1pt,
minimum size=7.4mm,
inner sep=0pt,
font=\bfseries
},
legendblack/.style={
circle,
draw=black,
fill=black,
minimum size=4.8mm,
inner sep=0pt
},
legendwhite/.style={
circle,
draw=black,
fill=white,
minimum size=4.8mm,
inner sep=0pt
},
legendcand/.style={
circle,
draw=orange!80!black,
fill=orange!20,
line width=0.7pt,
minimum size=5.0mm,
inner sep=0pt
},
legendbest/.style={
circle,
draw=green!50!black,
fill=green!25,
line width=0.8pt,
minimum size=5.2mm,
inner sep=0pt
},
rowbox/.style={
draw=black!30,
rounded corners=2pt,
line width=0.5pt
},
resultbox/.style={
draw=green!50!black,
rounded corners=2pt,
line width=0.65pt,
fill=green!10
}
]
% ==================================================
% 左侧面板:当前棋盘局面
% ==================================================
\draw[panel, fill=orange!8]
(4.9,3.65) rectangle (11.1,11.0);
\node[titlebox]
at (8.0,11.65)
{当前棋盘局面 $s_t$};
\node at (8.0,10.55)
{\footnotesize 局部棋盘示意};
% 棋盘网格
\draw[line width=0.8pt]
(6,6) rectangle (10,10);
\foreach \x in {6,7,8,9,10}{
\draw[line width=0.5pt]
(\x,6) -- (\x,10);
}
\foreach \y in {6,7,8,9,10}{
\draw[line width=0.5pt]
(6,\y) -- (10,\y);
}
% 横坐标
\foreach \x in {6,7,8,9,10}{
\node[anchor=north]
at (\x,5.72)
{\x};
}
% 纵坐标:右对齐
\foreach \y in {6,7,8,9,10}{
\node[anchor=east]
at (5.72,\y)
{\y};
}
% 已有棋子
\node[blackstone] at (7,7) {};
\node[blackstone] at (8,7) {};
\node[blackstone] at (9,8) {};
\node[whitestone] at (7,9) {};
\node[whitestone] at (9,7) {};
\node[whitestone] at (10,8) {};
% 候选位置
\node[cand] at (7,8) {A};
\node[bestcand] at (8,8) {B};
\node[cand] at (8,9) {C};
\node[cand] at (9,9) {D};
% 图例:第一行
\node[legendblack] at (6.0,4.95) {};
\node[
anchor=west,
font=\footnotesize
] at (6.30,4.95) {黑棋};
\node[legendwhite] at (8.45,4.95) {};
\node[
anchor=west,
font=\footnotesize
] at (8.75,4.95) {白棋};
% 图例:第二行
\node[legendcand] at (6.0,4.25) {};
\node[
anchor=west,
font=\footnotesize
] at (6.30,4.25) {候选位置};
\node[legendbest] at (8.45,4.25) {};
\node[
anchor=west,
font=\footnotesize
] at (8.75,4.25) {最优候选};
% ==================================================
% 中间连接箭头
% ==================================================
\draw[flow]
(11.45,8.90) -- (13.15,8.90);
\node at (12.30,9.23)
{\footnotesize 价值评估};
% ==================================================
% 右侧面板:动作价值评估
% ==================================================
\draw[panel, fill=green!5]
(13.5,3.65) rectangle (19.7,11.0);
\node[titlebox]
at (16.6,11.65)
{动作价值评估};
% 动作 A
\draw[rowbox, fill=white]
(13.8,9.95) rectangle (19.3,10.60);
\node[anchor=west]
at (13.98,10.275)
{$A:(7,8)$};
\node[anchor=west]
at (16.15,10.275)
{$Q(s_t,A)=1.5$};
% 动作 B
\draw[rowbox, fill=green!15]
(13.8,9.05) rectangle (19.3,9.70);
\node[anchor=west]
at (13.98,9.375)
{$B:(8,8)$};
\node[anchor=west]
at (16.15,9.375)
{$Q(s_t,B)=6.2$};
% 动作 C
\draw[rowbox, fill=white]
(13.8,8.15) rectangle (19.3,8.80);
\node[anchor=west]
at (13.98,8.475)
{$C:(8,9)$};
\node[anchor=west]
at (16.15,8.475)
{$Q(s_t,C)=3.7$};
% 动作 D
\draw[rowbox, fill=white]
(13.8,7.25) rectangle (19.3,7.90);
\node[anchor=west]
at (13.98,7.575)
{$D:(9,9)$};
\node[anchor=west]
at (16.15,7.575)
{$Q(s_t,D)=-1.1$};
% 动作选择公式
\draw[info]
(13.8,5.75) rectangle (19.3,6.75);
\node[align=center]
at (16.55,6.25)
{$
a_t=
\displaystyle
\arg\max_{a\in\mathcal{A}(s_t)}
Q(s_t,a)
$};
% 最终选择结果
\draw[resultbox]
(13.8,4.50) rectangle (19.3,5.25);
\node[
align=center,
text=green!40!black,
font=\footnotesize\bfseries
] at (16.55,4.875)
{因此选择位置 $(8,8)$ 落子};
\end{tikzpicture}
\begin{tikzpicture}[
font=\small,
flow/.style={
draw=black,
-Latex,
line width=0.8pt
},
dashedflow/.style={
draw=black!70,
-Latex,
dashed,
line width=0.75pt
},
panel/.style={
draw=black,
rounded corners=5pt,
line width=0.8pt
},
titlebox/.style={
draw=black,
rounded corners=4pt,
fill=blue!6,
minimum height=0.72cm,
align=center,
line width=0.8pt
},
statebox/.style={
draw=black,
rounded corners=4pt,
fill=gray!6,
minimum width=4.8cm,
minimum height=0.9cm,
align=center,
line width=0.8pt
},
actionbox/.style={
draw=black,
rounded corners=3pt,
fill=green!7,
minimum width=2.1cm,
minimum height=0.95cm,
align=center,
line width=0.75pt
},
rarebox/.style={
draw=red!70!black,
rounded corners=3pt,
fill=red!7,
minimum width=2.1cm,
minimum height=0.95cm,
align=center,
line width=0.9pt
},
valuebox/.style={
draw=black,
rounded corners=3pt,
fill=blue!6,
minimum width=2.1cm,
minimum height=0.95cm,
align=center,
line width=0.75pt
},
highvaluebox/.style={
draw=red!70!black,
rounded corners=3pt,
fill=red!9,
minimum width=2.1cm,
minimum height=0.95cm,
align=center,
line width=0.9pt
},
policybox/.style={
draw=black,
rounded corners=4pt,
fill=yellow!12,
minimum width=4.8cm,
minimum height=1.05cm,
align=center,
line width=0.8pt
},
warningbox/.style={
draw=red!70!black,
rounded corners=4pt,
fill=red!7,
minimum width=4.8cm,
minimum height=1.15cm,
align=center,
line width=0.9pt
},
notebox/.style={
draw=black,
rounded corners=4pt,
fill=gray!6,
minimum height=1.05cm,
align=center,
line width=0.8pt
}
]
% ==================================================
% Overall title
% ==================================================
% \node[titlebox, minimum width=8.2cm] at (9.4,10.8)
% {离线强化学习中的分布偏移与价值高估};
% ==================================================
% Left panel: data coverage
% ==================================================
\draw[panel, fill=green!2] (0.2,2.0) rectangle (6.0,10.1);
\node[titlebox, minimum width=4.5cm] at (3.1,9.55)
{\textbf{历史数据覆盖}};
\node[statebox] at (3.1,8.25)
{
五子棋状态 $s_t$\\
历史棋谱中的候选落子
};
\node[actionbox] (a1) at (1.65,6.75)
{
位置 $A$\\
样本数:$120$
};
\node[actionbox] (a2) at (4.55,6.75)
{
位置 $B$\\
样本数:$85$
};
\node[actionbox] (a3) at (1.65,5.25)
{
位置 $C$\\
样本数:$46$
};
\node[rarebox] (a4) at (4.55,5.25)
{
位置 $D$\\
样本数:$2$
};
\node[notebox, minimum width=4.9cm] at (3.1,3.25)
{
位置 $A$$B$$C$ 有较多数据支持\\
位置 $D$ 在历史棋谱中很少出现
};
% ==================================================
% Middle panel: value estimation
% ==================================================
\draw[panel, fill=blue!2] (6.5,2.0) rectangle (12.3,10.1);
\node[titlebox, minimum width=4.5cm] at (9.4,9.55)
{\textbf{价值模型估计}};
\node[statebox] at (9.4,8.25)
{
价值网络计算\\
$Q(s_t,a)$
};
\node[valuebox] (q1) at (7.95,6.75)
{
$Q(s_t,A)$\\
$5.2$
};
\node[valuebox] (q2) at (10.85,6.75)
{
$Q(s_t,B)$\\
$5.8$
};
\node[valuebox] (q3) at (7.95,5.25)
{
$Q(s_t,C)$\\
$4.6$
};
\node[highvaluebox] (q4) at (10.85,5.25)
{
$Q(s_t,D)$\\
$8.7$
};
\node[notebox, minimum width=4.9cm] at (9.4,3.25)
{
位置 $D$ 缺少数据支持\\
但被价值模型赋予了最高估计
};
% ==================================================
% Right panel: target policy shift
% ==================================================
\draw[panel, fill=orange!3] (12.8,2.0) rectangle (18.6,10.1);
\node[titlebox, minimum width=4.5cm] at (15.7,9.55)
{\textbf{目标策略偏移}};
\node[policybox] (policy) at (15.7,8.05)
{
目标策略选择价值最大的动作\\
$a_t=\arg\max_a Q(s_t,a)$
};
\node[policybox, fill=red!8] (selectd) at (15.7,6.25)
{
选择位置 $D$\\
$\pi_{\theta}(D\mid s_t)$ 增大
};
\node[warningbox] (newstate) at (15.7,4.35)
{
进入历史数据很少覆盖的状态\\
价值估计可能不再可靠
};
\node[notebox, minimum width=4.9cm] at (15.7,2.75)
{
离线训练无法通过新的环境交互\\
及时验证并修正这一判断
};
% ==================================================
% Arrows between panels
% ==================================================
% \draw[flow]
% (6.05,6.15) --
% node[above, align=center] {\footnotesize 训练价值模型}
% (6.45,6.15);
% \draw[flow]
% (12.35,6.15) --
% node[above, align=center] {\footnotesize 根据估计更新策略}
% (12.75,6.15);
% Right internal arrows
\draw[flow] (policy.south) -- (selectd.north);
\draw[flow] (selectd.south) -- (newstate.north);
% Highlight rare action correspondence
% \draw[dashedflow]
% (a4.east)
% .. controls (5.9,4.65) and (7.0,4.65)
% .. (q4.west);
% ==================================================
% Bottom summary
% ==================================================
\node[
notebox,
fill=yellow!10,
minimum width=17.2cm,
minimum height=1.05cm
] at (9.4,1.15)
{
数据覆盖不足
$\longrightarrow$
未知动作价值被高估
$\longrightarrow$
目标策略偏离行为数据分布
};
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}[
font=\small,
flow/.style={
draw=black,
-Latex,
line width=0.8pt
},
dashedflow/.style={
draw=black!70,
-Latex,
dashed,
line width=0.75pt
},
panel/.style={
draw=black,
rounded corners=5pt,
line width=0.8pt
},
titlebox/.style={
draw=black,
rounded corners=4pt,
fill=blue!6,
minimum height=0.72cm,
align=center,
line width=0.8pt
},
agentbox/.style={
draw=black,
rounded corners=4pt,
fill=blue!9,
minimum width=3.8cm,
minimum height=1.15cm,
align=center,
line width=0.8pt
},
envbox/.style={
draw=black,
rounded corners=4pt,
fill=orange!10,
minimum width=3.8cm,
minimum height=1.15cm,
align=center,
line width=0.8pt
},
databox/.style={
draw=black,
rounded corners=4pt,
fill=green!8,
minimum width=4.3cm,
minimum height=1.25cm,
align=center,
line width=0.8pt
},
trainbox/.style={
draw=black,
rounded corners=4pt,
fill=purple!7,
minimum width=4.3cm,
minimum height=1.2cm,
align=center,
line width=0.8pt
},
resultbox/.style={
draw=black,
rounded corners=4pt,
fill=yellow!12,
minimum width=4.3cm,
minimum height=1.15cm,
align=center,
line width=0.8pt
},
notebox/.style={
draw=black,
rounded corners=4pt,
fill=gray!6,
minimum width=6.7cm,
minimum height=1.15cm,
align=center,
line width=0.8pt
}
]
% ==================================================
% Overall title
% ==================================================
% \node[titlebox, minimum width=8.0cm] at (9.3,10.9)
% {在线强化学习与离线强化学习的数据使用方式};
% ==================================================
% Left panel: online RL
% ==================================================
\draw[panel, fill=blue!2] (0.3,1.1) rectangle (8.8,10.2);
\node[titlebox, minimum width=4.8cm] at (4.55,9.65)
{\textbf{在线强化学习}};
\node[agentbox] (online-agent) at (4.55,7.9)
{
当前策略 $\pi_{\theta}$\\[0.05cm]
根据棋盘状态选择落子
};
\node[envbox] (online-env) at (4.55,5.55)
{
环境交互\\[0.05cm]
完成新的五子棋对弈
};
\node[databox] (online-data) at (4.55,3.2)
{
新交互数据\\[0.05cm]
$(s_t,a_t,r_t,s_{t+1})$
};
% Main online loop
\draw[flow] (online-agent.south) --
node[right, align=left] {\footnotesize 执行动作 $a_t$}
(online-env.north);
\draw[flow] (online-env.south) --
node[right, align=left] {\footnotesize 返回奖励和新状态}
(online-data.north);
\draw[flow]
(online-data.west)
.. controls (1.05,3.2) and (1.05,7.9)
.. node[left, align=center] {\footnotesize 使用新数据\\[-0.05cm]\footnotesize 更新策略}
(online-agent.west);
\node[notebox, minimum width=6.6cm] at (4.55,1.75)
{
策略更新后重新进入环境\\
训练数据会随当前策略不断变化
};
% ==================================================
% Right panel: offline RL
% ==================================================
\draw[panel, fill=green!2] (9.3,1.1) rectangle (18.3,10.2);
\node[titlebox, minimum width=4.8cm] at (13.8,9.65)
{\textbf{离线强化学习}};
\node[databox, minimum width=5.1cm] (offline-data) at (13.8,8.0)
{
固定历史数据集 $\mathcal{D}$\\[0.05cm]
棋盘状态、落子、奖励和后续状态
};
\node[trainbox, minimum width=5.1cm] (offline-train) at (13.8,5.7)
{
离线训练\\[0.05cm]
学习价值函数与目标策略
};
\node[resultbox, minimum width=5.1cm] (offline-policy) at (13.8,3.4)
{
目标策略 $\pi_{\theta}$\\[0.05cm]
部署后根据状态选择动作
};
\draw[flow] (offline-data.south) --
node[right, align=left] {\footnotesize 从固定数据集中采样}
(offline-train.north);
\draw[flow] (offline-train.south) --
node[right, align=left] {\footnotesize 参数优化}
(offline-policy.north);
\node[notebox, minimum width=7.0cm] at (13.8,1.75)
{
训练期间不再进入环境采集新数据\\
能够学习的内容受历史数据覆盖范围限制
};
% ==================================================
% Contrast annotation in the middle
% ==================================================
\draw[dashedflow]
(8.85,7.95) --
node[above, align=center] {\footnotesize 数据来源不同}
(9.25,7.95);
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}[
font=\small,
flow/.style={
draw=black!80,
-Latex,
line width=0.8pt,
shorten <=1.5pt,
shorten >=1.5pt
},
inputbox/.style={
draw=black!75,
rounded corners=4pt,
fill=orange!8,
text width=4.0cm,
minimum height=4.9cm,
align=center,
line width=0.8pt,
inner xsep=7pt,
inner ysep=7pt
},
branchbox/.style={
draw=black!75,
rounded corners=4pt,
text width=5.2cm,
minimum height=2.85cm,
align=center,
line width=0.8pt,
inner xsep=7pt,
inner ysep=6pt
},
positivebox/.style={
branchbox,
fill=green!9
},
negativebox/.style={
branchbox,
fill=red!6
},
resultbox/.style={
draw=black!75,
rounded corners=4pt,
text width=4.2cm,
minimum height=2.35cm,
align=center,
line width=0.8pt,
inner xsep=7pt,
inner ysep=6pt
},
positiveresult/.style={
resultbox,
fill=green!6
},
negativeresult/.style={
resultbox,
fill=red!4
},
principlebox/.style={
draw=black!65,
rounded corners=4pt,
fill=gray!6,
text width=13.3cm,
minimum height=1.2cm,
align=center,
line width=0.7pt,
inner xsep=8pt,
inner ysep=6pt
},
arrowlabel/.style={
font=\footnotesize,
text=black!80,
fill=white,
inner xsep=2pt,
inner ysep=1pt
},
branchlabel/.style={
font=\footnotesize,
text=black!80,
fill=white,
inner xsep=2pt,
inner ysep=1pt
}
]
% 设置安全边界,避免导出时裁切
\path[use as bounding box]
(-0.2,-0.35) rectangle (18.2,8.2);
% ==================================================
% 左侧:当前状态、策略与动作采样
% ==================================================
\node[inputbox] (input) at (2.5,4.75) {
{\bfseries 当前策略与动作}\\[6pt]
{\bfseries 当前棋盘状态 $s_t$}\\[4pt]
候选位置:$B=(8,8)$\\[4pt]
当前策略概率:\\[2pt]
$\displaystyle
\pi_{\theta}(B\mid s_t)=0.40
$\\[9pt]
{\footnotesize 按当前策略采样}\\[-1pt]
$\Downarrow$\\[3pt]
$\displaystyle
a_t=B=(8,8)
$\\[7pt]
{\footnotesize
随后观察该动作产生的实际回报}
};
% ==================================================
% 中间:正优势分支
% ==================================================
\node[positivebox] (positive) at (9.0,6.40) {
{\bfseries 正优势($+$):回报高于基线}\\[6pt]
实际回报:$G_t=8$\\[3pt]
状态基线:$b(s_t)=6$\\[5pt]
优势估计:$\widehat{A}_t=G_t-b(s_t)$\\[2pt]
$\displaystyle
=8-6=2>0
$\\[5pt]
{\footnotesize
该动作表现优于当前局面的平均水平}
};
% ==================================================
% 中间:负优势分支
% ==================================================
\node[negativebox] (negative) at (9.0,3.10) {
{\bfseries 负优势($-$):回报低于基线}\\[6pt]
实际回报:$G_t=3$\\[3pt]
状态基线:$b(s_t)=6$\\[5pt]
优势估计:$\widehat{A}_t=G_t-b(s_t)$\\[2pt]
$\displaystyle
=3-6=-3<0
$\\[5pt]
{\footnotesize
该动作表现低于当前局面的平均水平}
};
% ==================================================
% 右侧:正优势对应的策略更新结果
% ==================================================
\node[positiveresult] (positive-result) at (15.6,6.40) {
{\bfseries 动作概率提高($\uparrow$}\\[7pt]
更新前:\\[-1pt]
$\displaystyle
\pi_{\theta}(B\mid s_t)=0.40
$\\[5pt]
更新后:\\[-1pt]
$\displaystyle
\pi_{\theta}(B\mid s_t)=0.48
$\\[6pt]
{\footnotesize
后续更容易选择动作 $B$}
};
% ==================================================
% 右侧:负优势对应的策略更新结果
% ==================================================
\node[negativeresult] (negative-result) at (15.6,3.10) {
{\bfseries 动作概率降低($\downarrow$}\\[7pt]
更新前:\\[-1pt]
$\displaystyle
\pi_{\theta}(B\mid s_t)=0.40
$\\[5pt]
更新后:\\[-1pt]
$\displaystyle
\pi_{\theta}(B\mid s_t)=0.32
$\\[6pt]
{\footnotesize
后续选择动作 $B$ 的概率下降}
};
% ==================================================
% 左侧动作节点到正负分支的公共分叉
% ==================================================
\coordinate (split) at (5.35,4.75);
\coordinate (positive-join) at (5.35,6.40);
\coordinate (negative-join) at (5.35,3.10);
% 从左侧动作模块引出主干
\draw[flow]
(input.east)
--
(split);
% 公共分叉点
\fill[black!80]
(split) circle (1.4pt);
% 正优势分支
\draw[flow]
(split)
--
(positive-join)
--
node[midway, above=3pt, branchlabel]
{$G_t>b(s_t)$}
(positive.west);
% 负优势分支
\draw[flow]
(split)
--
(negative-join)
--
node[midway, below=3pt, branchlabel]
{$G_t<b(s_t)$}
(negative.west);
% ==================================================
% 优势分支到概率更新结果
% ==================================================
\draw[flow]
(positive.east)
--
node[midway, above=4pt, arrowlabel]
{提高选择概率}
(positive-result.west);
\draw[flow]
(negative.east)
--
node[midway, above=4pt, arrowlabel]
{降低选择概率}
(negative-result.west);
% ==================================================
% 底部:统一的基线与策略更新原则
% ==================================================
\node[principlebox] (principle) at (9.0,0.45) {
{\bfseries 基线与策略更新原则}\\[5pt]
常用状态基线为
$\displaystyle b(s_t)=V^{\pi}(s_t)$\\[3pt]
策略更新关注的不是回报的绝对大小,
而是动作结果相对于当前平均水平的好坏。
};
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}[
font=\small,
flow/.style={
draw=black,
-Latex,
line width=0.8pt
},
dashedflow/.style={
draw=black!80,
-Latex,
dashed,
line width=0.75pt
},
panel/.style={
draw=black,
rounded corners=4pt,
line width=0.8pt
},
titlebox/.style={
draw=black,
rounded corners=4pt,
fill=blue!5,
minimum height=0.72cm,
align=center
},
infobox/.style={
draw=black,
rounded corners=4pt,
fill=gray!6,
minimum width=4.2cm,
minimum height=1.05cm,
align=center,
line width=0.8pt
},
rowbox/.style={
draw=black,
rounded corners=4pt,
minimum width=5.2cm,
minimum height=1.95cm,
align=left,
line width=0.8pt
},
pospanel/.style={
draw=black,
rounded corners=4pt,
fill=green!6,
line width=0.8pt
},
negpanel/.style={
draw=black,
rounded corners=4pt,
fill=red!5,
line width=0.8pt
}
]
% =========================
% Left panel
% =========================
\draw[panel, fill=orange!8] (0.2,3.8) rectangle (5.5,10.4);
\node[titlebox, minimum width=4.2cm] at (2.85,10.9) {旧策略与裁剪区间};
\node[infobox] at (2.85,9.55) {
旧策略\\[0.06cm]
$\pi_{\theta_{\mathrm{old}}}(B\mid s_t)=0.40$
};
\node[infobox] at (2.85,7.8) {
裁剪阈值\\[0.06cm]
$\epsilon=0.2$
};
\node[infobox] at (2.85,6.05) {
概率比值允许范围\\[0.06cm]
$[1-\epsilon,1+\epsilon]=[0.8,1.2]$
};
\node[infobox, minimum width=4.4cm, minimum height=1.35cm] at (2.85,4.5) {
裁剪限制的是\\[0.05cm]
过大概率变化带来的\\[0.05cm]
目标函数收益
};
% arrows to two cases
\draw[flow] (5.65,8.6) -- (6.8,8.9);
\draw[flow] (5.65,5.6) -- (6.8,5.3);
% =========================
% Top right panel: positive advantage
% =========================
\draw[pospanel] (6.9,7.25) rectangle (18.1,10.4);
\node[titlebox, minimum width=4.8cm] at (12.5,10.9) {正优势动作 $\widehat{A}_t>0$};
\draw[rowbox, fill=white] (7.3,8.05) rectangle (12.2,9.8);
\node[anchor=west, align=left] at (7.55,9.45) {
新策略概率:$0.48$\\
概率比值:$r_t(\theta)=0.48/0.40=1.20$\\
位于上界\\
允许提高动作概率
};
\draw[rowbox, fill=green!12] (12.8,8.05) rectangle (17.7,9.8);
\node[anchor=west, align=left] at (13.05,9.45) {
新策略概率:$0.60$\\
概率比值:$r_t(\theta)=0.60/0.40=1.50$\\
超出上界 $1.20$\\
裁剪后按 $1.20$ 计算收益
};
\node[text=green!40!black] at (9.75,7.55) {\footnotesize 适度提高概率};
\node[text=green!40!black] at (15.25,7.55) {\footnotesize 过大变化不再获得额外鼓励};
% =========================
% Bottom right panel: negative advantage
% =========================
\draw[negpanel] (6.9,3.8) rectangle (18.1,6.95);
\node[titlebox, minimum width=4.8cm] at (12.5,7.45) {负优势动作 $\widehat{A}_t<0$};
\draw[rowbox, fill=white] (7.3,4.6) rectangle (12.2,6.35);
\node[anchor=west, align=left] at (7.55,6.0) {
新策略概率:$0.32$\\
概率比值:$r_t(\theta)=0.32/0.40=0.80$\\
位于下界\\
允许降低动作概率
};
\draw[rowbox, fill=red!10] (12.8,4.6) rectangle (17.7,6.35);
\node[anchor=west, align=left] at (13.05,6.0) {
新策略概率:$0.20$\\
概率比值:$r_t(\theta)=0.20/0.40=0.50$\\
低于下界 $0.80$\\
裁剪后按 $0.80$ 计算收益
};
\node[text=red!60!black] at (9.75,4.1) {\footnotesize 适度降低概率};
\node[text=red!60!black] at (15.25,4.1) {\footnotesize 过大变化不再获得额外鼓励};
% =========================
% Bottom note
% =========================
\draw[panel, fill=gray!6] (6.9,2.2) rectangle (18.1,3.3);
\node[align=center] at (12.5,2.75) {
PPO 并不直接禁止新策略继续变化\\
而是限制超出裁剪范围后的额外优化收益
};
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}[
font=\small,
flow/.style={
draw=black,
-Latex,
line width=0.8pt
},
dashedflow/.style={
draw=black!75,
-Latex,
dashed,
line width=0.75pt
},
panel/.style={
draw=black,
rounded corners=4pt,
line width=0.8pt
},
titlebox/.style={
draw=black,
rounded corners=4pt,
fill=blue!5,
minimum height=0.72cm,
align=center
},
stepbox/.style={
draw=black,
rounded corners=4pt,
fill=gray!5,
minimum width=3.8cm,
minimum height=1.1cm,
align=center,
line width=0.8pt
},
actorbox/.style={
draw=black,
rounded corners=4pt,
fill=blue!8,
minimum width=4.1cm,
minimum height=1.05cm,
align=center,
line width=0.8pt
},
criticbox/.style={
draw=black,
rounded corners=4pt,
fill=green!8,
minimum width=4.1cm,
minimum height=1.05cm,
align=center,
line width=0.8pt
},
envbox/.style={
draw=black,
rounded corners=4pt,
fill=orange!10,
minimum width=4.1cm,
minimum height=1.05cm,
align=center,
line width=0.8pt
},
notebox/.style={
draw=black,
rounded corners=4pt,
fill=yellow!10,
minimum width=5.2cm,
minimum height=1.0cm,
align=center,
line width=0.8pt
},
comparebox/.style={
draw=black,
rounded corners=4pt,
fill=gray!8,
minimum width=5.4cm,
minimum height=1.8cm,
align=left,
line width=0.8pt
}
]
% =========================
% Outer panel
% =========================
\draw[panel, fill=white] (0.2,0.3) rectangle (18.7,11.2);
\node[titlebox, minimum width=5.4cm] at (9.45,11.7) {PPO 的策略更新与样本重复利用过程};
% =========================
% Main steps
% =========================
\node[actorbox] (s1) at (3.0,9.7) {
第 1 步\\
固定当前策略\\
$\theta \rightarrow \theta_{\mathrm{old}}$
};
\node[envbox] (s2) at (9.45,9.7) {
第 2 步\\
使用旧策略与环境交互\\
采集状态、动作、奖励数据
};
\node[criticbox] (s3) at (15.8,9.7) {
第 3 步\\
Critic 计算价值估计\\
得到回报和优势 $\widehat{A}_t$
};
\node[stepbox] (s4) at (3.0,6.9) {
第 4 步\\
将采集到的数据\\
划分为多个小批次
};
\node[stepbox] (s5) at (9.45,6.9) {
第 5 步\\
基于裁剪目标\\
更新 Actor
};
\node[criticbox] (s6) at (15.8,6.9) {
第 6 步\\
更新 Critic\\
提高价值估计精度
};
\node[notebox] (s7) at (9.45,4.4) {
对同一批数据重复训练 $K$\\
每一轮都使用裁剪目标限制策略变化
};
\node[actorbox] (s8) at (9.45,1.9) {
第 7 步\\
完成本轮更新后\\
用新策略重新采样数据
};
% =========================
% Main arrows
% =========================
\draw[flow] (s1.east) -- (s2.west);
\draw[flow] (s2.east) -- (s3.west);
\draw[flow] (s3.south west) .. controls (14.0,8.5) and (4.8,8.2) .. (s4.north east);
\draw[flow] (s4.east) -- (s5.west);
\draw[flow] (s5.east) -- (s6.west);
\draw[flow] (s6.south west) .. controls (14.0,5.6) and (11.7,5.0) .. (s7.north east);
\draw[flow] (s7.south) -- (s8.north);
% =========================
% Reuse loop
% =========================
\draw[dashedflow]
(s7.west)
.. controls (4.8,4.4) and (4.8,6.0)
.. node[midway, above] {\footnotesize 重复 $K$} (s4.south);
% =========================
% Comparison note
% =========================
\node[comparebox] at (3.5,2.1) {
\textbf{与 A2C 的区别:}\\
A2C:采集一批数据后通常只更新一次\\
PPO:采集一批数据后可划分小批次并重复更新多轮
};
% =========================
% Small note
% =========================
\node[comparebox, minimum width=5.0cm, minimum height=1.6cm] at (15.1,2.1) {
\textbf{核心原因:}\\
裁剪目标限制单次策略更新幅度\\
因此同一批样本可以在一定范围内重复利用
};
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}[
font=\small,
topbox/.style={
draw=black!75,
rounded corners=4pt,
minimum height=2.55cm,
align=center,
line width=0.75pt,
inner xsep=6pt,
inner ysep=5pt,
font=\footnotesize
},
estimatebox/.style={
topbox,
fill=blue!6,
text width=3.25cm
},
samplebox/.style={
topbox,
fill=orange!10,
text width=3.85cm
},
targetbox/.style={
topbox,
fill=green!8,
text width=3.65cm
},
updatebox/.style={
topbox,
fill=green!15,
text width=3.15cm
},
formulabox/.style={
draw=black!75,
rounded corners=4pt,
fill=gray!5,
minimum width=16.4cm,
minimum height=1.90cm,
align=center,
line width=0.8pt,
inner xsep=8pt,
inner ysep=7pt
},
calculationbox/.style={
draw=green!45!black,
rounded corners=4pt,
fill=green!7,
minimum width=12.5cm,
minimum height=1.30cm,
align=center,
line width=0.8pt,
inner xsep=8pt,
inner ysep=6pt
},
flow/.style={
draw=black!80,
-Latex,
line width=0.75pt,
shorten <=2pt,
shorten >=2pt
},
inputflow/.style={
draw=black!65,
dashed,
-Latex,
line width=0.7pt,
shorten <=2pt,
shorten >=2pt
},
flowlabel/.style={
font=\scriptsize,
text=black!80,
fill=white,
inner xsep=1.5pt,
inner ysep=0.5pt
},
inputlabel/.style={
font=\scriptsize,
text=black!70,
fill=white,
inner xsep=1.5pt,
inner ysep=0.5pt
},
explanation/.style={
font=\footnotesize,
text=black!75,
align=center
}
]
% 保留足够的上下左右边距,避免导出时内容被裁切
\path[use as bounding box]
(-2.2,-8.15) rectangle (18.0,1.75);
% ==================================================
% 第一层:Q-learning 的四个步骤
% ==================================================
\node[estimatebox] (estimate) at (0,0) {
{\small\bfseries 当前价值估计}\\[5pt]
\mbox{智能体在位置 $(8,8)$ 落子}\\[6pt]
$\displaystyle Q(s_t,(8,8))=2.0$
};
\node[samplebox] (sample) at (5.2,0) {
{\small\bfseries 观察交互结果}\\[5pt]
即时奖励:$r_t=0$\\[5pt]
\mbox{下一状态最大动作价值}\\[3pt]
$\displaystyle
\max_{a'}Q(s_{t+1},a')=6.0
$
};
\node[targetbox] (target) at (10.8,0) {
{\small\bfseries 计算价值目标}\\[5pt]
$\displaystyle
y_t=
r_t+\gamma\max_{a'}Q(s_{t+1},a')
$\\[6pt]
$\displaystyle
y_t=0+0.9\times6.0=5.4
$
};
\node[updatebox] (update) at (15.8,0) {
{\small\bfseries 更新动作价值}\\[5pt]
学习率:$\alpha=0.5$\\[7pt]
$\displaystyle Q_{\mathrm{new}}=3.7$
};
% ==================================================
% 顶部流程箭头
% ==================================================
\draw[flow]
(estimate.east)
--
node[midway, above=4pt, flowlabel]
{执行动作}
(sample.west);
\draw[flow]
(sample.east)
--
node[midway, above=4pt, flowlabel]
{计算目标}
(target.west);
\draw[flow]
(target.east)
--
node[midway, above=4pt, flowlabel]
{更新估计}
(update.west);
% ==================================================
% 第二层:Q-learning 更新公式
% ==================================================
\node[formulabox] (formula) at (7.9,-3.75) {
{\small\bfseries Q-learning 更新公式}\\[7pt]
$\displaystyle
\begin{aligned}
y_t
&=
r_t+
\gamma\max_{a'}Q(s_{t+1},a'),
\\[3pt]
Q(s_t,a_t)
&\leftarrow
Q(s_t,a_t)
+
\alpha
\bigl[
y_t-Q(s_t,a_t)
\bigr].
\end{aligned}
$
};
% 在公式框上边缘设置两个输入位置
\coordinate (formula-current-input)
at ([xshift=-6.7cm]formula.north);
\coordinate (formula-target-input)
at ([xshift=1.7cm]formula.north);
% 当前估计值输入
\draw[inputflow]
(estimate.south)
to[out=-90,in=90]
node[pos=0.50, left=3pt, inputlabel]
{当前估计值}
(formula-current-input);
% 目标值输入
\draw[inputflow]
(target.south)
to[out=-90,in=90]
node[pos=0.50, right=3pt, inputlabel]
{目标值}
(formula-target-input);
% ==================================================
% 第三层:代入数值并得到更新结果
% ==================================================
\node[calculationbox] (calculation) at (7.9,-6.35) {
$\displaystyle
Q(s_t,(8,8))
\leftarrow
2.0
+
0.5\times(5.4-2.0)
=
\textcolor{green!40!black}{\mathbf{3.7}}
$
};
\draw[flow]
(formula.south)
--
node[midway, right=5pt, flowlabel]
{代入数值}
(calculation.north);
% ==================================================
% 底部结果说明
% ==================================================
\node[
explanation,
text width=12.5cm
] at (7.9,-7.65) {
新观测得到的目标价值高于原有估计,\\[3pt]
因此位置 $(8,8)$ 的动作价值由 $2.0$ 提高至 $3.7$
};
\end{tikzpicture}
\ No newline at end of file
# 中文课程讲义 LaTeX 模板
主文件是 `aml_notes.tex`,建议使用 XeLaTeX 编译:
```powershell
xelatex aml_notes.tex
xelatex aml_notes.tex
```
第二次编译用于生成完整目录和交叉引用。图片可以放在 `figures/``images/` 目录中,然后用 `\includegraphics` 插入。
常用修改位置:
- 课程信息:修改 `\coursename``\semester``\teacher``\school`
- 新增章节:使用 `\chapter{章节标题}`
- 新增小节:使用 `\section{小节标题}``\subsection{小节标题}`
- 插入表格:参考模板中的 `table``longtable` 示例。
- 插入图片:把图片放入 `figures/`,参考模板中的 `figure` 示例。
如果使用 Overleaf,也请选择 XeLaTeX 作为编译器。
% !TeX program = xelatex
% 中文课程讲义 LaTeX 模板
% 编译建议:XeLaTeX 或 LuaLaTeX。Windows / macOS / Linux 均可使用 ctex 自动处理中文字体。
\documentclass[UTF8,a4paper,zihao=-4,oneside,openany]{ctexbook}
% 页面与基础排版
\usepackage[
top=2.6cm,
bottom=2.6cm,
left=2.7cm,
right=2.7cm,
headheight=15pt
]{geometry}
\usepackage{setspace}
\setstretch{1.25}
\setlength{\parindent}{2em}
\setlength{\parskip}{0.2em}
\setlength{\emergencystretch}{3em}
\sloppy
% 数学、表格、图片
\usepackage{amsmath,amssymb}
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{array}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{graphicx}
\usepackage{hyperref}
\usetikzlibrary{arrows.meta,backgrounds,decorations.pathreplacing,fit}
\usepackage[numbers,sort&compress]{natbib}
\pgfplotsset{compat=1.18}
\bibliographystyle{plainnat}
\usepackage{ulem} % 提供 \uline 下划线命令(或使用 \underline)
\graphicspath{{figures/}{images/}}
% 颜色与强调框
\usepackage[most]{tcolorbox}
\usepackage{xcolor}
\definecolor{CourseInk}{HTML}{1F2933}
\definecolor{CourseBlue}{HTML}{24577A}
\definecolor{CourseGreen}{HTML}{2D6A4F}
\definecolor{CourseGold}{HTML}{A16207}
\definecolor{CourseGray}{HTML}{F4F6F8}
\definecolor{CourseLine}{HTML}{D9E2EC}
\definecolor{ugreen}{rgb}{0,0.5,0}
\definecolor{lolgreen}{RGB}{103,213,181}
\definecolor{lolorange}{RGB}{246,179,82}
\definecolor{lolpurple}{RGB}{200,158,196}
\tcbset{
enhanced,
boxrule=0.6pt,
arc=2mm,
left=3mm,
right=3mm,
top=2mm,
bottom=2mm,
breakable
}
\newtcolorbox{learninggoals}{
colback=CourseGray,
colframe=CourseBlue,
title=学习目标,
fonttitle=\bfseries
}
\newtcolorbox{importantnote}{
colback=white,
colframe=CourseGreen,
title=重点提示,
fonttitle=\bfseries
}
\newtcolorbox{examplebox}[1][]{
colback=white,
colframe=CourseGold,
title=例题 #1,
fonttitle=\bfseries
}
\newtcolorbox{exercisebox}{
colback=CourseGray,
colframe=CourseLine,
title=课堂练习,
fonttitle=\bfseries\color{CourseInk}
}
% 页眉页脚与链接
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\small 中文课程讲义}
\fancyhead[R]{\small \leftmark}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
\usepackage[
colorlinks=true,
linkcolor=CourseBlue,
urlcolor=CourseGreen,
citecolor=CourseGold
]{hyperref}
% 章节样式
\ctexset{
chapter = {
name = {第,讲},
number = \chinese{chapter},
format = \huge\bfseries\color{CourseBlue},
beforeskip = 0pt,
afterskip = 22pt
},
section = {
format = \Large\bfseries\color{CourseInk}
},
subsection = {
format = \large\bfseries\color{CourseInk}
}
}
% 常用命令
\newcommand{\coursename}{中文课程名称}
\newcommand{\semester}{2026 春季}
\newcommand{\teacher}{授课教师}
\newcommand{\school}{学校 / 机构名称}
\newcommand{\lessondate}{\today}
\newcommand{\blankline}{\par\noindent\rule{\linewidth}{0.4pt}\par}
\newcommand{\keyword}[1]{\textbf{\color{CourseBlue}#1}}
% 统一图片占位符:所有待补图片统一使用该占位框。
\newcommand{\imageplaceholder}[2][5cm]{%
\fbox{%
\begin{minipage}[c][#1][c]{0.78\linewidth}
\centering
\textbf{图片占位}\\[0.45em]
{\small #2}
\end{minipage}%
}%
}
% 原讲义中多处使用 \mindex 标注术语,这里给出安全定义,避免未定义命令。
\newcommand{\mindex}[1]{\textit{#1}}
\begin{document}
% % 封面
% \begin{titlepage}
% \centering
% \vspace*{1.5cm}
% {\zihao{1}\bfseries\color{CourseBlue}\coursename\par}
% \vspace{0.8cm}
% {\zihao{3}\bfseries 课程讲义模板\par}
% \vspace{1.2cm}
% \imageplaceholder[0.24\textheight]{封面图:将图片命名为 \texttt{cover.jpg} 并放入 \texttt{figures/} 目录。}
% \vfill
% \begin{tabular}{rl}
% \textbf{教师:} & \teacher \\
% \textbf{学期:} & \semester \\
% \textbf{单位:} & \school \\
% \textbf{日期:} & \lessondate \\
% \end{tabular}
% \vspace*{1.2cm}
% \end{titlepage}
% 目录
\frontmatter
\pagestyle{plain}
\tableofcontents
\cleardoublepage
% 正文
\mainmatter
\pagestyle{fancy}
% \chapter{课程导论}
% \begin{learninggoals}
% \begin{itemize}
% \item 了解本课程的学习目标、评价方式与课堂要求。
% \item 熟悉讲义中的例题、练习、阅读材料与作业模块。
% \item 掌握如何在模板中插入章节、表格、图片和重点提示。
% \end{itemize}
% \end{learninggoals}
% \section{课程说明}
% 这里填写本讲的正文内容。中文可直接输入,不需要额外转码。若要突出关键词,可使用
% \keyword{关键词强调},也可以使用普通的 \textbf{加粗}、\emph{斜体} 等格式。
% \begin{importantnote}
% 这里可以写课堂重点、易错点、考试提示,或者需要学生特别记住的概念。
% \end{importantnote}
% \section{表格示例}
% 表格建议使用 \texttt{booktabs} 提供的 \verb|\toprule|、\verb|\midrule|、\verb|\bottomrule|,
% 视觉会比普通竖线表格更清爽。
% \begin{table}[htbp]
% \centering
% \caption{课程安排示例}
% \label{tab:schedule}
% \begin{tabularx}{0.92\linewidth}{>{\centering\arraybackslash}p{2.3cm}X>{\centering\arraybackslash}p{2.8cm}}
% \toprule
% 周次 & 主题 & 任务 \\
% \midrule
% 第 1 周 & 课程导论与学习方法 & 阅读讲义 \\
% 第 2 周 & 核心概念一 & 完成练习 \\
% 第 3 周 & 核心概念二 & 小组讨论 \\
% \bottomrule
% \end{tabularx}
% \end{table}
% \section{图片示例}
% 将图片放入 \texttt{figures/} 目录,然后用 \verb|\includegraphics| 插入。下面的示例会在
% \texttt{figures/example.png} 存在时显示图片,否则显示一个占位框。
% \begin{figure}[htbp]
% \centering
% \imageplaceholder{示例图片:将图片保存为 \texttt{figures/example.png}。}
% \caption{图片插入示例}
% \label{fig:example}
% \end{figure}
% \section{例题与练习}
% \begin{examplebox}[1]
% 这里放置例题内容。可以包含公式:
% \[
% a^2 + b^2 = c^2
% \]
% 也可以写解题步骤或分析。
% \end{examplebox}
% \begin{exercisebox}
% \begin{enumerate}
% \item 请用自己的话概括本讲的三个重点。
% \item 根据表~\ref{tab:schedule},说明第 2 周需要完成什么任务。
% \item 观察图~\ref{fig:example},写出你能得到的信息。
% \end{enumerate}
% \end{exercisebox}
% \chapter{第二讲标题}
% \section{知识点一}
% 从这里开始写第二讲内容。新增章节时,复制下面结构即可:
% \begin{verbatim}
% \chapter{新的一讲}
% \section{小节标题}
% 正文内容……
% \end{verbatim}
% \subsection{更小的层级}
% 如果一讲内部内容较多,可以继续使用 \verb|\subsection| 或 \verb|\subsubsection| 组织层次。
% \section{长表格示例}
% 如果表格跨页,可以使用 \texttt{longtable}。
% \begin{longtable}{p{0.18\linewidth}p{0.34\linewidth}p{0.34\linewidth}}
% \caption{长表格结构示例}
% \label{tab:longtable}\\
% \toprule
% 模块 & 内容 & 备注 \\
% \midrule
% \endfirsthead
% \toprule
% 模块 & 内容 & 备注 \\
% \midrule
% \endhead
% 课前 & 预习阅读材料 & 可附链接或二维码图片 \\
% 课中 & 讲授、讨论、练习 & 建议加入例题与即时反馈 \\
% 课后 & 作业、复盘、扩展阅读 & 可列出提交要求 \\
% \bottomrule
% \end{longtable}
\chapter{大模型预训练与微调方法}
\input{section/3.0-introduction}
\input{section/3.1-pretraining}
\input{section/3.2-prompt}
\input{section/3.3-finetune}
\input{section/3.4-alignment}
\input{section/3.5-reasoning}
\input{section/3.6-summary}
\appendix
\chapter{附录}
\section{常用 LaTeX 片段}
\begin{verbatim}
% 插入普通图片
\begin{figure}[htbp]
\centering
\includegraphics[width=0.8\linewidth]{figures/your-image.png}
\caption{图片标题}
\end{figure}
% 插入三线表
\begin{table}[htbp]
\centering
\caption{表格标题}
\begin{tabular}{lll}
\toprule
A & B & C \\
\midrule
内容 & 内容 & 内容 \\
\bottomrule
\end{tabular}
\end{table}
\end{verbatim}
\backmatter
\chapter{参考资料}
这里可以列出教材、论文、网站或其他阅读材料。
% 使用外部 BibTeX 数据库。请将 bibliography.bib 与本 .tex 文件放在同一目录。
% 如果你的 bib 文件名不同,例如 refs.bib,请改成 \bibliography{refs}。
\bibliography{bibliography}
\end{document}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论