Skip to content

Commit

Permalink
update images (#42)
Browse files Browse the repository at this point in the history
1. draw svg figure in ch-ray-train-tune and change the figure file name in the text content.

Note that for 'bayesian-optimization-explained.svg', the base image is drawn using code 'drawio\ch-ray-train-tune\Rplot.R', and the text on the image is added in draw.io; and for 'tune-algorithms.svg', the base image is drawn using code 'drawio\ch-ray-train-tune\Pythonplot.py' , and the text on the image is added in draw.io;

Note that when exporting 'bayesian-optimization-explained.svg' from draw.io, do not select options '包含绘图副本', '嵌入图片', and '嵌入字体'.

2. redraw 'img\ch-mpi\rma-window.svg', 'img\ch-mpi-large-model\gpu-direct.svg', 'img\ch-mpi-large-model\mpi-wo-gpu-direct.svg',  'img\ch-mpi-large-model\gpu-communication.svg'.
  • Loading branch information
leverage-point authored May 6, 2024
1 parent 99fb5b7 commit 01256be
Show file tree
Hide file tree
Showing 21 changed files with 1,576 additions and 377 deletions.
10 changes: 5 additions & 5 deletions ch-ray-train-tune/tune-algorithm-scheduler.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"\n",
"超参数调优是一种黑盒优化,所谓黑盒优化,指的是目标函数是一个黑盒,我们只能通过观察其输入和输出来推断其行为。黑盒的概念比较难以理解,但是我们可以相比梯度下降算法,梯度下降算法**不是**一种黑盒优化算法,我们可以得到目标函数的梯度(或近似值),并用梯度来指导搜索方向,最终找到目标函数的(局部)最优解。黑盒优化算法一般无法找到目标函数的数学表达式和梯度,也无法使用基于梯度的优化技术。贝叶斯优化、遗传算法、模拟退火等都是黑盒优化,这些算法通常在超参数搜索空间中选择一些候选解,运行目标函数,得到超参数组合的实际性能,基于实际性能,不断迭代调整,即重复上述过程,直到满足条件。{numref}`fig-tune-algorithms` 展示了在二维搜索空间中进行超参数搜索,每个点表示一种超参数组合,颜色越暖,表示性能越好。迭代式的算法从初始点开始,后续试验依赖之前试验的结果,最后向性能较好的方向收敛。\n",
"\n",
"```{figure} ../img/ch-ray-train-tune/tune-algorithms.jpeg\n",
"```{figure} ../img/ch-ray-train-tune/tune-algorithms.svg\n",
"---\n",
"width: 600px\n",
"name: fig-tune-algorithms\n",
Expand All @@ -32,7 +32,7 @@
"\n",
"为防止陷入局部最优,采集函数在选取下一个取值点时,应该既考虑利用(Exploit)那些均值较大的,又探索(Explore)那些方差较大的,即在利用和探索之间寻找一个平衡。例如,模型训练非常耗时,有限的计算资源只能再跑 1 组超参数了,那应该选择均值较大的,因为这样能选到最优结果的可能性最高;如果我们计算资源还能可以跑上千次,那应该多探索不同的可能性。在 {numref}`fig-bayesian-optimization-explained` 的例子中,迭代 3 和 迭代 4 都在迭代 2 的观测值附近选择新的点,是在探索和利用之间的一个平衡。\n",
"\n",
"```{figure} ../img/ch-ray-train-tune/bayesian-optimization-explained.png\n",
"```{figure} ../img/ch-ray-train-tune/bayesian-optimization-explained.svg\n",
"---\n",
"width: 600px\n",
"name: fig-bayesian-optimization-explained\n",
Expand All @@ -53,7 +53,7 @@
"3. 选出排序靠前的超参数组合,进行下一轮(Rung)训练,性能较差的超参数组合早停。\n",
"4. 下一轮每个超参数组合的计算资源额度以一定的策略增加。\n",
"\n",
"```{figure} ../img/ch-ray-train-tune/successive-halving.png\n",
"```{figure} ../img/ch-ray-train-tune/successive-halving.svg\n",
"---\n",
"width: 600px\n",
"name: fig-successive-halving\n",
Expand Down Expand Up @@ -92,7 +92,7 @@
"\n",
"{numref}`fig-hyperband-example` 是一个例子:横轴是外层循环,共有 5 个(0 到 4)可能性,初始的计算资源 $n$ 和每个超参数组合所能获得的计算资源 $r$ 形成一个组合(Bracket);纵轴是内层循环,对于某一种初始的 Bracket,执行 SHA 算法,一直迭代到选出最优试验。\n",
"\n",
"```{figure} ../img/ch-ray-train-tune/hyperband-example.png\n",
"```{figure} ../img/ch-ray-train-tune/hyperband-example.svg\n",
"---\n",
"width: 600px\n",
"name: fig-hyperband-example\n",
Expand Down Expand Up @@ -636,7 +636,7 @@
"\n",
"种群训练(Population Based Training,PBT){cite}`jaderberg2017Population` 主要针对深度神经网络训练,它借鉴了遗传算法的思想,可以同时优化模型参数和超参数。PBT 中,种群可以简单理解成不同的试验,PBT 并行地启动多个试验,每个试验从超参数搜索空间中随机选择一个超参数组合,并随机初始化参数矩阵,训练过程中会定期地评估模型指标。模型训练过程中,基于模型性能指标,PBT 会**利用**或**探索**当前试验的模型参数或超参数。当前试验的指标不理想,PBT 会执行“利用”,将当前模型权重换成种群中其他表现较好的参数权重。PBT 也会“探索”:变异生成新的超参数进行接下来的训练。在一次完整的训练过程中,其他超参数调优方法会选择一种超参数组合完成整个训练;PBT 在训练过程中借鉴效果更好的模型权重,或使用新的超参数,因此它被认为同时优化模型参数和超参数。\n",
"\n",
"```{figure} ../img/ch-ray-train-tune/population-based-training.webp\n",
"```{figure} ../img/ch-ray-train-tune/population-based-training.svg\n",
"---\n",
"width: 600px\n",
"name: fig-population-based-training\n",
Expand Down
Loading

0 comments on commit 01256be

Please sign in to comment.