From bc5029a47b60183dff3d1c20b3494d3b88d2df54 Mon Sep 17 00:00:00 2001 From: Mu Li Date: Tue, 13 Nov 2018 22:18:28 -0800 Subject: [PATCH] Theme (#423) * add frontpage.html * change theme * change permission * fix build_html * fix build html * Update build_html.sh * Update Makefile * Update fasttext.md * Update Jenkinsfile * Update Jenkinsfile * Update glove.md * Update notation.md * Update notation.md * Update Makefile * update mxtheme * use python 3.6 to build * Update Jenkinsfile --- .gitignore | 8 +- .gitmodules | 3 + Jenkinsfile | 28 +++ Makefile | 15 +- build/Makefile | 1 + build/_static/frontpage.css | 96 ++++++++ build/_static/gluon.css | 16 -- build/_static/index.css | 223 ------------------ build/build_doc.sh | 57 ----- build/build_html.sh | 13 + build/build_pdf.sh | 7 + build/conf.py | 26 +- build/env.yml | 16 ++ build/frontpage.html | 91 +++++++ build/index.html | 214 ----------------- build/{toc.rst => index.rst} | 8 +- build/mx-theme | 1 + chapter_appendix/notation.md | 8 - .../fasttext.md | 4 +- chapter_natural-language-processing/glove.md | 4 +- 20 files changed, 301 insertions(+), 538 deletions(-) create mode 100644 .gitmodules create mode 100644 Jenkinsfile create mode 100644 build/_static/frontpage.css delete mode 100644 build/_static/gluon.css delete mode 100755 build/_static/index.css delete mode 100644 build/build_doc.sh create mode 100755 build/build_html.sh create mode 100755 build/build_pdf.sh create mode 100644 build/env.yml create mode 100644 build/frontpage.html delete mode 100644 build/index.html rename build/{toc.rst => index.rst} (82%) create mode 160000 build/mx-theme diff --git a/.gitignore b/.gitignore index 2b9afd004..68dc18a5b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,13 @@ **/.ipynb_checkpoints **/__pycache__ data/ -build/ +build/chapter* +build/_build +build/img +build/environment.yml +build/gluonbook +build/data +build/README.md *.json *.params *.DS_Store diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..8ebebc015 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "build/mx-theme"] + path = build/mx-theme + url = https://github.com/mli/mx-theme diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..2ec798d86 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,28 @@ +stage("Build HTML") { + node { + ws('workspace/d2l-zh') { + checkout scm + sh "build/build_html.sh" + } + } +} +stage("Build PDF") { + node { + ws('workspace/d2l-zh') { + sh "build/build_pdf.sh" + } + } +} + +stage("Publish") { + node { + ws('workspace/d2l-zh') { + sh """#!/bin/bash + set -ex + if [[ ${env.BRANCH_NAME} == master ]]; then + aws s3 sync --delete build/_build/html/ s3://zh.diveintodeeplearning.org/ --acl public-read + fi + """ + } + } +} diff --git a/Makefile b/Makefile index 5407446b9..901cecc5c 100644 --- a/Makefile +++ b/Makefile @@ -17,14 +17,14 @@ OBJ = $(patsubst %.md, build/%.md, $(MARKDOWN)) \ ORIGN_DEPS = $(wildcard img/* data/* gluonbook/*) environment.yml README.md DEPS = $(patsubst %, build/%, $(ORIGN_DEPS)) -PKG = build/_build/html/gluon_tutorials_zh.tar.gz build/_build/html/gluon_tutorials_zh.zip +PKG = build/_build/html/d2l-zh.tar.gz build/_build/html/d2l-zh.zip pkg: $(PKG) -build/_build/html/gluon_tutorials_zh.zip: $(OBJ) $(DEPS) +build/_build/html/d2l-zh.zip: $(OBJ) $(DEPS) cd build; zip -r $(patsubst build/%, %, $@ $(DEPS)) chapter* -build/_build/html/gluon_tutorials_zh.tar.gz: $(OBJ) $(DEPS) +build/_build/html/d2l-zh.tar.gz: $(OBJ) $(DEPS) cd build; tar -zcvf $(patsubst build/%, %, $@ $(DEPS)) chapter* build/%: % @@ -33,10 +33,9 @@ build/%: % html: $(DEPS) $(OBJ) make -C build html - cp build/index.html build/_build/html/ cp -r img/frontpage/ build/_build/html/_images/ - -TEX=build/_build/latex/gluon_tutorials_zh.tex + +TEX=build/_build/latex/d2l-zh.tex build/_build/latex/%.pdf: img/%.svg @mkdir -p $(@D) @@ -61,8 +60,8 @@ pdf: $(DEPS) $(OBJ) $(PDFIMG) sed -i /{\\\\tablename\\\\\ \\\\thetable{}\ --\ continued\ from\ previous\ page}/d $(TEX) cd build/_build/latex && \ bash ../../convert_output_svg.sh && \ - buf_size=10000000 xelatex gluon_tutorials_zh.tex && \ - buf_size=10000000 xelatex gluon_tutorials_zh.tex + buf_size=10000000 xelatex d2l-zh.tex && \ + buf_size=10000000 xelatex d2l-zh.tex clean: rm -rf build/chapter* build/_build $(DEPS) $(PKG) diff --git a/build/Makefile b/build/Makefile index ba196a15a..f2ace4966 100644 --- a/build/Makefile +++ b/build/Makefile @@ -19,6 +19,7 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +all: html .PHONY: help help: @echo "Please use \`make ' where is one of" diff --git a/build/_static/frontpage.css b/build/_static/frontpage.css new file mode 100644 index 000000000..5e58ee030 --- /dev/null +++ b/build/_static/frontpage.css @@ -0,0 +1,96 @@ +h1, .side-doc-outline { + display: none; +} +.document .page-content { + width: 100%; +} + +h2, h3, h4 { + letter-spacing: 2px; +} +.mdl-grid { + align-items: center; + justify-content: center; + text-align: center; + padding: 150px 0 0 0; +} + +#id2 h2 { + padding: 150px 0 0 0; +} + +.header h2 { + font-size: 30px; + padding-bottom: 35px; +} + +.header p { + font-size: 24px; + letter-spacing: 2px; + line-height: 36px; + padding-bottom: 10px; +} + +.header img { + max-width: 350px; +} + +.header .mdl-button { + margin: 0px 10px; + letter-spacing: 2px; + font-size: 16px; + margin: 1rem 1.5rem; + height: 40px; + width: 120px; +} + + +.author-item { + max-width: 300px; +} + +.author-item h3 { + padding-top: 25px; + padding-bottom: 10px; +} +.author-item img { + border-radius: 50%; + width: 120px; +} +.authors h4 { + width: 100%; +} + +.features .mdl-cell { + padding: 0 36px; +} +.features h2, .features-2 h2 { + padding-bottom: 24px; +} +.features-2 p { + padding: 0 200px; +} + + +@media (max-width: 1000px) { + .mdl-grid, #id2 h2 { + padding: 50px 0 0 0; + } + + .header .mdl-button { + width: 150px; + margin: 10px 100px; + } + + .header img, .features-2 img { + max-width: 300px; + } + + .features img { + max-width: 350px; + } + + .features-2 p { + padding: 0 24px; + } +} diff --git a/build/_static/gluon.css b/build/_static/gluon.css deleted file mode 100644 index 129c1426c..000000000 --- a/build/_static/gluon.css +++ /dev/null @@ -1,16 +0,0 @@ -code, .rst-content tt, .rst-content code { - font-size: 85%; -} - -.rst-content img { - display: block; - margin-left: auto; - margin-right: auto; -} - -.rst-content div.figure p.caption { - font-style: normal; - text-align: center; - margin-top: 10px; - font-size: 15px; -} diff --git a/build/_static/index.css b/build/_static/index.css deleted file mode 100755 index a65b59c71..000000000 --- a/build/_static/index.css +++ /dev/null @@ -1,223 +0,0 @@ -html, -body { - width: 100%; - height: 100%; -} - -body { - font-family: sans-serif; - -} - -a { - color: #447FB4; - -webkit-transition: all .35s; - transition: all .35s; -} - -a:hover, a:focus { - color: black; -} - -p { - font-size: 16px; - line-height: 1.5; - margin-bottom: 20px; -} - -section { - padding: 150px 0 0 0; -} - - -section h2 { - font-size: 38px; -} - - -section h3 { - font-size: 26px; -} - -/* header section */ -header.masthead { - position: relative; - width: 100%; - margin: 100px 0 0 0; - /* color: white; */ -} - -header.masthead img { - max-width: 350px; -} -header.masthead .header-content { - max-width: 500px; - margin-bottom: 100px; - text-align: center; -} - -header.masthead .header-content h1 { - font-size: 30px; - font-weight: 700; - letter-spacing: 2px; -} - -header.masthead .header-content p { - font-size: 24px; - padding: 0 0 20px; - letter-spacing: 1px; -} - -/* author section */ -section.authors .author-item { - max-width: 300px; - text-align: center; -} - -section.authors .author-item img { - width: 120px; -} - -section.authors .author-item h3 { - padding-top: 25px; - padding-bottom: 10px; -} - - -section.authors h3 { - padding-top: 25px; -} - -section.authors h4 { - padding-top: 20px; -} - - - -/* TOC */ - -section.toc .toc-content { - max-width: 600px; - margin-bottom: 50px; - text-align: center; -} - -section.toc .toc-content h2 { - padding-bottom: 30px; -} - -section.toc h3 { - padding-top: 20px; - padding-bottom: 15px; -} - -/* features */ - -section.features .features-content { - max-width: 600px; - margin-bottom: 50px; - text-align: center; -} - -section.features .features-content h2 { - padding-bottom: 30px; - font-size: 38px; -} - -section.features img { - width: 350px; -} - - - -/* notebook section */ -section.notebook img{ - max-width: 550px; -} - -section.notebook .content { - text-align: right; -} -section.notebook .content h2 { - padding: 0 30px 0 0px; - font-size: 38px; -} - -section.notebook .content p { - padding: 30px 30px 0 0px; -} -/* community */ - -section.community img{ - max-width: 550px; -} - -section.community .content { - text-align: left; -} -section.community .content h2 { - padding: 0 0 0 30px; - font-size: 38px; -} - -section.community .content p { - padding: 30px 0 0 30px; -} - - - -.btn-outline:hover, .btn-outline:focus, .btn-outline:active, .btn-outline.active { - /* color: white; */ - color: white; - background-color: #447FB4; -} - -.btn { - /* border-radius: 300px; */ - color: black; - border: 1px solid; - letter-spacing: 2px; - font-size: 14px; - padding: 10px 30px; - margin: 0px 10px; -} - -@media (max-width: 1000px) { - header.masthead { - margin-top: 50px; - } - header.masthead img { - max-width: 300px; - } - - header.masthead .header-content { - padding-top: 50px; - } - header.masthead .btn { - width: 150px; - margin: 10px 100px; - } - - section { - padding: 50px 0; - } - - - section.authors .author-item { - padding-top: 30px; - } - - section.features .feature-item { - padding-top: 25px; - } - - section.community .content, - section.notebook .content { - text-align: center; - padding: 25px 0; - } - section.notebook img, - section.community img { - max-width: 400px; - } -} diff --git a/build/build_doc.sh b/build/build_doc.sh deleted file mode 100644 index e4f04270a..000000000 --- a/build/build_doc.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# Build and publish all docs into Pulish all notebooks to mxnet. -set -x -set -e - -# Clean build/chapter*/*ipynb and build/chapter*/*md that are no longer needed. -cd build -for ch in chapter*; do - if ! [ -e "../$ch" ]; then - rm -rf $ch - else - shopt -s nullglob - for f in $ch/*.md $ch/*.ipynb; do - echo $f - base=$(basename $f) - md=${base%%.*}.md - if ! [ -e "../$ch/$md" ]; then - rm $f - fi - done - fi -done -cd .. - -# prepare the env -conda env update -f build/build.yml -conda activate gluon_zh_docs - -pip list - -rm -rf build/_build/ - -make html - -# avoid to put the downloaed data into the notebook package -mv build/data build/data-bak -make pkg -# backup build/data to avoid download the dataset each time and put the -rm -rf build/data -mv build/data-bak build/data - - -make pdf -cp build/_build/latex/gluon_tutorials_zh.pdf build/_build/html/ - -[ -e build/_build/latex/gluon_tutorials_zh.aux ] && rm build/_build/latex/gluon_tutorials_zh.aux -[ -e build/_build/latex/gluon_tutorials_zh.idx ] && rm build/_build/latex/gluon_tutorials_zh.idx - -# FOR 1.0 -cp build/_build/html/gluon_tutorials_zh.tar.gz build/_build/html/gluon_tutorials_zh-1.0.tar.gz -cp build/_build/html/gluon_tutorials_zh.zip build/_build/html/gluon_tutorials_zh-1.0.zip - - -# cd build && bash ipynb2mdd.sh && rm -rf _build/html/mdd.zip && cp mdd.zip _build/html/mdd.zip && cd .. - -aws s3 sync --delete build/_build/html/ s3://zh.gluon.ai/ --acl public-read -aws s3 sync --delete build/_build/html/ s3://zh.diveintodeeplearning.org/ --acl public-read diff --git a/build/build_html.sh b/build/build_html.sh new file mode 100755 index 000000000..2438301eb --- /dev/null +++ b/build/build_html.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -e +git submodule update --init +export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda/lib64 + +conda env update -f build/env.yml +conda activate d2l-zh-build + +pip list + +rm -rf build/_build/ + +make html diff --git a/build/build_pdf.sh b/build/build_pdf.sh new file mode 100755 index 000000000..4727d2a17 --- /dev/null +++ b/build/build_pdf.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +conda activate d2l-zh-build + +make pdf +cp build/_build/latex/d2l-zh.pdf build/_build/html/ diff --git a/build/conf.py b/build/conf.py index 7b8757bdc..a1beff7d7 100644 --- a/build/conf.py +++ b/build/conf.py @@ -69,10 +69,10 @@ def __init__(self, **options): #source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'toc' +master_doc = 'index' # General information about the project. -project = '动手学深度学习' +project = '《动手学深度学习》' copyright = '2017--2018, Contributors' author = "MXNet Community" @@ -102,7 +102,8 @@ def __init__(self, **options): # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**.ipynb_checkpoints'] +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**.ipynb_checkpoints', + 'mx-theme', 'sphinx_materialdesign_theme'] # The reST default role (used for this markup: `text`) to use for all # documents. @@ -136,7 +137,21 @@ def __init__(self, **options): # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'sphinx_rtd_theme' +# html_theme = 'sphinx_rtd_theme' + +html_theme_path = ['mx-theme'] +html_theme = 'sphinx_materialdesign_theme' +html_theme_options = { + 'primary_color': 'blue', + 'accent_color': 'deep_orange', + 'header_links' : [ + ('PDF', './d2l-zh.pdf', True, 'fas fa-download'), + ('论坛', 'https://discuss.gluon.ai/c/lecture?order=views', True, 'fab fa-discourse'), + ('Github', 'https://github.com/diveintodeeplearning/d2l-zh', True, 'fab fa-github'), + ('English Version', 'https://diveintodeeplearning.org', True, 'fas fa-external-link-alt'), + ], + 'show_footer': True +} # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -287,7 +302,7 @@ def __init__(self, **options): # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'gluon_tutorials_zh.tex', '动手学深度学习', + (master_doc, 'd2l-zh.tex', '动手学深度学习', author, 'manual'), ] @@ -372,4 +387,3 @@ def setup(app): }, True) app.add_javascript('baidu_tongji.js') app.add_javascript('google_analytics.js') - app.add_stylesheet('gluon.css') diff --git a/build/env.yml b/build/env.yml new file mode 100644 index 000000000..cf0abe8e9 --- /dev/null +++ b/build/env.yml @@ -0,0 +1,16 @@ +name: d2l-zh-build +dependencies: +- python==3.6 +- jupyter +- sphinx +- matplotlib +- pandas +- notebook +- pip: + - nbsphinx + - recommonmark + - https://github.com/mli/notedown/tarball/master + - mxnet-cu92==1.2.1 + - gluonbook==0.8.3 + - jieba + - awscli diff --git a/build/frontpage.html b/build/frontpage.html new file mode 100644 index 000000000..203cb7f9b --- /dev/null +++ b/build/frontpage.html @@ -0,0 +1,91 @@ + + +
+
+ +
+
+

《动手学深度学习》

+

一本面向在校学生、工程师和研究人员的
交互式深度学习书籍

+ + +
+
+ +
+
+
+ +

阿斯顿·张

+

亚马逊应用科学家,美国伊利诺伊大学香槟分校计算机科学博士。

+
+
+
+
+ +

李沐

+

亚马逊首席科学家,美国卡内基梅隆大学计算机系博士。

+
+
+
+
+ +

扎卡里 C. 立顿

+

亚马逊应用科学家,美国卡内基梅隆大学助理教授,加州大学圣迭戈分校计算机科学博士。

+
+
+
+
+ +

亚历山大 J. 斯莫拉

+

亚马逊机器学习总监,德国柏林工业大学计算机科学博士。

+
+
+

以及来自社区的 100+ 位贡献者

+

成为贡献者,你将会获得专享版赠书并被致谢

+
+ +
+
+
+

每一小节都是可以运行的 Jupyter 记事本

+

你可以自由修改代码和超参数来获取及时反馈,从而积累深度学习的实战经验。

+
+
+
+ +
+
+ +
+

公式 + 图示 + 代码

+

我们不仅结合文字、公式和图示来阐明深度学习里常用的模型和算法,还提供代码来演示如何从零开始实现它们,并使用真实数据来提供一个交互式的学习体验。

+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+

活跃社区支持

+

你可以通过每个章节最后的链接来同社区的数千名小伙伴一起讨论学习。

+
+
+
diff --git a/build/index.html b/build/index.html deleted file mode 100644 index 07917050b..000000000 --- a/build/index.html +++ /dev/null @@ -1,214 +0,0 @@ - - - - - - - - - - 动手学深度学习 Dive into Deep Learning - - - - - - - - -
-
-
-
- -
-
-
-

《动手学深度学习》

-

一本面向在校学生、工程师和研究人员的交互式深度学习书籍

- 在线阅读 - PDF - GITHUB - -
-
-
-
-
- -
-
-
-
-
- -

阿斯顿·张

-

亚马逊应用科学家。美国伊利诺伊大学香槟分校计算机科学博士。

-
-
- -
-
- -

李沐

-

亚马逊首席科学家。美国卡内基梅隆大学计算机系博士。

-
-
- -
-
- -

扎卡里 C. 立顿

-

亚马逊应用科学家。美国卡内基梅隆大学助理教授。加州大学圣迭戈分校计算机科学博士。

-
-
- -
-
- -

亚历山大 J. 斯莫拉

-

亚马逊机器学习总监。德国柏林工业大学计算机科学博士。

-
-
-
-

以及来自社区的 100+ 位贡献者

-

成为贡献者,你将会获得专享版赠书并被致谢

-
-
- - -
-
-
-
-
-

每一小节都是可以运行的 Jupyter 记事本

-

你可以自由修改代码和超参数来获取及时反馈,从而积累深度学习的实战经验。 -

-
-
-
- -
-
-
-
-
- -
-
-
-

公式 + 图示 + 代码

-

我们不仅结合文字、公式和图示来阐明深度学习里常用的模型和算法,还提供代码来演示如何从零开始实现它们,并使用真实数据来提供一个交互式的学习体验。

-
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-

活跃社区支持

-

你可以通过每个章节最后的链接来同社区的数千名小伙伴一起讨论学习。

-
-
-
-
-
- -
-
-
-

结合算法与实践

-

我们将从头开始解释深度学习和机器学习的各个概念,你无需具备这些背景知识。我们的目标是让你在完成学习后不但能从概念上理解深度学习,而且能将它应用到实际项目和研究之中。

-
-
-
-

引言 · 预备知识

-

▹ 深度学习简介 ▹ 如何使用本书 ▹ 获取和运行本书代码 -▹ 数据操作 ▹ 自动求梯度 ▹ 查阅 MXNet 文档

-
-
-

深度学习基础

-

▹ 线性回归 ▹ Softmax 回归 ▹ 多层感知机 ▹ - 模型选择 ▹ 权重衰减 ▹ 丢弃法 ▹ 正向、反向传播 ▹ - 模型初始化 ▹ Kaggle 实战 :房价预测

-
-
-

深度学习计算

-

▹ 模型构造 ▹ 模型参数的访问、初始化和共享 ▹ - 模型参数的延后初始化 ▹ 自定义层 ▹ 读取和存储 ▹ GPU 计算

-
-
-

卷积神经网络

-

▹ 二维卷积层 ▹ 填充和步幅 ▹ 多输入通道和多输出通道 - ▹ 池化层▹ LeNet ▹ AlexNet ▹ VGG ▹ - NiN ▹ GoogLeNet ▹ 批量归一化 ▹ ResNet ▹ - DenseNet

-
-
-

循环神经网络

-

▹ 语言模型 ▹ 循环神经网络 ▹ 通过时间反向传播 - ▹ GRU ▹ LSTM ▹ 深度循环神经网络 ▹ 双向循环神经网络

-
-
-

优化算法

-

▹ 优化与深度学习 ▹ 梯度下降和随机梯度下降 ▹ - 小批量随机梯度下降 ▹ 动量法 ▹ Adagrad ▹ RMSProp ▹ - Adadelta ▹ Adam

-
-
-

计算性能

-

▹ 命令式和符号式混合编程 ▹ 异步计算 ▹ - 自动并行计算 ▹ 多 GPU 计算

-
-
-

计算机视觉

-

▹ 图像增广 ▹ 微调 ▹ 物体检测和边界框 ▹ - 锚框 ▹ SSD ▹ R-CNN 系列 - ▹ FCN ▹ 样式 迁移 ▹ Kaggle 实战:CIFAR-10 - ▹ Kaggle 实战:ImageNet Dogs -

-
-
-

自然语言处理

-

▹ word2vec ▹ fastText ▹ GloVe ▹ - 求近义词和类比词 ▹ 文本情感分类 ▹ seq2seq ▹ - 束搜索 ▹ 注意力机制 ▹ 机器翻译

-
-
-
- -
- - - - - - - - diff --git a/build/toc.rst b/build/index.rst similarity index 82% rename from build/toc.rst rename to build/index.rst index b8024fade..a22575b52 100644 --- a/build/toc.rst +++ b/build/index.rst @@ -1,5 +1,11 @@ +《动手学深度学习》 +==================== + +.. raw:: html + :file: frontpage.html + 目录 -=============== +----- .. toctree:: :maxdepth: 2 diff --git a/build/mx-theme b/build/mx-theme new file mode 160000 index 000000000..139159749 --- /dev/null +++ b/build/mx-theme @@ -0,0 +1 @@ +Subproject commit 13915974942cfeb8c2d0754b96a5f697f89c8ad0 diff --git a/chapter_appendix/notation.md b/chapter_appendix/notation.md index 5257702c5..867fbd86e 100644 --- a/chapter_appendix/notation.md +++ b/chapter_appendix/notation.md @@ -55,14 +55,6 @@ |$\nabla_{\cdot} y$|$y$关于$\cdot$的梯度| -## 概率和统计 - -||| -|:--|:-:| -|$\mathbb{P}(\cdot)$|概率分布| -|$\cdot \sim \mathbb{P}$|随机变量$\cdot$的概率分布是$\mathbb{P}$| -|$\mathbb{P}(\cdot \mid \cdot)$|条件概率分布| -|$\mathbb{E}_\cdot\left(f(\cdot)\right)$|函数$f(\cdot)$对$\cdot$的数学期望| ## 复杂度 diff --git a/chapter_natural-language-processing/fasttext.md b/chapter_natural-language-processing/fasttext.md index 92d95b4b2..2c31b45da 100644 --- a/chapter_natural-language-processing/fasttext.md +++ b/chapter_natural-language-processing/fasttext.md @@ -6,9 +6,9 @@ 在fastText中,每个中心词被表示成子词的集合。下面我们用单词“where”作为例子来了解子词是如何产生的。首先,我们在单词的首尾分别添加特殊字符“<”和“>”以区分作为前后缀的子词。然后,将单词当成一个由字符构成的序列来提取$n$元语法。例如当$n=3$时,我们得到所有长度为3的子词: -$$\textrm{``"},$$ +$$\textrm{},$$ -以及特殊子词$\textrm{``"}$。 +以及特殊子词$\textrm{}$。 在fastText中,对于一个词$w$,我们将它所有长度在3到6的子词和特殊子词的并集记为$\mathcal{G}_w$。那么词典则是所有词的子词集合的并集。假设词典中子词$g$的向量为$\boldsymbol{z}_g$,那么跳字模型中词$w$的作为中心词的向量$\boldsymbol{v}_w$则表示成 diff --git a/chapter_natural-language-processing/glove.md b/chapter_natural-language-processing/glove.md index 78d098358..8cff9dc94 100644 --- a/chapter_natural-language-processing/glove.md +++ b/chapter_natural-language-processing/glove.md @@ -43,8 +43,8 @@ $$\sum_{i\in\mathcal{V}} \sum_{j\in\mathcal{V}} h(x_{ij}) \left(\mathbf{u}_j^\to |$w_k$=|“solid”|“gas”|“water”|“fashion”| |--:|:-:|:-:|:-:| -|$p_1=\mathbb{P}(w_k\mid\text{``ice"})$|0.00019|0.000066|0.003|0.000017| -|$p_2=\mathbb{P}(w_k\mid\text{``steam"})$|0.000022|0.00078|0.0022|0.000018| +|$p_1=\mathbb{P}(w_k\mid\text{"ice"})$|0.00019|0.000066|0.003|0.000017| +|$p_2=\mathbb{P}(w_k\mid\text{"steam"})$|0.000022|0.00078|0.0022|0.000018| |$p_1/p_2$|8.9|0.085|1.36|0.96| 我们可以观察到以下现象: