Update fig (#272)

This commit is contained in:
Cheng Lai
2022-04-12 11:57:10 +08:00
committed by GitHub
parent 9c6f64b116
commit 2e97cd7cf6
5 changed files with 179 additions and 170 deletions

View File

@@ -2,7 +2,7 @@
现代机器学习框架包含大量的组件。这些组件使得用户得以高效开发机器学习算法处理数据部署模型性能调优和使用硬件加速器。在设计这些组件的编程接口时一个核心的诉求是如何平衡框架性能和易用性为了达到最优的性能开发者需要利用硬件亲和的编程语言如C和C++来进行开发。这是因为C和C++的使用使得机器学习框架可以高效调用硬件的底层API从而最大限度发挥硬件性能。同时现代操作系统如Linux和Windows提供丰富的基于C和C++的编程接口如文件系统网络编程多线程管理等通过直接调用操作系统API可以降低框架运行的开销。
从易用性的角度分析,机器学习框架的使用者往往具有丰富的行业背景(如数据科学家,生物学家,化学家,物理学家等)。他们常用的编程语言是高层次脚本语言PythonMatlabR和Julia。相比于C和C++这些语言在提供编程的易用性的同时丧失了C和C++对底层硬件和操作系统进行深度优化的能力。因此机器学习框架的核心设计目标是其要具有易用编程接口来支持用户用高层次语言如Python来实现机器学习算法同时其也要具备以C和C++为核心的低层次编程接口使得框架开发者可以用C和C++实现大量高性能组件,从而在硬件上高效执行。在本章中,我们将会讲述如何达到这个设计目标。
从易用性的角度分析机器学习框架的使用者往往具有丰富的行业背景如数据科学家生物学家化学家物理学家等。他们常用的编程语言是高层次脚本语言PythonMatlabR和Julia。相比于C和C++这些语言在提供编程的易用性的同时丧失了C和C++对底层硬件和操作系统进行深度优化的能力。因此机器学习框架的核心设计目标是其要具有易用编程接口来支持用户用高层次语言如Python来实现机器学习算法同时其也要具备以C和C++为核心的低层次编程接口使得框架开发者可以用C和C++实现大量高性能组件,从而在硬件上高效执行。在本章中,我们将会讲述如何达到这个设计目标。
本章的学习目标包括:

View File

@@ -19,7 +19,7 @@
- **测试和调试:**
训练过程中用户需要测试API来对当前模型的精度进行评估。当精度达到目标后训练结束。这一过程中用户往往需要调试API来完成对模型的性能和正确性进行验证。
![机器学习系统工作流](../img/ch02/workflow.svg)
![机器学习系统工作流](../img/ch02/img_workflow.svg)
:width:`800px`
:label:`img_workflow`

View File

@@ -19,3 +19,8 @@
- Python和C之间的互操作性一般通过CType等技术实现。
- 机器学习框架一般具有多种C和C++接口允许用户定义和注册C++实现的算子。这些算子使得用户可以开发高性能模型,数据处理函数,优化器等一系列框架拓展。
## 扩展阅读
- MindSpore编程指南[MindSpore](https://www.mindspore.cn/docs/programming_guide/zh-CN/r1.6/index.html)
- Python和C/C++混合编程:[Pybind11](https://pybind11.readthedocs.io/en/latest/basics.html#creating-bindings-for-a-simple-function)

172
img/ch02/img_workflow.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -1,168 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
version="1.1"
id="svg2"
xml:space="preserve"
width="1251.4545"
height="158.8"
viewBox="0 0 1251.4545 158.8"
sodipodi:docname="workflow.svg"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><defs
id="defs6"><clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath18"><path
d="M 0,0 H 939.9273 V 120 H 0 Z"
id="path16" /></clipPath></defs><sodipodi:namedview
id="namedview4"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="0.99494688"
inkscape:cx="963.36801"
inkscape:cy="-127.64501"
inkscape:window-width="1920"
inkscape:window-height="1137"
inkscape:window-x="1912"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="g22" /><g
id="g8"
inkscape:groupmode="layer"
inkscape:label="workflow"
transform="matrix(1.3333333,0,0,-1.3333333,-1.2545919,159.3272)"><g
id="g10" /><g
id="g22"><g
id="g26"
transform="matrix(7.874016e-5,0,0,-7.874016e-5,1.690944,118.7454)"><path
d="M 0,0 H 1648690 V 1493520 H 0 Z"
style="fill:none;stroke:#000000;stroke-width:19050;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:none;stroke-opacity:1"
id="path28" /></g><g
id="g30"
transform="matrix(0.2181818,0,0,0.2181818,30.4146,-65.45454)"><text
transform="matrix(1,0,0,-1,0,550)"
style="font-variant:normal;font-weight:normal;font-size:83px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text34"><tspan
x="0 82.501991 165.00398 247.50597"
y="0"
sodipodi:role="line"
id="tspan32">数据处理</tspan></text></g><g
id="g38"
transform="matrix(7.874016e-5,0,0,-7.874016e-5,203.5091,118.7454)"><path
d="M 0,0 H 1645920 V 1493520 H 0 Z"
style="fill:none;stroke:#000000;stroke-width:19050;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:none;stroke-opacity:1"
id="path40" /></g><g
id="g42"
transform="matrix(0.2181818,0,0,0.2181818,232.2039,-65.45454)"><text
transform="matrix(1,0,0,-1,0,550)"
style="font-variant:normal;font-weight:normal;font-size:83px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text46"><tspan
x="0 82.501991 165.00398 247.50597"
y="0"
sodipodi:role="line"
id="tspan44">模型结构</tspan></text></g><g
id="g50"
transform="matrix(7.874016e-5,0,0,-7.874016e-5,607.3636,118.7454)"><path
d="M 0,0 H 1648691 V 1493520 H 0 Z"
style="fill:none;stroke:#000000;stroke-width:19050;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:none;stroke-opacity:1"
id="path52" /></g><g
id="g54"
transform="matrix(0.2181818,0,0,0.2181818,636.1186,-65.45454)"><text
transform="matrix(1,0,0,-1,0,550)"
style="font-variant:normal;font-weight:normal;font-size:83px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text58"><tspan
x="0 82.501991"
y="0"
sodipodi:role="line"
id="tspan56">训练</tspan></text></g><g
id="g60"
transform="matrix(0.2181818,0,0,0.2181818,672.1186,-65.45454)"><text
transform="matrix(1,0,0,-1,0,550)"
style="font-variant:normal;font-weight:normal;font-size:83px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text64"><tspan
x="0 82.501991"
y="0"
sodipodi:role="line"
id="tspan62">过程</tspan></text></g><path
d="m 142.4182,68.72725 h 33.7091 v 8.78181 L 193.6909,59.94544 176.1273,42.38182 v 8.78181 h -33.7091 z"
style="fill:#deebf7;fill-opacity:1;fill-rule:evenodd;stroke:none"
id="path66" /><g
id="g68"
transform="matrix(7.874016e-5,0,0,-7.874016e-5,142.4182,77.50906)"><path
d="M 0,111529 H 428106.1 V 0 L 651164,223058 428106.1,446116 V 334587 H 0 Z"
style="fill:none;stroke:#000000;stroke-width:19050;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:none;stroke-opacity:1"
id="path70" /></g><path
d="m 545.8364,68.72726 h 33.491 v 8.7818 L 596.8909,59.94541 579.3274,42.38182 v 8.78179 h -33.491 z"
style="fill:#deebf7;fill-opacity:1;fill-rule:evenodd;stroke:none"
id="path72" /><g
id="g74"
transform="matrix(7.874016e-5,0,0,-7.874016e-5,545.8364,77.50906)"><path
d="M 0,111528.8 H 425335.6 V 0 L 648393,223058.3 425335.6,446116 V 334587.2 H 0 Z"
style="fill:none;stroke:#000000;stroke-width:19050;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:none;stroke-opacity:1"
id="path76" /></g><path
d="m 342.9272,68.72726 h 33.491 v 8.7818 L 393.9818,59.94541 376.4182,42.38182 v 8.78179 h -33.491 z"
style="fill:#deebf7;fill-opacity:1;fill-rule:evenodd;stroke:none"
id="path78" /><g
id="g80"
transform="matrix(7.874016e-5,0,0,-7.874016e-5,342.9272,77.50906)"><path
d="M 0,111528.8 H 425335.6 V 0 L 648393,223058.3 425335.6,446116 V 334587.2 H 0 Z"
style="fill:none;stroke:#000000;stroke-width:19050;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:none;stroke-opacity:1"
id="path82" /></g><g
id="g86"
transform="matrix(7.874016e-5,0,0,-7.874016e-5,405.1091,118.7454)"><path
d="M 0,0 H 1648691 V 1493520 H 0 Z"
style="fill:none;stroke:#000000;stroke-width:19050;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:none;stroke-opacity:1"
id="path88" /></g><g
id="g90"
transform="matrix(0.2181818,0,0,0.2181818,415.9932,-54.76363)"><text
transform="matrix(1,0,0,-1,0,550)"
style="font-variant:normal;font-weight:normal;font-size:83px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text94"><tspan
x="0 82.501991 165.00398 247.50597 330.00797 412.50995"
y="0"
sodipodi:role="line"
id="tspan92">损失函数和优</tspan></text></g><g
id="g96"
transform="matrix(0.2181818,0,0,0.2181818,442.9932,-76.36363)"><text
transform="matrix(1,0,0,-1,0,550)"
style="font-variant:normal;font-weight:normal;font-size:83px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text100"><tspan
x="0 82.501991 165.00398"
y="0"
sodipodi:role="line"
id="tspan98">化算法</tspan></text></g><g
id="g104"
transform="matrix(7.874016e-5,0,0,-7.874016e-5,808.9636,118.7454)"><path
d="M 0,0 H 1648691 V 1493520 H 0 Z"
style="fill:none;stroke:#000000;stroke-width:19050;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:none;stroke-opacity:1"
id="path106" /></g><g
id="g108"
transform="matrix(0.2181818,0,0,0.2181818,828.8295,-65.45454)"><text
transform="matrix(1,0,0,-1,0,550)"
style="font-variant:normal;font-weight:normal;font-size:83px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text112"><tspan
x="0 82.501991 165.00398 247.50597 330.00797"
y="0"
sodipodi:role="line"
id="tspan110">测试和调试</tspan></text></g><path
d="m 747.4364,72.05453 h 33.8181 v 8.72729 L 798.709,63.32729 781.2545,45.87276 V 54.6 h -33.8181 z"
style="fill:#deebf7;fill-opacity:1;fill-rule:evenodd;stroke:none"
id="path114" /><g
id="g116"
transform="matrix(7.874016e-5,0,0,-7.874016e-5,747.4364,80.78182)"><path
d="M 0,110836.6 H 429490.6 V 0 L 651163,221672.5 429490.6,443345 V 332509.1 H 0 Z"
style="fill:none;stroke:#000000;stroke-width:19050;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:none;stroke-opacity:1"
id="path118" /></g></g></g></svg>

Before

Width:  |  Height:  |  Size: 9.3 KiB