diff --git a/ch-data-science/data-science-lifecycle.ipynb b/ch-data-science/data-science-lifecycle.ipynb index bc44636..b420a69 100644 --- a/ch-data-science/data-science-lifecycle.ipynb +++ b/ch-data-science/data-science-lifecycle.ipynb @@ -11,7 +11,7 @@ "\n", "```{figure} ../img/ch-data-science/data-science-lifecycle.svg\n", "---\n", - "width: 400px\n", + "width: 600px\n", "name: fig-data-science-lifecycle\n", "---\n", "数据科学生命周期\n", @@ -62912,7 +62912,7 @@ "网络上的开源数据往往已经被处理过,实际业务场景的数据准备难度比开源数据大很多。\n", "因此,数据准备是最耗时的步骤,它可能会占整个项目时间的 70%-90%,然而它是整个数据科学生命周期中最重要的步骤。\n", "\n", - "在房价预测这个场景下,当前我们使用的这个开源数据集的特征只有 8 列。为了更好地做这个任务,应该挖掘更多的信息,包括房屋面积等更详细的信息。如果能从其他数据源获取的数据,并将这些数据融合,能显著提升最终要过,但数据融合需要进行数据清洗和对齐工作。\n", + "在房价预测这个场景下,当前我们使用的这个开源数据集的特征只有 8 列。为了更好地做这个任务,应该挖掘更多的信息,包括房屋面积等更详细的信息。如果能从其他数据源获取数据,并将这些数据融合,能显著提升最终要过,但数据融合需要进行数据清洗和对齐工作。\n", "\n", "数据的预处理非常依赖数据分析师的经验,这里不仔细展开讲解。现在我们只对数据进行切分,分为训练集和测试集。" ] @@ -62926,7 +62926,8 @@ "from sklearn.model_selection import train_test_split\n", "\n", "X_train, X_test, y_train, y_test = train_test_split(cal.data,\n", - " cal.target, random_state=11)" + " cal.target, \n", + " random_state=11)" ] }, { diff --git a/ch-data-science/deep-learning.md b/ch-data-science/deep-learning.md index 149416a..efa6fd0 100644 --- a/ch-data-science/deep-learning.md +++ b/ch-data-science/deep-learning.md @@ -14,11 +14,11 @@ $$ $\boldsymbol{x}$ 是输入,$\boldsymbol{W}$ 是神经网络的参数,又被称为权重。神经网络的学习的过程,就是不断更新参数 $\boldsymbol{W}$ 的过程,这也是所谓的训练过程。训练好的模型可以用来推理,用来预测未知数据。 -$f$ 是激活函数(Activation Function)。$\boldsymbol{W}$ 与 $\boldsymbol{x}$ 相乘仅是一个线性变换,就算很多个乘法叠加起来,仍然是线性变换,或者说没有激活函数的多层网络就退化成了一个单层线性模型。激活函数可以在神经网络中引入了非线性因素,使得多层神经网络理论上可以拟合任何输入数据到输出数据的模式。从模拟生物的神经元的角度,激活函数是为了让有些神经元被激活,有些神经元被抑制。常见的激活函数有 Sigmoid 和 ReLU。{numref}`sec-machine-learning-intro` 我们对 Sigmod 进行过可视化,ReLU 的公式为:$f(x) = \max (0, x)$。 +$f$ 是激活函数(Activation Function)。$\boldsymbol{W}$ 与 $\boldsymbol{x}$ 相乘仅是一个线性变换,就算很多个乘法叠加起来,仍然是线性变换,或者说没有激活函数的多层网络就退化成了一个单层线性模型。激活函数可以在神经网络中引入了非线性因素,使得多层神经网络理论上可以拟合任何输入数据到输出数据的模式。从模拟生物神经元的角度,激活函数是为了让有些神经元被激活,有些神经元被抑制。常见的激活函数有 Sigmoid 和 ReLU。{numref}`sec-machine-learning-intro` 我们对 Sigmod 进行过可视化,ReLU 的公式为:$f(x) = \max (0, x)$。 ## 前向传播 -{numref}`fig-forward-pass` 是一种最简单的神经网络:将 $\boldsymbol{z^{[n]}} = \boldsymbol{W^{[n]}} \cdot \boldsymbol{a^{[n-1]}} + \boldsymbol{b^{[n]}}$ 和 $\boldsymbol{a^{[n]}} = f(\boldsymbol{z^{[n]}})$ 堆叠,前一层的输出 $\boldsymbol{a^{[n-1]}}$ 作为下一层的输入。这种网络又被成为前馈神经网络(Feedforward Neural Network),或者多层感知机(Multilayer Perceptron,MLP)。多层网络中,为了区分某一层,用方括号上标来表示,比如 $\boldsymbol{a^{[1]}}$ 是第一层的输出,$\boldsymbol{W^{[1]}}$ 是第一层的参数。 +{numref}`fig-forward-pass` 是一种最简单的神经网络:将 $\boldsymbol{z^{[n]}} = \boldsymbol{W^{[n]}} \cdot \boldsymbol{a^{[n-1]}} + \boldsymbol{b^{[n]}}$ 和 $\boldsymbol{a^{[n]}} = f(\boldsymbol{z^{[n]}})$ 堆叠,前一层的输出 $\boldsymbol{a^{[n-1]}}$ 作为下一层的输入。这种网络又被称为前馈神经网络(Feedforward Neural Network),或者多层感知机(Multilayer Perceptron,MLP)。多层网络中,为了区分某一层,用方括号上标来表示,比如 $\boldsymbol{a^{[1]}}$ 是第一层的输出,$\boldsymbol{W^{[1]}}$ 是第一层的参数。 ```{figure} ../img/ch-data-science/forward-pass.svg --- @@ -61,7 +61,7 @@ name: fig-back-propagation ## 超参数 -神经网络训练过程中,有很多训练模型之前需要人为设定的一些参数,这些参数不能通过模型的反向传播算法来自动学习,而需要手动选择和调整。这些参数又被成为超参数(Hyperparameter),超参数的选择通常基于经验或反复试验。以下是一些超参数: +神经网络训练过程中,有一些需要人为设定的参数,这些参数不能通过模型的反向传播算法来自动学习,而需要手动选择和调整。这些参数又被成为超参数(Hyperparameter),超参数的选择通常基于经验或反复试验。以下是一些超参数: * 学习率,即刚才提到的 $\alpha$,控制着每次更新参数的步长。 * 网络结构:模型的层数、每层的神经元数量、激活函数的选择等。不同的网络结构对于不同的任务可能有不同的性能表现。 @@ -84,26 +84,40 @@ name: fig-model-training-input-output 前向传播、反向传播和更新模型权重的输入和输出 ``` -对于前向传播,输入有两部分:i-1 层输出 $\boldsymbol{a^{[i-1]}}$ 和第 i 层的模型权重 $\boldsymbol{W^{[i]}}$、$\boldsymbol{b^{[i]}}$;输出又被称为激活(Activation)。 +### 前向传播 -对于反向传播,输入有三部分:i 层输出 $\boldsymbol{a^{[i]}}$;第 i 层的模型权重 $\boldsymbol{W^{[i]}}$、$\boldsymbol{b^{[i]}}$;损失对 i 层输出的导数 $\boldsymbol{\boldsymbol{\frac{\partial L}{a^{[i]}}}}$。根据链式法则,可以求出损失对 i 层模型权重的导数 $\boldsymbol{\frac{\partial L}{\partial W^{[i]} +- **输入:** +对于前向传播,输入有两部分:i-1 层输出 $\boldsymbol{a^{[i-1]}}$ 和第 i 层的模型权重 $\boldsymbol{W^{[i]}}$、$\boldsymbol{b^{[i]}}$ + +- **输出:** +输出又被称为激活(Activation),是权重与输出相乘之后,经过激活函数的结果。 + +### 反向传播 + +- **输入:** +对于反向传播,输入有三部分:i 层输出 $\boldsymbol{a^{[i]}}$;第 i 层的模型权重 $\boldsymbol{W^{[i]}}$、$\boldsymbol{b^{[i]}}$;损失对 i 层输出的导数 $\boldsymbol{\boldsymbol{\frac{\partial L}{a^{[i]}}}}$。 + +- **输出:** +根据链式法则,可以求出损失对 i 层模型权重的导数 $\boldsymbol{\frac{\partial L}{\partial W^{[i]} }}$、$\boldsymbol{\frac{\partial L}{\partial b^{[i]} }}$,也就是梯度。 +### 更新模型权重 + 得到梯度后,需要沿着梯度下降的方向更新模型权重。如果是最简单的梯度下降法,优化器直接在模型原有权重基础上做减法,不需要额外保存状态,比如:$\boldsymbol{W^{[l]}} = \boldsymbol{W^{[l]}}-\alpha\frac{\partial L}{\partial \boldsymbol{W^{[l]}}}$ -复杂一点的优化器,比如 Adam, 在梯度下降时引入了动量的概念。动量是梯度的指数移动平均,需要维护一个梯度的移动平均矩阵,这个矩阵就是优化器的状态。因此,优化器状态、原来的模型权重和梯度共同作为输入,可以得到更新后的模型权重。至此才能完成一轮模型的训练。 +复杂一点的优化器,比如 Adam {cite}`kingma2015Adam`, 在梯度下降时引入了动量的概念。动量是梯度的指数移动平均,需要维护一个梯度的移动平均矩阵,这个矩阵就是优化器的状态。因此,优化器状态、原来的模型权重和梯度共同作为输入,可以得到更新后的模型权重。至此才能完成一轮模型的训练。 -如果只考虑前向传播和反向传播,对于一个神经网络,其训练过程如 {numref}`fig-model-training` 所示。{numref}`fig-model-training` 演示了 3 层神经网络,前向过程用 FWD 表示,反向过程用 BWD 表示。 +对于一个神经网络,其训练过程如 {numref}`fig-model-training` 所示。{numref}`fig-model-training` 演示了 3 层神经网络,前向过程用 FWD 表示,反向过程用 BWD 表示。 ```{figure} ../img/ch-data-science/model-training.svg --- -width: 800px +width: 600px name: fig-model-training --- -前向传播(图中用 FWD 表示)和反向传播(图中用 BWD 表示) +前向传播(图中用 FWD 表示)、反向传播(图中用 BWD 表示)和更新模型权重 ``` ## 推理 -模型训练就是前向和反向传播,模型推理只需要前向传播,只不过输入层换成了需要预测的 $\boldsymbol{x}$。 \ No newline at end of file +模型训练是前向和反向传播,模型推理只需要前向传播,只不过输入层换成了需要预测的 $\boldsymbol{x}$。 \ No newline at end of file diff --git a/ch-data-science/machine-learning.ipynb b/ch-data-science/machine-learning.ipynb index 457f0e7..6741ebb 100644 --- a/ch-data-science/machine-learning.ipynb +++ b/ch-data-science/machine-learning.ipynb @@ -21,11 +21,11 @@ "\n", "### 一元线性回归\n", "\n", - "我们从线性回归开始,了解机器学习模型的数学原理。中学时,我们使用 $ y = ax + b $ 对很多问题进行建模,方程描述了变量 $y$ 随着变量 $x$ 而变化。方程是一条直线。如果建立好这样的数学模型,已知 $x$ 我们就可以得到预测的 $\\hat{y}$ 了。统计学家给变量 $y$ 带上了一个小帽子,表示这是预测值,以区别于真实观测到的数据。方程只有一个自变量 $x$,且不含平方立方等非一次项,因此被称为 ** 一元线性方程 **。\n", + "我们从线性回归开始,了解机器学习模型的数学原理。中学时,我们使用 $ y = ax + b $ 对很多问题进行建模,方程描述了变量 $y$ 随着变量 $x$ 而变化。方程是一条直线。如果建立好这样的数学模型,已知 $x$ 我们就可以得到预测的 $\\hat{y}$ 了。统计学家给变量 $y$ 带上了一个小帽子,表示这是预测值,以区别于真实观测到的数据。方程只有一个自变量 $x$,且不含平方立方等非一次项,因此被称为**一元线性方程**。\n", "\n", - "在对数据集进行建模时,我们只关注房屋面积和房价两个维度的数据。我们可以对参数 $a$ 和 $b$ 取不同值来构建不同的直线,这样就形成了一个参数家族。参数家族中有一个最佳组合,可以在统计上以最优的方式描述数据集。那么一元线性回归的监督学习过程就可以被定义为:给定 $m$ 个数据对 $(x, y)$ ,寻找最佳参数 $a^*$ 和 $b^*$,使模型可以更好地拟合这些数据。$a$ 和 $b$ 可以取不同的参数,到底哪个参数组合是最佳的呢?如何衡量模型是否以最优的方式拟合数据呢?机器学习用损失函数(Loss Function)的来衡量这个问题。损失函数又称为代价函数(Cost Function),它计算了模型预测值 $\\hat{y}$ 和真实值 $y$ 之间的差异程度。从名字也可以看出,这个函数计算的是模型犯错的损失或代价,损失函数越大,模型越差,越不能拟合数据。统计学家通常使用 $L(\\hat{y}, y)$ 来表示损失函数。\n", + "在对数据集进行建模时,我们从最简单的开始,只关注房屋面积($x$)和房价($y$)两个维度的数据。我们可以对参数 $a$ 和 $b$ 取不同值来构建不同的直线,这样就形成了一个参数家族。参数家族中有一个最佳组合,可以在统计上以最优的方式描述数据集。那么一元线性回归的监督学习过程就可以被定义为:给定 $m$ 个数据对 $(x, y)$ ,寻找最佳参数 $a^*$ 和 $b^*$,使模型可以更好地拟合这些数据。$a$ 和 $b$ 可以取不同的参数,到底哪个参数组合是最佳的呢?如何衡量模型是否以最优的方式拟合数据呢?机器学习用损失函数(Loss Function)的来衡量这个问题。损失函数又称为代价函数(Cost Function),它计算了模型预测值 $\\hat{y}$ 和真实值 $y$ 之间的差异程度。从名字也可以看出,这个函数计算的是模型犯错的损失或代价,损失函数越大,模型越差,越不能拟合数据。统计学家通常使用 $L(\\hat{y}, y)$ 来表示损失函数。\n", "\n", - "对于线性回归,一个简单实用的损失函数为预测值与真实值误差平方的平均值,下面公式中,$(i)$ 表示数据集中的第 $i$ 个样本点:\n", + "对于线性回归,一个简单实用的损失函数为预测值与真实值误差平方的平均值,下面公式中,$i$ 表示数据集中的第 $i$ 个样本点:\n", "\n", "$$\n", "L(\\hat{y}, y) = \\frac{1}{m} \\sum_{i=1}^m(\\hat{y}_{i}- y_{i})^2\n", @@ -43,7 +43,7 @@ "a^*, b^* = \\mathop{\\arg\\min}_{a, b}L(a, b)\n", "$$\n", "\n", - "式中 $\\arg\\min$ 是一种常见的数学符号,表示寻找能让 $L$ 函数最小的参数 $a*$ 和 $b*$。\n", + "式中 $\\arg\\min$ 是一种常见的数学符号,表示寻找能让 $L$ 函数最小的参数 $a^*$ 和 $b^*$。\n", "\n", "$$\n", "a^*, b^* = \\mathop{\\arg\\min}_{a, b}\\frac{1}{m}\\sum_{i=1}^m[(ax_{i} + b) - y_{i}]^2\n", @@ -53,23 +53,23 @@ "求解这个函数一般有两个方法:\n", "\n", "* 基于微积分和线性代数知识,求使得 $L$ 导数为 0 的点,这个点一般为最优点。这种方式只能解那些简单的模型。\n", - "* 基于梯度下降,迭代地搜索最优点。梯度下降法能解很多复杂复杂的模型,比如深度学习模型,{numref}`sec-deep-learning-intro` 进一步解释了梯度下降法。\n", + "* 基于梯度下降,迭代地搜索最优点。梯度下降法能解很多复杂的模型,比如深度学习模型,{numref}`sec-deep-learning-intro` 进一步解释了梯度下降法。\n", "\n", "### 线性回归的一般形式\n", "\n", - "我们现在把回归问题扩展到更为一般的场景。假设 $\\boldsymbol{x}$ 是多元的,或者说是多维的。比如,要预测房价,需要考虑的因素很多,包括学区、卧室数量(两居、三居、四居)、周边商业、交通等。如下面公式所示,每个因素是一个 $w$:\n", + "我们现在把回归问题扩展到更为一般的场景。假设 $\\boldsymbol{x}$ 是多元的,或者说是多维的。比如,要预测房价,需要考虑的因素很多,包括学区、卧室数量(两居、三居、四居)、周边商业、交通等。如下面公式所示,每个因素是一个 $W$:\n", "\n", "$$\n", "f(\\boldsymbol{x}) = b + W_1 \\times x_1 + W_2 \\times x_2 + ... + W_n \\times x_n\n", "$$\n", "\n", - "这里的 $\\boldsymbol{w}$ 是 **参数**(Parameter),也可以叫做 **权重**(Weight)。这里共有 $n$ 种维度的影响因素,机器学习领域将这 $n$ 种影响因素称为 **特征**(Feature)。用向量表示为:\n", + "$W$ 是 **参数**(Parameter),也可以叫做 **权重**(Weight)。这里共有 $n$ 种维度的影响因素,机器学习领域将这 $n$ 种影响因素称为**特征**(Feature)。用向量表示为:\n", "\n", "$$\n", "f(\\boldsymbol{x}) = b + \\boldsymbol{W} \\boldsymbol{{x}}\n", "$$\n", "\n", - "要预测的 $y$ 是实数,从负无穷到正无穷,预测实数模型被称为**回归模型**。\n", + "要预测的 $y$ 是实数,从负无穷到正无穷,预测实数的模型被称为**回归模型**。\n", "\n", "## 逻辑回归\n", "\n", diff --git a/ch-data-science/python-ecosystem.md b/ch-data-science/python-ecosystem.md index 4d5b6b8..4deb019 100644 --- a/ch-data-science/python-ecosystem.md +++ b/ch-data-science/python-ecosystem.md @@ -1,5 +1,7 @@ -(sec-python-ecosystem)= -# Python 软件生态 +(sec-ecosystem)= +# 软件生态与本书内容 + +## Python 软件生态 Python 已经成为数据科学首选的编程语言。{numref}`fig-python-ecosystem-img` 是一些主流的数据科学工具: @@ -15,8 +17,22 @@ name: fig-python-ecosystem-img Python 数据科学软件生态 ``` -Dask、Ray、Xorbits 和 mpi4py 是对数据科学生态的拓展。本书假设读者对以上软件生态有一定了解,读者也可以阅读以下书籍深入理解这些软件工具: +## 本书内容 + +本书假定读者已经对数据科学有所了解,已经使用过 pandas、XGBoost、PyTorch 等 Python 数据科学软件,希望使用一些工具加速数据科学,如果对数据科学不熟悉,可以阅读以下书籍。 * Wes McKinney(pandas 项目发起人)撰写的《利用 Python 进行数据分析》 {cite}`mckinney2022python` 是一本非常优秀的数据科学入门书籍,也是 pandas 框架的入门书籍。 * 周志华老师的《机器学习》 {cite}`zhou2016machine` 是机器学习理论的入门教科书,是了解绝大多数机器学习算法的必备书籍。 -* 亚马逊科学家阿斯顿·张、李沐等人的《动手学深度学习》 {cite}`zhang2019dive` 从算法原理到编程实践,深入浅出地讲解了常见人工智能算法及其应用,是入门深度学习的最佳实战书籍。 \ No newline at end of file +* 亚马逊科学家阿斯顿·张、李沐等人的《动手学深度学习》 {cite}`zhang2019dive` 从算法原理到编程实践,深入浅出地讲解了常见人工智能算法及其应用,是入门深度学习的最佳实战书籍。 + +Dask、Ray、Xorbits 和 mpi4py 是对数据科学生态的拓展,将单机任务横向扩展到集群。这些框架有很多组件,{numref}`tab-lifecycle-module` 概括了这些框架组件所对应的数据科学生命周期、 + +```{table} 数据科学生命周期与框架组件 +:name: tab-lifecycle-module +|生命周期|框架组件| +|---|---| +|数据处理|Dask DataFrame、Dask Array、Ray Data、Modin、Xorbits Data| +|模型训练|Dask-ML、Ray Train、RLib、mpi4py| +|超参数调优|Dask-ML、Ray Tune| +|模型部署|Ray Serve、Xinference| +``` \ No newline at end of file diff --git a/ch-parallel-computing/computer-architecture.md b/ch-parallel-computing/computer-architecture.md index c19093b..9014239 100644 --- a/ch-parallel-computing/computer-architecture.md +++ b/ch-parallel-computing/computer-architecture.md @@ -3,7 +3,7 @@ 大数据与人工智能应用对算力要求极高,为应对飞速增长的算力需求,芯片与硬件厂商近年来重点发展多核、集群(Cluster)和异构计算(Heterogeneous Computing)。{numref}`fig-computer-arch` 展示了现代计算机的体系结构。 -```{figure} ../img/ch-intro/computer-arch.svg +```{figure} ../img/ch-parallel-computing/computer-arch.svg --- width: 600px name: fig-computer-arch diff --git a/ch-parallel-computing/parallel-program-design.md b/ch-parallel-computing/parallel-program-design.md index 2890ce0..a41ac88 100644 --- a/ch-parallel-computing/parallel-program-design.md +++ b/ch-parallel-computing/parallel-program-design.md @@ -5,7 +5,7 @@ 如何设计软件和算法,使得程序可以并行运行在多核或者集群上?早在 1995 年,Ian Foster 在其书中提出了 PCAM 方法 {cite}`foster1995designing`,其思想可以用来指导并行算法的设计。PCAM 主要有四个步骤:切分(Partitioning)、通信(Communication)、聚集(Agglomeration)和分发(Mapping);{numref}`fig-pcam-img` 展示了这四个步骤。 -```{figure} ../img/ch-intro/pcam.svg +```{figure} ../img/ch-parallel-computing/pcam.svg --- width: 400px name: fig-pcam-img @@ -36,9 +36,9 @@ PCAM 方法 Google 2004 年提出 MapReduce {cite}`dean2004MapReduce`,这是一种典型的大数据并行计算范式。{numref}`fig-map-reduce` 展示了使用 MapReduce 进行词频统计的处理方式。 -```{figure} ../img/ch-intro/map-reduce.svg +```{figure} ../img/ch-parallel-computing/map-reduce.svg --- -width: 600px +width: 800px name: fig-map-reduce --- MapReduce 进行词频统计 diff --git a/ch-parallel-computing/performance-metrics.md b/ch-parallel-computing/performance-metrics.md index 689fada..1d96f18 100644 --- a/ch-parallel-computing/performance-metrics.md +++ b/ch-parallel-computing/performance-metrics.md @@ -8,12 +8,12 @@ 传统的高性能计算经常使用 FLOPS(Floating Point OPerations per Second)来衡量软硬件的性能。 :::{note} -所谓浮点数,指的是计算机一定比特位数来表示小数。用更多的比特位数,数值越精确,精度越高,但计算的成本越高。业界已经形成了一些标准,电气电子工程师学会(Institute of Electrical and Electronics Engineers, IEEE)定义了 16 位浮点数(FP16)、32 位浮点数(FP32)和 64 位浮点数(FP64)在计算机中的表示方法。大部分科学计算任务需要 FP64,深度学习等任务只需要 FP32、FP16 甚至更低。严格意义上来讲,需要明确是 FP32 还是 FP64 精度下的 FLOPS。因为不同硬件所能提供的 FP32 和 FP64 算力有很大差异。 +所谓浮点数,指的是计算机一定比特位数来表示小数。比特位数越高,数值越精确,精度越高,但计算的成本越高。业界已经形成了一些标准,电气电子工程师学会(Institute of Electrical and Electronics Engineers, IEEE)定义了 16 位浮点数(FP16)、32 位浮点数(FP32)和 64 位浮点数(FP64)在计算机中的表示方法。大部分科学计算任务需要 FP64,深度学习等任务只需要 FP32、FP16 甚至更低。严格意义上来讲,需要明确是 FP32 还是 FP64 精度下的 FLOPS。因为不同硬件所能提供的 FP32 和 FP64 算力有很大差异。 ::: FLOPS 指每秒钟能够完成多少次浮点计算。如果进行一个 $n$ 维向量加法:$a + b$,所需的浮点计算次数为 $n$。将浮点计算次数除以时间,就是 FLOPS。 -FLOPS 指标既依赖于硬件性能,也与软件和算法高度相关。{numref}`sec-thread-process` 提到线程安全问题,{numref}`sec-serial-parallel` 中有任务分发的过程,如果软件算法设计不够好,大量计算资源闲置,应用程序的 FLOPS 可能很低。 +FLOPS 指标既依赖于硬件性能,也与软件和算法高度相关。{numref}`sec-thread-process` 提到线程安全问题,{numref}`sec-serial-parallel` 提到任务分发调度,如果软件算法设计不够好,大量计算资源闲置,应用程序的 FLOPS 可能很低。 ## 加速比 @@ -33,6 +33,6 @@ $$ 其中 $N$ 为并行程序所使用的计算核心的数目。当加速比为 $N$ 时,串行程序可以被线性拓展到多个计算核心上,可以说并行程序获得了*线性加速比*。 -线性加速比是最理想的情况,实际上很难达到。{numref}`sec-serial-parallel` 中的示意图中可以看到,并行程序需要有 Scheduler 将不同的任务分发到多个 Worker 上,多个 Worker 之间还要通信。 +线性加速比是最理想的情况,实际上很难达到。并行程序需要有调度器将不同的任务分发到多个 Worker 上,多个 Worker 之间还要通信,数据在多个 Worker 之间需要同步。 -另外,在使用 GPU 时,计算效率指标的 $N$ 取值应该是多少也有一定争议。GPU 上的计算核心成千上万,我们很难在一个 GPU 计算核心上测试得到 $t_s$;GPU 与 CPU 是协同工作的,计算加速比或效率时,是否要把 CPU 考虑进来? \ No newline at end of file +另外,在使用 GPU 时,计算效率指标的 $N$ 取值为是多少也有一定争议。GPU 上的计算核心成千上万,我们很难在一个 GPU 计算核心上测试得到 $t_s$;GPU 与 CPU 是协同工作的,计算加速比或效率时,是否要把 CPU 考虑进来?目前还没有共识。 \ No newline at end of file diff --git a/ch-parallel-computing/serial-parallel.md b/ch-parallel-computing/serial-parallel.md index a380d62..b411dfa 100644 --- a/ch-parallel-computing/serial-parallel.md +++ b/ch-parallel-computing/serial-parallel.md @@ -3,9 +3,9 @@ 如果不对计算任务(Task)进行并行加速,大部分计算任务是串行执行的,即 {numref}`fig-serial-timeline` 所示。这里的 Worker 可以是一个计算核心,也可以是集群中的一个节点。 -```{figure} ../img/ch-intro/serial-timeline.svg +```{figure} ../img/ch-parallel-computing/serial-timeline.svg --- -width: 600px +width: 800px name: fig-serial-timeline --- 串行执行的时间轴示意图 @@ -13,9 +13,9 @@ name: fig-serial-timeline 集群和异构计算提供了更多可利用的计算核心,并行计算将计算任务分布到多个 Worker 上,如 {numref}`fig-distributed-timeline` 所示。无论是在单机多核编程,还是在集群多机,都需要一个调度器(Scheduler)将计算任务分布到不同的 Worker 上。随着更多 Worker 参与,任务总时间缩短,节省的时间可用于其他任务。 -```{figure} ../img/ch-intro/distributed-timeline.svg +```{figure} ../img/ch-parallel-computing/distributed-timeline.svg --- -width: 600px +width: 800px name: fig-distributed-timeline --- 分布式执行的时间轴示意图 diff --git a/ch-parallel-computing/thread-process.md b/ch-parallel-computing/thread-process.md index ee235f8..6d3d597 100644 --- a/ch-parallel-computing/thread-process.md +++ b/ch-parallel-computing/thread-process.md @@ -7,7 +7,7 @@ CPU、GPU、网卡等都是硬件层面上的概念,在软件层面,经常 CPU、GPU、网卡等都是被操作系统(Operating System,OS)管理的。操作系统一方面管理硬件,另一方面通过各类应用软件为用户提供服务。正在运行的软件就是进程(Process)。以个人的笔记本电脑为例,使用浏览器浏览网页时,操作系统创建了一个浏览器的进程;使用文本编辑软件 Word 编写文字内容时,操作系统创建了一个 Word 进程。macOS 上的**活动监视器**(如 {numref}`fig-mac-process` 所示),和 Windows 上的**任务管理器**,都可以看到操作系统当前运行的进程,以及各个进程对 CPU、内存等资源的占用。 -```{figure} ../img/ch-intro/mac-process.png +```{figure} ../img/ch-parallel-computing/mac-process.png --- width: 600px name: fig-mac-process @@ -15,19 +15,19 @@ name: fig-mac-process macOS 的活动监视器 ``` -技术层面上,操作系统管理所有进程的执行,为它们合理地分配资源:操作系统以进程为单位分配主存空间,每个进程都有自己的地址空间、数据栈等等。 +技术层面上,操作系统管理所有进程的执行,给进程们合理地分配资源:操作系统以进程为单位分配主存空间,每个进程都有自己的主存地址空间、数据栈等等。 -大部分编程语言实现时,一个进程包含多个线程,即 {numref}`fig-process-thread` 所示。每个线程运行在一个物理计算核心上,一个进程的多个线程可利用多个物理计算核心。 +大部分编程语言实现时,一个进程包含多个线程,如 {numref}`fig-process-thread` 所示。每个线程运行在一个物理计算核心上,一个进程的多个线程可利用多个物理计算核心。 -```{figure} ../img/ch-intro/process-thread.svg +```{figure} ../img/ch-parallel-computing/process-thread.svg --- -width: 500px +width: 600px name: fig-process-thread --- 进程和线程 ``` -从 {numref}`fig-process-thread` 看到,一个进程拥有多个并发的执行线程。多个线程共享相同的上下文(data、files 等),线程间的数据共享和通信更加容易。 +从 {numref}`fig-process-thread` 看到,一个进程拥有多个并发的执行线程。多个线程共享相同的上下文(数据、文件等),线程间的数据共享和通信更加容易。 进程之间是相互隔离的,如果多个进程之间要交换数据,必须通过进程间通信机制(Inter-Process Communication,IPC)来实现数据共享,比如多个进程共享内存(`multiprocessing.shared_memory`)或者 {numref}`sec-mpi-intro` 将要介绍的消息传递接口(Message Passing Interface,MPI)。 @@ -43,7 +43,7 @@ x = x - 1 如果这三行计算被调度到三个线程上,数据 `x` 是被三个线程共享的,三个线程的执行顺序将严重影响计算的结果。{numref}`fig-thread-safe` 展示了三种不同的时序可能性,三种时序的计算结果可能各有不同。由于调度时序因素导致的问题,会使得并行计算的结果不符合预期,线程不安全。 -```{figure} ../img/ch-intro/thread-safe.svg +```{figure} ../img/ch-parallel-computing/thread-safe.svg --- width: 600px name: fig-thread-safe @@ -53,9 +53,9 @@ name: fig-thread-safe 解决线程安全的最简单办法是加锁。如 {numref}`fig-thread-lock` 所示,对于共享的数据,每个线程对其进行修改前先加锁,修改完后再释放锁。 -```{figure} ../img/ch-intro/thread-lock.svg +```{figure} ../img/ch-parallel-computing/thread-lock.svg --- -width: 500px +width: 600px name: fig-thread-lock --- 线程锁 diff --git a/drawio/ch-data-science/bayesian-optimization-explained.drawio b/drawio/ch-data-science/bayesian-optimization-explained.drawio index 218041c..61fb866 100644 --- a/drawio/ch-data-science/bayesian-optimization-explained.drawio +++ b/drawio/ch-data-science/bayesian-optimization-explained.drawio @@ -1,6 +1,6 @@ - + - + @@ -112,10 +112,10 @@ - + - + diff --git a/drawio/ch-data-science/data-science-lifecycle.drawio b/drawio/ch-data-science/data-science-lifecycle.drawio index 64ee280..e190160 100644 --- a/drawio/ch-data-science/data-science-lifecycle.drawio +++ b/drawio/ch-data-science/data-science-lifecycle.drawio @@ -1,6 +1,6 @@ - + - + diff --git a/drawio/ch-intro/map-reduce.drawio b/drawio/ch-intro/map-reduce.drawio deleted file mode 100644 index 9f0d1e9..0000000 --- a/drawio/ch-intro/map-reduce.drawio +++ /dev/null @@ -1,253 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/drawio/ch-intro/serial-timeline.drawio b/drawio/ch-intro/serial-timeline.drawio deleted file mode 100644 index f147d14..0000000 --- a/drawio/ch-intro/serial-timeline.drawio +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/drawio/ch-intro/computer-arch.drawio b/drawio/ch-parallel-computing/computer-arch.drawio similarity index 83% rename from drawio/ch-intro/computer-arch.drawio rename to drawio/ch-parallel-computing/computer-arch.drawio index 94942ef..a30dc17 100644 --- a/drawio/ch-intro/computer-arch.drawio +++ b/drawio/ch-parallel-computing/computer-arch.drawio @@ -1,6 +1,6 @@ - + - + @@ -43,10 +43,10 @@ - + - + @@ -67,10 +67,10 @@ - + - + @@ -85,34 +85,34 @@ - + - + - + - + - + - + - + - + - + - + @@ -127,7 +127,7 @@ - + diff --git a/drawio/ch-intro/distributed-timeline.drawio b/drawio/ch-parallel-computing/distributed-timeline.drawio similarity index 70% rename from drawio/ch-intro/distributed-timeline.drawio rename to drawio/ch-parallel-computing/distributed-timeline.drawio index beaf22f..35b54f9 100644 --- a/drawio/ch-intro/distributed-timeline.drawio +++ b/drawio/ch-parallel-computing/distributed-timeline.drawio @@ -1,6 +1,6 @@ - + - + @@ -19,13 +19,13 @@ - + - + - + @@ -40,13 +40,13 @@ - + - + - + @@ -61,10 +61,10 @@ - + - + @@ -79,10 +79,10 @@ - + - + @@ -94,16 +94,16 @@ - + - + - + diff --git a/drawio/ch-parallel-computing/map-reduce.drawio b/drawio/ch-parallel-computing/map-reduce.drawio new file mode 100644 index 0000000..5c13d7b --- /dev/null +++ b/drawio/ch-parallel-computing/map-reduce.drawio @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/drawio/ch-intro/pcam.drawio b/drawio/ch-parallel-computing/pcam.drawio similarity index 100% rename from drawio/ch-intro/pcam.drawio rename to drawio/ch-parallel-computing/pcam.drawio diff --git a/drawio/ch-intro/process-thread.drawio b/drawio/ch-parallel-computing/process-thread.drawio similarity index 78% rename from drawio/ch-intro/process-thread.drawio rename to drawio/ch-parallel-computing/process-thread.drawio index 9abb1ca..ab8fb8c 100644 --- a/drawio/ch-intro/process-thread.drawio +++ b/drawio/ch-parallel-computing/process-thread.drawio @@ -1,11 +1,11 @@ - + - + - + @@ -19,11 +19,11 @@ - + - - + + @@ -36,8 +36,8 @@ - - + + @@ -64,22 +64,22 @@ - + - + - + - + - + - + diff --git a/drawio/ch-parallel-computing/serial-timeline.drawio b/drawio/ch-parallel-computing/serial-timeline.drawio new file mode 100644 index 0000000..9d381da --- /dev/null +++ b/drawio/ch-parallel-computing/serial-timeline.drawio @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/drawio/ch-intro/thread-lock.drawio b/drawio/ch-parallel-computing/thread-lock.drawio similarity index 87% rename from drawio/ch-intro/thread-lock.drawio rename to drawio/ch-parallel-computing/thread-lock.drawio index f0b5119..334ee47 100644 --- a/drawio/ch-intro/thread-lock.drawio +++ b/drawio/ch-parallel-computing/thread-lock.drawio @@ -1,11 +1,11 @@ - + - + - + @@ -19,11 +19,11 @@ - + - - + + @@ -36,8 +36,8 @@ - - + + @@ -63,22 +63,22 @@ - + - + - + - + - + - + diff --git a/drawio/ch-intro/thread-safe.drawio b/drawio/ch-parallel-computing/thread-safe.drawio similarity index 90% rename from drawio/ch-intro/thread-safe.drawio rename to drawio/ch-parallel-computing/thread-safe.drawio index f86d8cd..968c014 100644 --- a/drawio/ch-intro/thread-safe.drawio +++ b/drawio/ch-parallel-computing/thread-safe.drawio @@ -1,11 +1,11 @@ - + - + - + @@ -19,10 +19,10 @@ - + - + @@ -35,8 +35,8 @@ - - + + @@ -61,22 +61,22 @@ - + - + - + - + - + - + diff --git a/img/ch-data-science/bayesian-optimization-explained.svg b/img/ch-data-science/bayesian-optimization-explained.svg index 833c848..afca96f 100644 --- a/img/ch-data-science/bayesian-optimization-explained.svg +++ b/img/ch-data-science/bayesian-optimization-explained.svg @@ -1,4 +1,4 @@ -
第 3 次迭代
第 3 次迭代
观测样本点
观测样本点
采集函数最大值
采集函数最大值
目标函数
目标函数
新观测样本点
新观测样本点
采集函数
采集函数
方差
方差
均值
均值
采集函数
采集函数
第 4 次迭代
第 4 次迭代
第 5 次迭代
第 5 次迭代
Text is not SVG - cannot display
\ No newline at end of file +
第 3 次迭代
第 3 次迭代
观测样本点
观测样本点
采集函数最大值
采集函数最大值
目标函数
目标函数
新观测样本点
新观测样本点
采集函数
采集函数
方差
方差
均值
均值
采集函数
采集函数
第 4 次迭代
第 4 次迭代
第 5 次迭代
第 5 次迭代
Text is not SVG - cannot display
\ No newline at end of file diff --git a/img/ch-intro/computer-arch.svg b/img/ch-intro/computer-arch.svg deleted file mode 100644 index 54c6f1a..0000000 --- a/img/ch-intro/computer-arch.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - -
处理器 0
处理器 0
核心 0
核心 0
核心 1
核心 1
核心 2
核心 2
核心 3
核心 3
处理器 1
处理器 1
核心 4
核心 4
核心 5
核心 5
核心 6
核心 6
核心 7
核心 7
高速缓存
高速缓存
高速缓存
高速缓存
主存
主存
Bus
Bus
CPU
CPU
CPU
CPU
GPU
GPU
GPU
内存
GPU...
网卡
网卡
Text is not SVG - cannot display
\ No newline at end of file diff --git a/img/ch-intro/distributed-timeline.svg b/img/ch-intro/distributed-timeline.svg deleted file mode 100644 index d531d46..0000000 --- a/img/ch-intro/distributed-timeline.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - -
Worker 1
Worker 1
任务 1
任务 1
任务 5
任务 5
任务 9
任务 9
Worker 2
Worker 2
任务 2
任务 2
任务 6
任务 6
任务 10
任务 10
Worker 3
Worker 3
任务 3
任务 3
任务 7
任务 7
Worker 4
Worker 4
任务 4
任务 4
任务 8
任务 8
时间
时间
节省时间
节省时间
Text is not SVG - cannot display
\ No newline at end of file diff --git a/img/ch-intro/map-reduce.svg b/img/ch-intro/map-reduce.svg deleted file mode 100644 index 1ada603..0000000 --- a/img/ch-intro/map-reduce.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - -
This is an Apple.

Apple is red in color.
This is an Apple....
This is an Apple
This is an A...
Apple is 
red in 
color
Apple is...
输入
输入
切分
切分
映射
映射
This-1

Is-1

An-1

Apple-1
This-1...
Apple-1

Is-1

Red-1

In-1

Color-1
Apple-1...
交换
交换
This-1
This-1
Is-1

Is-1
Is-1...
An-1
An-1
Apple-1

Apple-1
Apple-1...
Red-1
Red-1
In-1
In-1
Color-1
Color-1
聚合
聚合
This-1
This-1
Is-2
Is-2
An-1
An-1
Apple-2
Apple-2
Red-1
Red-1
In-1
In-1
Color-1
Color-1
This-1

Is-2

An-1

Apple-2

Red-1

In-1

Color-1
This-1...
输出
输出
Text is not SVG - cannot display
\ No newline at end of file diff --git a/img/ch-intro/process-thread.svg b/img/ch-intro/process-thread.svg deleted file mode 100644 index ddb4ee9..0000000 --- a/img/ch-intro/process-thread.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - -
数据
数据
文件
文件
代码
代码
寄存器
寄存器
寄存器
寄存器
寄存器
寄存器
运行栈
运行栈
运行栈
运行栈
运行栈
运行栈
线程
线程
进程
进程
Text is not SVG - cannot display
\ No newline at end of file diff --git a/img/ch-intro/serial-timeline.svg b/img/ch-intro/serial-timeline.svg deleted file mode 100644 index 0047856..0000000 --- a/img/ch-intro/serial-timeline.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - -
Worker 1
Worker 1
任务 1
任务 1
任务 2
任务 2
任务 3
任务 3
任务 4
任务 4
任务 5
任务 5
任务 6
任务 6
任务 7
任务 7
任务 8
任务 8
任务 9
任务 9
任务 10
任务 10
时间
时间
Text is not SVG - cannot display
\ No newline at end of file diff --git a/img/ch-intro/thread-lock.svg b/img/ch-intro/thread-lock.svg deleted file mode 100644 index a813a37..0000000 --- a/img/ch-intro/thread-lock.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - -
数据
数据
文件
文件
代码
代码
寄存器
寄存器
寄存器
寄存器
寄存器
寄存器
运行栈
运行栈
运行栈
运行栈
运行栈
运行栈
x
x
x = x + 1
x = x + 1
x = x * 2
x = x * 2
x = x - 1
x = x - 1
线程 1
线程 1
线程 2
线程 2
线程 3
线程 3
时间
时间
加锁 x
加锁 x
解锁 x
解锁 x
加锁 x
加锁 x
解锁 x
解锁 x
加锁 x
加锁 x
解锁 x
解锁 x
Text is not SVG - cannot display
\ No newline at end of file diff --git a/img/ch-intro/thread-safe.svg b/img/ch-intro/thread-safe.svg deleted file mode 100644 index 5248bf3..0000000 --- a/img/ch-intro/thread-safe.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - -
数据
数据
文件
文件
代码
代码
寄存器
寄存器
寄存器
寄存器
寄存器
寄存器
运行栈
运行栈
运行栈
运行栈
运行栈
运行栈
x
x
x = x + 1
x = x + 1
x = x * 2
x = x * 2
x = x - 1
x = x - 1
线程 1
线程 1
线程 2
线程 2
线程 3
线程 3
时间
时间
x = x + 1
x = x + 1
x = x * 2
x = x * 2
x = x - 1
x = x - 1
x = x + 1
x = x + 1
x = x * 2
x = x * 2
x = x - 1
x = x - 1
场景 1
场景 1
场景 2
场景 2
场景 3
场景 3
Text is not SVG - cannot display
\ No newline at end of file diff --git a/img/ch-parallel-computing/computer-arch.svg b/img/ch-parallel-computing/computer-arch.svg new file mode 100644 index 0000000..e7f0e0b --- /dev/null +++ b/img/ch-parallel-computing/computer-arch.svg @@ -0,0 +1,4 @@ + + + +
处理器 0
处理器 0
核心 0
核心 0
核心 1
核心 1
核心 2
核心 2
核心 3
核心 3
处理器 1
处理器 1
核心 4
核心 4
核心 5
核心 5
核心 6
核心 6
核心 7
核心 7
高速缓存
高速缓存
高速缓存
高速缓存
主存
主存
总线
总线
CPU
CPU
CPU
CPU
GPU
GPU
GPU
内存
GPU...
网卡
网卡
Text is not SVG - cannot display
\ No newline at end of file diff --git a/img/ch-parallel-computing/distributed-timeline.svg b/img/ch-parallel-computing/distributed-timeline.svg new file mode 100644 index 0000000..9006854 --- /dev/null +++ b/img/ch-parallel-computing/distributed-timeline.svg @@ -0,0 +1,4 @@ + + + +
Worker 1
Worker 1
任务 1
任务 1
任务 5
任务 5
任务 9
任务 9
Worker 2
Worker 2
任务 2
任务 2
任务 6
任务 6
任务 10
任务 10
Worker 3
Worker 3
任务 3
任务 3
任务 7
任务 7
Worker 4
Worker 4
任务 4
任务 4
任务 8
任务 8
时间
时间
节省时间
节省时间
Text is not SVG - cannot display
\ No newline at end of file diff --git a/img/ch-intro/mac-process.png b/img/ch-parallel-computing/mac-process.png similarity index 100% rename from img/ch-intro/mac-process.png rename to img/ch-parallel-computing/mac-process.png diff --git a/img/ch-parallel-computing/map-reduce.svg b/img/ch-parallel-computing/map-reduce.svg new file mode 100644 index 0000000..10c684b --- /dev/null +++ b/img/ch-parallel-computing/map-reduce.svg @@ -0,0 +1,4 @@ + + + +
This is an Apple.

Apple is red in color.
This is an Apple...
This is an Apple
This is an...
Apple is 
red in 
color
Apple is...
输入
输入
切分
切分
映射
映射
This-1

Is-1

An-1

Apple-1
This-1...
Apple-1

Is-1

Red-1

In-1

Color-1
Apple-1...
交换
交换
This-1
This-1
Is-1

Is-1
Is-1...
An-1
An-1
Apple-1

Apple-1
Apple-1...
Red-1
Red-1
In-1
In-1
Color-1
Color-1
聚合
聚合
This-1
This-1
Is-2
Is-2
An-1
An-1
Apple-2
Apple-2
Red-1
Red-1
In-1
In-1
Color-1
Color-1
This-1

Is-2

An-1

Apple-2

Red-1

In-1

Color-1
This-1...
输出
输出
Text is not SVG - cannot display
\ No newline at end of file diff --git a/img/ch-intro/pcam.png b/img/ch-parallel-computing/pcam.png similarity index 100% rename from img/ch-intro/pcam.png rename to img/ch-parallel-computing/pcam.png diff --git a/img/ch-intro/pcam.svg b/img/ch-parallel-computing/pcam.svg similarity index 100% rename from img/ch-intro/pcam.svg rename to img/ch-parallel-computing/pcam.svg diff --git a/img/ch-parallel-computing/process-thread.svg b/img/ch-parallel-computing/process-thread.svg new file mode 100644 index 0000000..c59105a --- /dev/null +++ b/img/ch-parallel-computing/process-thread.svg @@ -0,0 +1,4 @@ + + + +
数据
数据
文件
文件
代码
代码
寄存器
寄存器
寄存器
寄存器
寄存器
寄存器
运行栈
运行栈
运行栈
运行栈
运行栈
运行栈
线程
线程
进程
进程
Text is not SVG - cannot display
\ No newline at end of file diff --git a/img/ch-intro/serial-timeline.png b/img/ch-parallel-computing/serial-timeline.png similarity index 100% rename from img/ch-intro/serial-timeline.png rename to img/ch-parallel-computing/serial-timeline.png diff --git a/img/ch-parallel-computing/serial-timeline.svg b/img/ch-parallel-computing/serial-timeline.svg new file mode 100644 index 0000000..7dabf51 --- /dev/null +++ b/img/ch-parallel-computing/serial-timeline.svg @@ -0,0 +1,4 @@ + + + +
Worker 1
Worker 1
任务 1
任务 1
任务 2
任务 2
任务 3
任务 3
任务 4
任务 4
任务 5
任务 5
任务 6
任务 6
任务 7
任务 7
任务 8
任务 8
任务 9
任务 9
任务 10
任务 10
时间
时间
Text is not SVG - cannot display
\ No newline at end of file diff --git a/img/ch-parallel-computing/thread-lock.svg b/img/ch-parallel-computing/thread-lock.svg new file mode 100644 index 0000000..8c30088 --- /dev/null +++ b/img/ch-parallel-computing/thread-lock.svg @@ -0,0 +1,4 @@ + + + +
数据
数据
文件
文件
代码
代码
寄存器
寄存器
寄存器
寄存器
寄存器
寄存器
运行栈
运行栈
运行栈
运行栈
运行栈
运行栈
x
x
x = x + 1
x = x + 1
x = x * 2
x = x * 2
x = x - 1
x = x - 1
线程 1
线程 1
线程 2
线程 2
线程 3
线程 3
时间
时间
加锁 x
加锁 x
解锁 x
解锁 x
加锁 x
加锁 x
解锁 x
解锁 x
加锁 x
加锁 x
解锁 x
解锁 x
Text is not SVG - cannot display
\ No newline at end of file diff --git a/img/ch-parallel-computing/thread-safe.svg b/img/ch-parallel-computing/thread-safe.svg new file mode 100644 index 0000000..6b0cb6c --- /dev/null +++ b/img/ch-parallel-computing/thread-safe.svg @@ -0,0 +1,4 @@ + + + +
数据
数据
文件
文件
代码
代码
寄存器
寄存器
寄存器
寄存器
寄存器
寄存器
运行栈
运行栈
运行栈
运行栈
运行栈
运行栈
x
x
x = x + 1
x = x + 1
x = x * 2
x = x * 2
x = x - 1
x = x - 1
线程 1
线程 1
线程 2
线程 2
线程 3
线程 3
时间
时间
x = x + 1
x = x + 1
x = x * 2
x = x * 2
x = x - 1
x = x - 1
x = x + 1
x = x + 1
x = x * 2
x = x * 2
x = x - 1
x = x - 1
场景 1
场景 1
场景 2
场景 2
场景 3
场景 3
Text is not SVG - cannot display
\ No newline at end of file diff --git a/references.bib b/references.bib index d6cd582..12ff34e 100644 --- a/references.bib +++ b/references.bib @@ -183,6 +183,14 @@ @article{petersohn2020Scalable langid = {english} } +@inproceedings{kingma2015Adam, + title = {Adam: {{A}} Method for Stochastic Optimization}, + booktitle = {3rd International Conference on Learning Representations, {{ICLR}} 2015, San Diego, {{CA}}, {{USA}}, May 7-9, 2015, Conference Track Proceedings}, + author = {Kingma, Diederik P. and Ba, Jimmy}, + editor = {Bengio, Yoshua and LeCun, Yann}, + year = {2015} +} + @article{petersohn2021Flexible, title = {Flexible Rule-Based Decomposition and Metadata Independence in Modin: A Parallel Dataframe System}, shorttitle = {Flexible Rule-Based Decomposition and Metadata Independence in Modin},