Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
403195f0
Unverified
Commit
403195f0
authored
Jul 15, 2021
by
Yuge Zhang
Committed by
GitHub
Jul 15, 2021
Browse files
Merge branch 'master' into nn-meter
parents
99aa8226
a7278d2d
Changes
207
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
925 additions
and
236 deletions
+925
-236
docs/zh_CN/Tutorial/QuickStart.rst
docs/zh_CN/Tutorial/QuickStart.rst
+6
-2
docs/zh_CN/Tutorial/SearchSpaceSpec.rst
docs/zh_CN/Tutorial/SearchSpaceSpec.rst
+13
-1
docs/zh_CN/Tutorial/Tensorboard.rst
docs/zh_CN/Tutorial/Tensorboard.rst
+51
-0
docs/zh_CN/Tutorial/WebUI.rst
docs/zh_CN/Tutorial/WebUI.rst
+64
-13
docs/zh_CN/Tutorial/python_api_connect.ipynb
docs/zh_CN/Tutorial/python_api_connect.ipynb
+12
-5
docs/zh_CN/Tutorial/python_api_start.ipynb
docs/zh_CN/Tutorial/python_api_start.ipynb
+34
-54
docs/zh_CN/_templates/index.html
docs/zh_CN/_templates/index.html
+46
-42
docs/zh_CN/builtin_tuner.rst
docs/zh_CN/builtin_tuner.rst
+0
-3
docs/zh_CN/conf.py
docs/zh_CN/conf.py
+3
-3
docs/zh_CN/hpo_benchmark.rst
docs/zh_CN/hpo_benchmark.rst
+240
-0
docs/zh_CN/hyperparameter_tune.rst
docs/zh_CN/hyperparameter_tune.rst
+2
-1
docs/zh_CN/nas.rst
docs/zh_CN/nas.rst
+14
-10
docs/zh_CN/reference.rst
docs/zh_CN/reference.rst
+3
-2
docs/zh_CN/reference/experiment_config.rst
docs/zh_CN/reference/experiment_config.rst
+325
-93
docs/zh_CN/sdk_reference.rst
docs/zh_CN/sdk_reference.rst
+1
-1
examples/model_compress/pruning/basic_pruners_torch.py
examples/model_compress/pruning/basic_pruners_torch.py
+14
-5
examples/model_compress/pruning/speedup/model_speedup.py
examples/model_compress/pruning/speedup/model_speedup.py
+1
-1
examples/model_compress/pruning/speedup/speedup_mobilnetv2.py
...ples/model_compress/pruning/speedup/speedup_mobilnetv2.py
+21
-0
examples/model_compress/pruning/speedup/speedup_nanodet.py
examples/model_compress/pruning/speedup/speedup_nanodet.py
+39
-0
examples/model_compress/pruning/speedup/speedup_yolov3.py
examples/model_compress/pruning/speedup/speedup_yolov3.py
+36
-0
No files found.
docs/zh_CN/Tutorial/QuickStart.rst
View file @
403195f0
...
@@ -149,6 +149,9 @@ NNI 用来帮助超参调优。它的流程如下:
...
@@ -149,6 +149,9 @@ NNI 用来帮助超参调优。它的流程如下:
codeDir
:
.
codeDir
:
.
gpuNum
:
0
gpuNum
:
0
..
_nniignore
:
..
Note
::
如果要使用远程计算机或集群作为
:
doc
:`
训练平台
<../
TrainingService
/
Overview
>`
,为了避免产生过大的网络压力,
NNI
限制了文件的最大数量为
2000
,大小为
300
MB
。
如果
codeDir
中包含了过多的文件,可添加
``.
nniignore
``
文件来排除部分,与
``.
gitignore
``
文件用法类似。
参考
`
git
documentation
<
https
://
git
-
scm
.
com
/
docs
/
gitignore
#
_pattern_format
>`
__
,了解更多如何编写此文件的详细信息
_
。
..
Note
::
如果要使用远程计算机或集群作为
:
doc
:`
训练平台
<../
TrainingService
/
Overview
>`
,为了避免产生过大的网络压力,
NNI
限制了文件的最大数量为
2000
,大小为
300
MB
。
如果
codeDir
中包含了过多的文件,可添加
``.
nniignore
``
文件来排除部分,与
``.
gitignore
``
文件用法类似。
参考
`
git
documentation
<
https
://
git
-
scm
.
com
/
docs
/
gitignore
#
_pattern_format
>`
__
,了解更多如何编写此文件的详细信息
_
。
*
示例
:*
:
githublink
:`
config
.
yml
<
examples
/
trials
/
mnist
-
pytorch
/
config
.
yml
>`
和
:
githublink
:`.
nniignore
<
examples
/
trials
/
mnist
-
pytorch
/.
nniignore
>`
*
示例
:*
:
githublink
:`
config
.
yml
<
examples
/
trials
/
mnist
-
pytorch
/
config
.
yml
>`
和
:
githublink
:`.
nniignore
<
examples
/
trials
/
mnist
-
pytorch
/.
nniignore
>`
...
@@ -234,7 +237,7 @@ Experiment 相关信息会显示在界面上,配置和搜索空间等。 NNI
...
@@ -234,7 +237,7 @@ Experiment 相关信息会显示在界面上,配置和搜索空间等。 NNI
查看
Trial
详情页面
查看
Trial
详情页面
^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^
可以在此页面中看到最佳的试用指标和超参数图。
当您单击按钮
``
Add
/
Remove
columns
``
时,表格内容包括更多列。
可以在此页面中看到最佳的试用指标和超参数图。
当您单击按钮
``
Add
/
Remove
columns
``
时,表格内容包括更多列。
当您单击按钮
``
Add
/
Remove
columns
``
时,表格内容包括更多列。
..
image
::
../../
img
/
webui
-
img
/
full
-
detail
.
png
..
image
::
../../
img
/
webui
-
img
/
full
-
detail
.
png
...
@@ -260,11 +263,12 @@ Experiment 相关信息会显示在界面上,配置和搜索空间等。 NNI
...
@@ -260,11 +263,12 @@ Experiment 相关信息会显示在界面上,配置和搜索空间等。 NNI
-------------
-------------
*
`
在
Web
界面中启动
TensorBoard
<
Tensorboard
.
rst
>`
__
*
`
尝试不同的
Tuner
<../
Tuner
/
BuiltinTuner
.
rst
>`
__
*
`
尝试不同的
Tuner
<../
Tuner
/
BuiltinTuner
.
rst
>`
__
*
`
尝试不同的
Assessor
<../
Assessor
/
BuiltinAssessor
.
rst
>`
__
*
`
尝试不同的
Assessor
<../
Assessor
/
BuiltinAssessor
.
rst
>`
__
*
`
如何使用命令行工具
nnictl
<
Nnictl
.
rst
>`
__
*
`
如何使用命令行工具
nnictl
<
Nnictl
.
rst
>`
__
*
`
如何实现
Trial
代码
<../
TrialExample
/
Trials
.
rst
>`
__
*
`
如何实现
Trial
代码
<../
TrialExample
/
Trials
.
rst
>`
__
*
`
如何在本机运行
Experiment
(
支持多
GPU
卡
)
?
<../
TrainingService
/
LocalMode
.
rst
>`
__
*
`
如何在本机运行
Experiment
(
支持多
GPU
卡
)
?
<../
TrainingService
/
LocalMode
.
rst
>`
__
<../
TrainingService
/
LocalMode
.
rst
>`
__
*
`
如何在多机上运行
Experiment
?
<../
TrainingService
/
RemoteMachineMode
.
rst
>`
__
*
`
如何在多机上运行
Experiment
?
<../
TrainingService
/
RemoteMachineMode
.
rst
>`
__
*
`
如何在
OpenPAI
上运行
Experiment
?
<../
TrainingService
/
PaiMode
.
rst
>`
__
*
`
如何在
OpenPAI
上运行
Experiment
?
<../
TrainingService
/
PaiMode
.
rst
>`
__
*
`
如何通过
Kubeflow
在
Kubernetes
上运行
Experiment
?
<../
TrainingService
/
KubeflowMode
.
rst
>`
__
*
`
如何通过
Kubeflow
在
Kubernetes
上运行
Experiment
?
<../
TrainingService
/
KubeflowMode
.
rst
>`
__
...
...
docs/zh_CN/Tutorial/SearchSpaceSpec.rst
View file @
403195f0
...
@@ -243,13 +243,25 @@
...
@@ -243,13 +243,25 @@
-
-
-
-
-
-
* - DNGO Tuner
- :raw-html:`✓`
-
- :raw-html:`✓`
- :raw-html:`✓`
- :raw-html:`✓`
- :raw-html:`✓`
- :raw-html:`✓`
-
-
-
-
已知的局限:
已知的局限:
*
*
GP Tuner
和
Metis Tuner 的搜索空间只支持 **数值**,(**choice** 类型在其它 Tuner 中可以使用非数值, 如:字符串等)。 GP Tuner 和 Metis Tuner 都使用了高斯过程的回归(Gaussian Process Regressor, GPR)。 GPR 基于计算不同点距离的和函数来进行预测,其无法计算非数值值的距离。
GP Tuner
、
Metis Tuner
和 DNGO Tuner
的搜索空间只支持 **数值**,(**choice** 类型在其它 Tuner 中可以使用非数值, 如:字符串等)。 GP Tuner 和 Metis Tuner 都使用了高斯过程的回归(Gaussian Process Regressor, GPR)。 GPR 基于计算不同点距离的和函数来进行预测,其无法计算非数值值的距离。
*
*
请注意,对于嵌套搜索空间:
请注意,对于嵌套搜索空间:
...
...
docs/zh_CN/Tutorial/Tensorboard.rst
0 → 100644
View file @
403195f0
如何在 Web 界面中使用 TensorBoard
====================================================
从 NNI v2.2 开始,您可以在 Web 界面中跨一个或多个 Trial 启动 TensorBoard 进程。 该功能目前支持本地训练平台和共享存储的重用模式下的训练平台,并将在未来的 NNI 版本中支持更多场景。
准备
-----------
确保在您的环境中安装了 TensorBoard。 如果您从未使用过 TensorBoard,这里有入门教程供您参考:`在 TensorFlow 下使用 TensorBoard <https://www.tensorflow.org/tensorboard/get_started>`__, `在 PyTorch 下使用 TensorBoard <https://pytorch.org/tutorials/recipes/recipes/tensorboard_with_pytorch.html>`__。
使用 Web 界面启动 TensorBoard
--------------------------------------------------------
1. 保存日志
^^^^^^^^^^^^
NNI 将自动获取 Trial 输出文件夹下的 ``tensorboard`` 子文件夹作为 tensorboard logdir。 所以在 Trial 的源代码中,你需要将 TensorBoard 日志保存在 ``NNI_OUTPUT_DIR/tensorboard`` 下。 此日志路径可以连接为:
.. code-block:: python
log_dir = os.path.join(os.environ["NNI_OUTPUT_DIR"], 'tensorboard')
2. 启动 TensorBoard
^^^^^^^^^^^^^^^^^^^^^
像比较一样,首先选择要组合的 Trial 来启动 TensorBoard,然后单击 ``Tensorboard`` 按钮。
.. image:: ../../img/Tensorboard_1.png
:target: ../../img/Tensorboard_1.png
:alt:
点击弹出框中的 "OK "按钮后,你将跳转到 TensorBoard 门户。
.. image:: ../../img/Tensorboard_2.png
:target: ../../img/Tensorboard_2.png
:alt:
你可以在 TensorBoard 门户上看到 ``SequenceID-TrialID``。
.. image:: ../../img/Tensorboard_3.png
:target: ../../img/Tensorboard_3.png
:alt:
3. 全部停用
^^^^^^^^^^^^
如果你想打开已经启动的门户,请点击 tensorboard id。 如果你不再需要 TensorBoard,点击 ``Stop all tensorboard`` 按钮。
.. image:: ../../img/Tensorboard_4.png
:target: ../../img/Tensorboard_4.png
:alt:
docs/zh_CN/Tutorial/WebUI.rst
View file @
403195f0
Web 界面
Web 界面
===============
===============
===
Experiment 管理
Experiment 管理
-----------------------
-----------------------
...
@@ -144,7 +144,7 @@ Experiment 管理
...
@@ -144,7 +144,7 @@ Experiment 管理
查看超参
查看超参
--------------------
--------------------
点
击 ``
Hyper Parameter
`` 标签查看图
像
。
单
击 ``
Intermediate Result
`` 标签查看
折线
图。
* 可以 ``添加/删除`` 轴,或者拖动以交换图表上的轴。
* 可以 ``添加/删除`` 轴,或者拖动以交换图表上的轴。
...
@@ -195,7 +195,7 @@ Trial 可能在训练过程中有大量中间结果。 为了更清楚的理解
...
@@ -195,7 +195,7 @@ Trial 可能在训练过程中有大量中间结果。 为了更清楚的理解
查看 Trial 状态
查看 Trial 状态
------------------
------------------
点击 ``Trials Detail`` 标签查看所有 Trial 的状态。 特别是:
点击 ``Trials Detail`` 标签查看所有 Trial 的状态。 特别是:
特别是:
* Trial 详情:Trial 的 id,持续时间,开始时间,结束时间,状态,精度和搜索空间文件。
* Trial 详情:Trial 的 id,持续时间,开始时间,结束时间,状态,精度和搜索空间文件。
...
@@ -207,7 +207,44 @@ Trial 可能在训练过程中有大量中间结果。 为了更清楚的理解
...
@@ -207,7 +207,44 @@ Trial 可能在训练过程中有大量中间结果。 为了更清楚的理解
* ``Add column`` 按钮可选择在表格中显示的列。 如果 Experiment 的最终结果是 dict,则可以在表格中查看其它键。 可选择 ``Intermediate count`` 列来查看 Trial 进度。
* 支持通过 id,状态,Trial 编号, 以及参数来搜索。
1. Trial id:
.. image:: ../../img/webui-img/search-trial.png
:target: ../../img/webui-img/search-trial.png
:alt: searchTrial
2. Trial No.:
.. image:: ../../img/webui-img/detail/searchNo.png
:target: ../../img/webui-img/detail/searchNo.png
:alt: searchTrialNo.
3. Trial 状态:
.. image:: ../../img/webui-img/detail/searchStatus.png
:target: ../../img/webui-img/detail/searchStatus.png
:alt: searchStatus
4. Trial 参数:
(1) 类型为 choice 的参数:
.. image:: ../../img/webui-img/detail/searchParameterChoice.png
:target: ../../img/webui-img/detail/searchParameterChoice.png
:alt: searchParameterChoice
(2) 类型不是 choice 的参数:
.. image:: ../../img/webui-img/detail/searchParameterRange.png
:target: ../../img/webui-img/detail/searchParameterRange.png
:alt: searchParameterRange
* ``Add column`` 按钮可选择在表格中显示的列。 如果 Experiment 的最终结果是 dict,则可以在表格中查看其它键。 * ``Add column`` 按钮可选择在表格中显示的列。 如果 Experiment 的最终结果是 dict,则可以在表格中查看其它键。 可选择 ``Intermediate count`` 列来查看 Trial 进度。
.. image:: ../../img/webui-img/addColumn.png
.. image:: ../../img/webui-img/addColumn.png
...
@@ -229,13 +266,7 @@ Trial 可能在训练过程中有大量中间结果。 为了更清楚的理解
...
@@ -229,13 +266,7 @@ Trial 可能在训练过程中有大量中间结果。 为了更清楚的理解
:alt: compareTrialsGraph
:alt: compareTrialsGraph
* ``Tensorboard`` 请参考 `此文档 <Tensorboard.rst>`__。
* 支持通过 id,状态,Trial 编号, 以及参数来搜索。
.. image:: ../../img/webui-img/search-trial.png
:target: ../../img/webui-img/search-trial.png
:alt: searchTrial
...
@@ -248,15 +279,22 @@ Trial 可能在训练过程中有大量中间结果。 为了更清楚的理解
...
@@ -248,15 +279,22 @@ Trial 可能在训练过程中有大量中间结果。 为了更清楚的理解
* 如果在 OpenPAI 或 Kubeflow 平台上运行,还可以看到 hdfsLog。
* 您可以在 ``Log`` 选项卡上看到 Trial 日志。 在本地模式下有 ``View trial log``, ``View trial error`` 和 ``View trial stdout`` 三个按钮。 * 如果在 OpenPAI 或 Kubeflow 平台上运行,还可以看到 hdfsLog。
1. 本机模式
.. image:: ../../img/webui-img/detail/log-local.png
:target: ../../img/webui-img/detail/log-local.png
:alt: logOnLocal
2. OpenPAI、Kubeflow 等模式:
.. image:: ../../img/webui-img/detail-pai.png
.. image:: ../../img/webui-img/detail-pai.png
:target: ../../img/webui-img/detail-pai.png
:target: ../../img/webui-img/detail-pai.png
:alt: detailPai
:alt: detailPai
* 中间结果图:可在此图中通过点击 intermediate 按钮来查看默认指标。
* 中间结果图:可在此图中通过点击 intermediate 按钮来查看默认指标。
...
@@ -273,3 +311,16 @@ Trial 可能在训练过程中有大量中间结果。 为了更清楚的理解
...
@@ -273,3 +311,16 @@ Trial 可能在训练过程中有大量中间结果。 为了更清楚的理解
:target: ../../img/webui-img/kill-running.png
:target: ../../img/webui-img/kill-running.png
:alt: killTrial
:alt: killTrial
* 自定义 Trial:您可以更改此 Trial 参数,然后将其提交给 Experiment。 如果您想重新运行失败的 Trial ,您可以向 Experiment 提交相同的参数。
.. image:: ../../img/webui-img/detail/customizedTrialButton.png
:target: ../../img/webui-img/detail/customizedTrialButton.png
:alt: customizedTrialButton
.. image:: ../../img/webui-img/detail/customizedTrial.png
:target: ../../img/webui-img/detail/customizedTrial.png
:alt: customizedTrial
docs/zh_CN/Tutorial/python_api_connect.ipynb
View file @
403195f0
...
@@ -26,7 +26,6 @@
...
@@ -26,7 +26,6 @@
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"[2021-02-25 07:50:38] Tuner not set, wait for connect...\n",
"[2021-02-25 07:50:38] Connect to port 8080 success, experiment id is IF0JnfLE, status is RUNNING.\n"
"[2021-02-25 07:50:38] Connect to port 8080 success, experiment id is IF0JnfLE, status is RUNNING.\n"
]
]
}
}
...
@@ -55,7 +54,7 @@
...
@@ -55,7 +54,7 @@
"text/plain": [
"text/plain": [
"{'id': 'IF0JnfLE',\n",
"{'id': 'IF0JnfLE',\n",
" 'revision': 6,\n",
" 'revision': 6,\n",
"
'execDuration
':
28
,\n",
"
'maxTrialNum
':
10
,\n",
" 'logDir': '/home/ningshang/nni-experiments/IF0JnfLE',\n",
" 'logDir': '/home/ningshang/nni-experiments/IF0JnfLE',\n",
" 'nextSequenceId': 2,\n",
" 'nextSequenceId': 2,\n",
" 'params': {'authorName': 'default',\n",
" 'params': {'authorName': 'default',\n",
...
@@ -90,7 +89,15 @@
...
@@ -90,7 +89,15 @@
"execution_count": 3,
"execution_count": 3,
"id": "printable-bookmark",
"id": "printable-bookmark",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[2021-03-05 12:18:32] (root) Successfully update maxTrialNum.\n"
]
}
],
"source": [
"source": [
"experiment.update_max_trial_number(10)"
"experiment.update_max_trial_number(10)"
]
]
...
@@ -106,14 +113,14 @@
...
@@ -106,14 +113,14 @@
"text/plain": [
"text/plain": [
"{'id': 'IF0JnfLE',\n",
"{'id': 'IF0JnfLE',\n",
" 'revision': 8,\n",
" 'revision': 8,\n",
" 'execDuration':
3
2,\n",
" 'execDuration': 2
8
,\n",
" 'logDir': '/home/ningshang/nni-experiments/IF0JnfLE',\n",
" 'logDir': '/home/ningshang/nni-experiments/IF0JnfLE',\n",
" 'nextSequenceId': 2,\n",
" 'nextSequenceId': 2,\n",
" 'params': {'authorName': 'default',\n",
" 'params': {'authorName': 'default',\n",
" 'experimentName': 'example_sklearn-classification',\n",
" 'experimentName': 'example_sklearn-classification',\n",
" 'trialConcurrency': 1,\n",
" 'trialConcurrency': 1,\n",
" 'maxExecDuration': 3600,\n",
" 'maxExecDuration': 3600,\n",
" 'maxTrialNum':
1
0,\n",
" 'maxTrialNum':
20
0,\n",
" 'searchSpace': '{\"C\": {\"_type\": \"uniform\", \"_value\": [0.1, 1]}, \"kernel\": {\"_type\": \"choice\", \"_value\": [\"linear\", \"rbf\", \"poly\", \"sigmoid\"]}, \"degree\": {\"_type\": \"choice\", \"_value\": [1, 2, 3, 4]}, \"gamma\": {\"_type\": \"uniform\", \"_value\": [0.01, 0.1]}, \"coef0\": {\"_type\": \"uniform\", \"_value\": [0.01, 0.1]}}',\n",
" 'searchSpace': '{\"C\": {\"_type\": \"uniform\", \"_value\": [0.1, 1]}, \"kernel\": {\"_type\": \"choice\", \"_value\": [\"linear\", \"rbf\", \"poly\", \"sigmoid\"]}, \"degree\": {\"_type\": \"choice\", \"_value\": [1, 2, 3, 4]}, \"gamma\": {\"_type\": \"uniform\", \"_value\": [0.01, 0.1]}, \"coef0\": {\"_type\": \"uniform\", \"_value\": [0.01, 0.1]}}',\n",
" 'trainingServicePlatform': 'local',\n",
" 'trainingServicePlatform': 'local',\n",
" 'tuner': {'builtinTunerName': 'TPE',\n",
" 'tuner': {'builtinTunerName': 'TPE',\n",
...
...
docs/zh_CN/Tutorial/python_api_start.ipynb
View file @
403195f0
...
@@ -8,36 +8,17 @@
...
@@ -8,36 +8,17 @@
"## 启动并管理一个新的 Experiment"
"## 启动并管理一个新的 Experiment"
]
]
},
},
{
"cell_type": "markdown",
"id": "immediate-daily",
"metadata": {},
"source": [
"### 1. 初始化 Tuner"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "formed-grounds",
"metadata": {},
"outputs": [],
"source": [
"from nni.algorithms.hpo.gridsearch_tuner import GridSearchTuner\n",
"tuner = GridSearchTuner()"
]
},
{
{
"cell_type": "markdown",
"cell_type": "markdown",
"id": "reported-somerset",
"id": "reported-somerset",
"metadata": {},
"metadata": {},
"source": [
"source": [
"###
2
. 定义搜索空间"
"###
1
. 定义搜索空间"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
2
,
"execution_count":
1
,
"id": "potential-williams",
"id": "potential-williams",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
...
@@ -56,24 +37,27 @@
...
@@ -56,24 +37,27 @@
"id": "greek-archive",
"id": "greek-archive",
"metadata": {},
"metadata": {},
"source": [
"source": [
"###
3
. 配置 Experiment "
"###
2
. 配置 Experiment "
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
3
,
"execution_count":
2
,
"id": "fiscal-expansion",
"id": "fiscal-expansion",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"from nni.experiment import Experiment\n",
"from nni.experiment import Experiment\n",
"experiment = Experiment(
tuner,
'local')\n",
"experiment = Experiment('local')\n",
"experiment.config.experiment_name = '
test
'\n",
"experiment.config.experiment_name = '
Example
'\n",
"experiment.config.trial_concurrency = 2\n",
"experiment.config.trial_concurrency = 2\n",
"experiment.config.max_trial_number =
5
\n",
"experiment.config.max_trial_number =
10
\n",
"experiment.config.search_space = search_space\n",
"experiment.config.search_space = search_space\n",
"experiment.config.trial_command = 'python3 main.py'\n",
"experiment.config.trial_command = 'python3 main.py'\n",
"experiment.config.trial_code_directory = './'"
"experiment.config.trial_code_directory = './'\n",
"experiment.config.tuner.name = 'TPE'\n",
"experiment.config.tuner.class_args['optimize_mode'] = 'maximize'\n",
"experiment.config.training_service.use_active_gpu = True"
]
]
},
},
{
{
...
@@ -81,12 +65,12 @@
...
@@ -81,12 +65,12 @@
"id": "received-tattoo",
"id": "received-tattoo",
"metadata": {},
"metadata": {},
"source": [
"source": [
"###
4
. 启动 Experiment"
"###
3
. 启动 Experiment"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
4
,
"execution_count":
3
,
"id": "pleasant-patent",
"id": "pleasant-patent",
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
...
@@ -94,17 +78,15 @@
...
@@ -94,17 +78,15 @@
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"[2021-02-22 12:27:11] Creating experiment, Experiment ID: bj025qo4\n",
"[2021-03-05 12:12:19] Creating experiment, Experiment ID: wdt0le3v\n",
"[2021-02-22 12:27:11] Connecting IPC pipe...\n",
"[2021-03-05 12:12:19] Starting web server...\n",
"[2021-02-22 12:27:15] Statring web server...\n",
"[2021-03-05 12:12:20] Setting up...\n",
"[2021-02-22 12:27:16] Setting up...\n",
"[2021-03-05 12:12:20] Web UI URLs: http://127.0.0.1:8080 http://10.0.1.5:8080 http://172.17.0.1:8080\n"
"[2021-02-22 12:27:16] Dispatcher started\n",
"[2021-02-22 12:27:16] Web UI URLs: http://127.0.0.1:8081 http://10.0.1.5:8081 http://172.17.0.1:8081\n"
]
]
}
}
],
],
"source": [
"source": [
"experiment.start(808
1
)"
"experiment.start(808
0
)"
]
]
},
},
{
{
...
@@ -112,12 +94,12 @@
...
@@ -112,12 +94,12 @@
"id": "miniature-prison",
"id": "miniature-prison",
"metadata": {},
"metadata": {},
"source": [
"source": [
"###
5
. Experiment 查看和管理"
"###
4
. Experiment 查看和管理"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
5
,
"execution_count":
4
,
"id": "animated-english",
"id": "animated-english",
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
...
@@ -127,7 +109,7 @@
...
@@ -127,7 +109,7 @@
"'RUNNING'"
"'RUNNING'"
]
]
},
},
"execution_count":
5
,
"execution_count":
4
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
...
@@ -138,18 +120,18 @@
...
@@ -138,18 +120,18 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
6
,
"execution_count":
5
,
"id": "alpha-ottawa",
"id": "alpha-ottawa",
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"data": {
"data": {
"text/plain": [
"text/plain": [
"[TrialResult(parameter={'
coef0': 0.01, 'gamma': 0.01
, 'degree':
1
, '
kernel': 'linear', 'C
': 0.
1
}, value=0.98
66666666666667
, trialJobId='
B55mT
'),\n",
"[TrialResult(parameter={'
C': 0.30000000000000004, 'kernel': 'linear'
, 'degree':
3
, '
gamma': 0.03, 'coef0
': 0.
07
}, value=0.98
88888888888889
, trialJobId='
VLqU9
'),\n",
" TrialResult(parameter={'
coef0
': 0.
02
, '
gamma': 0.01, 'degree': 1, 'kernel': 'linear', 'C
': 0.
1
}, value=0.
9866666666666667
, trialJobId='
QkhD0
')]"
" TrialResult(parameter={'
C
': 0.
5
, '
kernel': 'sigmoid', 'degree': 1, 'gamma': 0.03, 'coef0
': 0.
07
}, value=0.
8888888888888888
, trialJobId='
DLo6r
')]"
]
]
},
},
"execution_count":
6
,
"execution_count":
5
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
...
@@ -160,18 +142,18 @@
...
@@ -160,18 +142,18 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
7
,
"execution_count":
6
,
"id": "unique-rendering",
"id": "unique-rendering",
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"data": {
"data": {
"text/plain": [
"text/plain": [
"{'
B55mT
': [TrialMetricData(timestamp=161
3996853005
, trialJobId='
B55mT
', parameterId='
0
', type='FINAL', sequence=0, data=0.
9866666666666667
)],\n",
"{'
DLo6r
': [TrialMetricData(timestamp=161
4946351592
, trialJobId='
DLo6r
', parameterId='
1
', type='FINAL', sequence=0, data=0.
8888888888888888
)],\n",
" '
QkhD0
': [TrialMetricData(timestamp=161
3996853843
, trialJobId='
QkhD0
', parameterId='
1
', type='FINAL', sequence=0, data=0.98
66666666666667
)]}"
" '
VLqU9
': [TrialMetricData(timestamp=161
4946351607
, trialJobId='
VLqU9
', parameterId='
0
', type='FINAL', sequence=0, data=0.98
88888888888889
)]}"
]
]
},
},
"execution_count":
7
,
"execution_count":
6
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
...
@@ -185,12 +167,12 @@
...
@@ -185,12 +167,12 @@
"id": "welsh-difference",
"id": "welsh-difference",
"metadata": {},
"metadata": {},
"source": [
"source": [
"###
6
. 停止 Experiment"
"###
5
. 停止 Experiment"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
8
,
"execution_count":
7
,
"id": "technological-cleanup",
"id": "technological-cleanup",
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
...
@@ -198,10 +180,8 @@
...
@@ -198,10 +180,8 @@
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"[2021-02-22 12:28:16] Stopping experiment, please wait...\n",
"[2021-03-05 12:12:40] Stopping experiment, please wait...\n",
"[2021-02-22 12:28:16] Dispatcher exiting...\n",
"[2021-03-05 12:12:42] Experiment stopped\n"
"[2021-02-22 12:28:17] Experiment stopped\n",
"[2021-02-22 12:28:19] Dispatcher terminiated\n"
]
]
}
}
],
],
...
@@ -231,4 +211,4 @@
...
@@ -231,4 +211,4 @@
},
},
"nbformat": 4,
"nbformat": 4,
"nbformat_minor": 5
"nbformat_minor": 5
}
}
\ No newline at end of file
docs/zh_CN/_templates/index.html
View file @
403195f0
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
{% block document %}
{% block document %}
<div>
<div>
<div
class=
"chinese"
><a
href=
"https://nni.readthedocs.io/
en/latest
/"
>
English
</a></div>
<div
class=
"chinese"
><a
href=
"https://nni.readthedocs.io/
zh/stable
/"
>
English
</a></div>
<b>
NNI (Neural Network Intelligence)
</b>
是一个轻量但强大的工具包,帮助用户
<b>
自动
</b>
的进行
<b>
NNI (Neural Network Intelligence)
</b>
是一个轻量但强大的工具包,帮助用户
<b>
自动
</b>
的进行
<a
href=
"{{ pathto('FeatureEngineering/Overview') }}"
>
特征工程
</a>
,
<a
href=
"{{ pathto('NAS/Overview') }}"
>
神经网络架构搜索
</a>
,
<a
href=
"{{ pathto('Tuner/BuiltinTuner') }}"
>
超参调优
</a>
以及
<a
href=
"{{ pathto('Compression/Overview') }}"
>
模型压缩
</a>
。
<a
href=
"{{ pathto('FeatureEngineering/Overview') }}"
>
特征工程
</a>
,
<a
href=
"{{ pathto('NAS/Overview') }}"
>
神经网络架构搜索
</a>
,
<a
href=
"{{ pathto('Tuner/BuiltinTuner') }}"
>
超参调优
</a>
以及
<a
href=
"{{ pathto('Compression/Overview') }}"
>
模型压缩
</a>
。
</div>
</div>
...
@@ -99,13 +99,14 @@
...
@@ -99,13 +99,14 @@
<ul
class=
"circle"
>
<ul
class=
"circle"
>
<li><a
href=
"https://github.com/microsoft/nni/tree/master/examples/trials/mnist-pytorch"
>
MNIST-pytorch
</li>
<li><a
href=
"https://github.com/microsoft/nni/tree/master/examples/trials/mnist-pytorch"
>
MNIST-pytorch
</li>
</a>
</a>
<li><a
href=
"https://github.com/microsoft/nni/tree/master/examples/trials/mnist-tfv
1
"
>
MNIST-tensorflow
</li>
<li><a
href=
"https://github.com/microsoft/nni/tree/master/examples/trials/mnist-tfv
2
"
>
MNIST-tensorflow
</li>
</a>
</a>
<li><a
href=
"https://github.com/microsoft/nni/tree/master/examples/trials/mnist-keras"
>
MNIST-keras
</li></a>
<li><a
href=
"https://github.com/microsoft/nni/tree/master/examples/trials/mnist-keras"
>
MNIST-keras
</li></a>
<li><a
href=
"{{ pathto('TrialExample/GbdtExample') }}"
>
Auto-gbdt
</a></li>
<li><a
href=
"{{ pathto('TrialExample/GbdtExample') }}"
>
Auto-gbdt
</a></li>
<li><a
href=
"{{ pathto('TrialExample/Cifar10Examples') }}"
>
Cifar10-pytorch
</li></a>
<li><a
href=
"{{ pathto('TrialExample/Cifar10Examples') }}"
>
Cifar10-pytorch
</li></a>
<li><a
href=
"{{ pathto('TrialExample/SklearnExamples') }}"
>
Scikit-learn
</a></li>
<li><a
href=
"{{ pathto('TrialExample/SklearnExamples') }}"
>
Scikit-learn
</a></li>
<li><a
href=
"{{ pathto('TrialExample/EfficientNet') }}"
>
EfficientNet
</a></li>
<li><a
href=
"{{ pathto('TrialExample/EfficientNet') }}"
>
EfficientNet
</a></li>
<li><a
href=
"{{ pathto('TrialExample/OpEvoExamples') }}"
>
GPU Kernel 调优
</li></a>
<a
href=
"{{ pathto('SupportedFramework_Library') }}"
>
更多...
</a><br
/>
<a
href=
"{{ pathto('SupportedFramework_Library') }}"
>
更多...
</a><br
/>
</ul>
</ul>
</ul>
</ul>
...
@@ -115,27 +116,25 @@
...
@@ -115,27 +116,25 @@
<ul
class=
"firstUl"
>
<ul
class=
"firstUl"
>
<div><b>
穷举搜索
</b></div>
<div><b>
穷举搜索
</b></div>
<ul
class=
"circle"
>
<ul
class=
"circle"
>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}"
>
Random Search(随机搜索)
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}
#Random
"
>
Random Search(随机搜索)
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}"
>
Grid Search(遍历搜索)
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}
#GridSearch
"
>
Grid Search(遍历搜索)
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}"
>
Batch(批处理)
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}
#Batch
"
>
Batch(批处理)
</a></li>
</ul>
</ul>
<div><b>
启发式搜索
</b></div>
<div><b>
启发式搜索
</b></div>
<ul
class=
"circle"
>
<ul
class=
"circle"
>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}"
>
Naïve Evolution(朴素进化)
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}#Evolution"
>
Naïve Evolution(朴素进化)
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}"
>
Anneal(退火算法)
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}#Anneal"
>
Anneal(退火算法)
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}"
>
Hyperband
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}#Hyperband"
>
Hyperband
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}#PBTTuner"
>
P-DARTS
</a></li>
</ul>
</ul>
<div><b>
贝叶斯优化
</b></div>
<div><b>
贝叶斯优化
</b></div>
<ul
class=
"circle"
>
<ul
class=
"circle"
>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}"
>
BOHB
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}#BOHB"
>
BOHB
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}"
>
TPE
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}#TPE"
>
TPE
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}"
>
SMAC
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}#SMAC"
>
SMAC
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}"
>
Metis Tuner
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}#MetisTuner"
>
Metis Tuner
</a></li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}"
>
GP Tuner
</a>
</li>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}#GPTuner"
>
GP Tuner
</a>
</li>
</ul>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}#DNGOTuner"
>
PPO Tuner
</a></li>
<div><b>
基于强化学习
</b></div>
<ul
class=
"circle"
>
<li><a
href=
"{{ pathto('Tuner/BuiltinTuner') }}"
>
PPO Tuner
</a>
</li>
</ul>
</ul>
</ul>
</ul>
<a
href=
"{{ pathto('NAS/Overview') }}"
>
神经网络架构搜索
</a>
<a
href=
"{{ pathto('NAS/Overview') }}"
>
神经网络架构搜索
</a>
...
@@ -143,26 +142,32 @@
...
@@ -143,26 +142,32 @@
<ul
class=
"circle"
>
<ul
class=
"circle"
>
<li><a
href=
"{{ pathto('NAS/ENAS') }}"
>
ENAS
</a></li>
<li><a
href=
"{{ pathto('NAS/ENAS') }}"
>
ENAS
</a></li>
<li><a
href=
"{{ pathto('NAS/DARTS') }}"
>
DARTS
</a></li>
<li><a
href=
"{{ pathto('NAS/DARTS') }}"
>
DARTS
</a></li>
<li><a
href=
"{{ pathto('NAS/PDARTS') }}"
>
P-DARTS
</a></li>
<li><a
href=
"{{ pathto('NAS/CDARTS') }}"
>
CDARTS
</a></li>
<li><a
href=
"{{ pathto('NAS/SPOS') }}"
>
SPOS
</a></li>
<li><a
href=
"{{ pathto('NAS/SPOS') }}"
>
SPOS
</a></li>
<li><a
href=
"{{ pathto('NAS/Proxylessnas') }}"
>
ProxylessNAS
</a></li>
<li><a
href=
"{{ pathto('NAS/Proxylessnas') }}"
>
ProxylessNAS
</a></li>
<li><a
href=
"{{ pathto('Tuner/NetworkmorphismTuner') }}"
>
Network Morphism
</a>
</li>
<li><a
href=
"{{ pathto('NAS/FBNet') }}"
>
微信
</a></li>
<li><a
href=
"{{ pathto('NAS/TextNAS') }}"
>
TextNAS
</a>
</li>
<li><a
href=
"{{ pathto('NAS/ExplorationStrategies') }}"
>
基于强化学习
</a></li>
<li><a
href=
"{{ pathto('NAS/ExplorationStrategies') }}"
>
Network Morphism
</a></li>
<li><a
href=
"{{ pathto('NAS/Overview') }}"
>
TextNAS
</a></li>
</ul>
</ul>
</ul>
</ul>
<a
href=
"{{ pathto('Compression/Overview') }}"
>
模型压缩
</a>
<a
href=
"{{ pathto('Compression/Overview') }}"
>
模型压缩
</a>
<ul
class=
"firstUl"
>
<ul
class=
"firstUl"
>
<div><b>
剪枝
</b></div>
<div><b>
剪枝
</b></div>
<ul
class=
"circle"
>
<ul
class=
"circle"
>
<li><a
href=
"{{ pathto('Compression/Pruner') }}"
>
AGP Pruner
</a></li>
<li><a
href=
"{{ pathto('Compression/Pruner') }}#agp-pruner"
>
AGP Pruner
</a></li>
<li><a
href=
"{{ pathto('Compression/Pruner') }}"
>
Slim Pruner
</a></li>
<li><a
href=
"{{ pathto('Compression/Pruner') }}#slim-pruner"
>
Slim Pruner
</a></li>
<li><a
href=
"{{ pathto('Compression/Pruner') }}"
>
FPGM Pruner
</a></li>
<li><a
href=
"{{ pathto('Compression/Pruner') }}#fpgm-pruner"
>
FPGM Pruner
</a></li>
<li><a
href=
"{{ pathto('Compression/Pruner') }}#netadapt-pruner"
>
NetAdapt Pruner
</a></li>
<li><a
href=
"{{ pathto('Compression/Pruner') }}#simulatedannealing-pruner"
>
SimulatedAnnealing Pruner
</a></li>
<li><a
href=
"{{ pathto('Compression/Pruner') }}#admm-pruner"
>
ADMM Pruner
</a></li>
<li><a
href=
"{{ pathto('Compression/Pruner') }}#autocompress-pruner"
>
AutoCompress Pruner
</a></li>
<li><a
href=
"{{ pathto('Compression/Overview') }}"
>
更多...
</a></li>
</ul>
</ul>
<div><b>
量化
</b></div>
<div><b>
量化
</b></div>
<ul
class=
"circle"
>
<ul
class=
"circle"
>
<li><a
href=
"{{ pathto('Compression/Quantizer') }}"
>
QAT Quantizer
</a></li>
<li><a
href=
"{{ pathto('Compression/Quantizer') }}#qat-quantize"
>
QAT Quantizer
</a></li>
<li><a
href=
"{{ pathto('Compression/Quantizer') }}"
>
DoReFa Quantizer
</a></li>
<li><a
href=
"{{ pathto('Compression/Quantizer') }}#dorefa-quantizer"
>
DoReFa Quantizer
</a></li>
<li><a
href=
"{{ pathto('Compression/Quantizer') }}#bnn-quantizer"
>
BNN Quantizer
</a></li>
</ul>
</ul>
</ul>
</ul>
<a
href=
"{{ pathto('FeatureEngineering/Overview') }}"
>
特征工程(测试版)
</a>
<a
href=
"{{ pathto('FeatureEngineering/Overview') }}"
>
特征工程(测试版)
</a>
...
@@ -172,22 +177,23 @@
...
@@ -172,22 +177,23 @@
</ul>
</ul>
<a
href=
"{{ pathto('Assessor/BuiltinAssessor') }}"
>
提前终止算法
</a>
<a
href=
"{{ pathto('Assessor/BuiltinAssessor') }}"
>
提前终止算法
</a>
<ul
class=
"circle"
>
<ul
class=
"circle"
>
<li><a
href=
"{{ pathto('Assessor/BuiltinAssessor') }}"
>
Median Stop(中位数终止)
</a></li>
<li><a
href=
"{{ pathto('Assessor/BuiltinAssessor') }}
#MedianStop
"
>
Median Stop(中位数终止)
</a></li>
<li><a
href=
"{{ pathto('Assessor/BuiltinAssessor') }}"
>
Curve Fitting(曲线拟合)
</a></li>
<li><a
href=
"{{ pathto('Assessor/BuiltinAssessor') }}
#Curvefitting
"
>
Curve Fitting(曲线拟合)
</a></li>
</ul>
</ul>
</td>
</td>
<td>
<td>
<ul
class=
"firstUl"
>
<ul
class=
"firstUl"
>
<li><a
href=
"{{ pathto('TrainingService/LocalMode') }}"
>
本机
</a></li>
<li><a
href=
"{{ pathto('TrainingService/LocalMode') }}"
>
本机
</a></li>
<li><a
href=
"{{ pathto('TrainingService/RemoteMachineMode') }}"
>
远程计算机
</a></li>
<li><a
href=
"{{ pathto('TrainingService/RemoteMachineMode') }}"
>
远程计算机
</a></li>
<li><a
href=
"{{ pathto('TrainingService/HybridMode') }}"
>
混合模式
</a></li>
<li><a
href=
"{{ pathto('TrainingService/AMLMode') }}"
>
AML(Azure Machine Learning)
</a></li>
<li><b>
基于 Kubernetes 的平台
</b></li>
<li><b>
基于 Kubernetes 的平台
</b></li>
<ul
class=
"circle"
>
<ul>
<li><a
href=
"{{ pathto('TrainingService/PaiMode') }}"
>
OpenPAI
</a></li>
<li><a
href=
"{{ pathto('TrainingService/PaiMode') }}"
>
OpenPAI
</a></li>
<li><a
href=
"{{ pathto('TrainingService/KubeflowMode') }}"
>
Kubeflow
</a></li>
<li><a
href=
"{{ pathto('TrainingService/KubeflowMode') }}"
>
Kubeflow
</a></li>
<li><a
href=
"{{ pathto('TrainingService/FrameworkControllerMode') }}"
>
基于 K8S 的 FrameworkController (如 AKS 等)
</a>
<li><a
href=
"{{ pathto('TrainingService/FrameworkControllerMode') }}"
>
基于 K8S 的 FrameworkController (如 AKS 等)
</a></li>
</li>
<li><a
href=
"{{ pathto('TrainingService/DLTSMode') }}"
>
DLWorkspace (又称 DLTS)
</a></li>
<li><a
href=
"{{ pathto('TrainingService/DLTSMode') }}"
>
DLWorkspace (又称 DLTS)
</a></li>
<li><a
href=
"{{ pathto('TrainingService/A
M
LMode') }}"
>
AML (Azure Machine Learning)
</a></li>
<li><a
href=
"{{ pathto('TrainingService/A
daptD
LMode') }}"
>
AML (Azure Machine Learning)
</a></li>
</ul>
</ul>
</ul>
</ul>
</td>
</td>
...
@@ -196,9 +202,9 @@
...
@@ -196,9 +202,9 @@
<td
class=
"verticalMiddle"
><b>
参考
</b></td>
<td
class=
"verticalMiddle"
><b>
参考
</b></td>
<td>
<td>
<ul
class=
"firstUl"
>
<ul
class=
"firstUl"
>
<li><a
href=
"
https://nni.readthedocs.io/zh/latest/autotune_ref.html#trial
"
>
Python API
</a></li>
<li><a
href=
"
{{ pathto('Tutorial/HowToLaunchFromPython') }}
"
>
Python API
</a></li>
<li><a
href=
"{{ pathto('Tutorial/AnnotationSpec') }}"
>
NNI Annotation
</a></li>
<li><a
href=
"{{ pathto('Tutorial/AnnotationSpec') }}"
>
NNI Annotation
</a></li>
<li><a
href=
"
https://nni.readthedocs.io/zh/latest/
installation
.html
"
>
支持的操作系统
</a></li>
<li><a
href=
"
{{ pathto('
installation
') }}
"
>
支持的操作系统
</a></li>
</ul>
</ul>
</td>
</td>
<td>
<td>
...
@@ -206,6 +212,8 @@
...
@@ -206,6 +212,8 @@
<li><a
href=
"{{ pathto('Tuner/CustomizeTuner') }}"
>
自定义 Tuner
</a></li>
<li><a
href=
"{{ pathto('Tuner/CustomizeTuner') }}"
>
自定义 Tuner
</a></li>
<li><a
href=
"{{ pathto('Assessor/CustomizeAssessor') }}"
>
自定义 Assessor
</a></li>
<li><a
href=
"{{ pathto('Assessor/CustomizeAssessor') }}"
>
自定义 Assessor
</a></li>
<li><a
href=
"{{ pathto('Tutorial/InstallCustomizedAlgos') }}"
>
安装自定义的 Tuner,Assessor,Advisor
</a></li>
<li><a
href=
"{{ pathto('Tutorial/InstallCustomizedAlgos') }}"
>
安装自定义的 Tuner,Assessor,Advisor
</a></li>
<li><a
href=
"{{ pathto('NAS/QuickStart') }}"
>
定义 NAS 模型空间
</a></li>
<li><a
href=
"{{ pathto('NAS/ApiReference') }}"
>
NAS/Retiarii APIs
</a></li>
</ul>
</ul>
</td>
</td>
<td>
<td>
...
@@ -224,7 +232,7 @@
...
@@ -224,7 +232,7 @@
<div>
<div>
<h2
class=
"second-title"
>
安装
</h2>
<h2
class=
"second-title"
>
安装
</h2>
<p>
<p>
NNI 支持并在 Ubuntu >= 16.04, macOS >= 10.14.1, 和 Windows 10 >= 1809 通过了测试。 在
`
python 64
位
>= 3.6
`
的环境中,只需要运行
`
pip install
`
即可完成安装。
NNI 支持并在 Ubuntu >= 16.04, macOS >= 10.14.1, 和 Windows 10 >= 1809 通过了测试。 在
<code>
python 64
-bit
>= 3.6
</code>
的环境中,只需要运行
<code>
pip install
</code>
即可完成安装。
</p>
</p>
<div
class=
"command-intro"
>
Linux 或 macOS
</div>
<div
class=
"command-intro"
>
Linux 或 macOS
</div>
<div
class=
"command"
>
python3 -m pip install --upgrade nni
</div>
<div
class=
"command"
>
python3 -m pip install --upgrade nni
</div>
...
@@ -241,7 +249,7 @@
...
@@ -241,7 +249,7 @@
<li>
如果遇到任何权限问题,可添加 --user 在用户目录中安装 NNI。
</li>
<li>
如果遇到任何权限问题,可添加 --user 在用户目录中安装 NNI。
</li>
<li>
目前,Windows 上的 NNI 支持本机,远程和 OpenPAI 模式。 强烈推荐使用 Anaconda 或 Miniconda
<a
href=
"{{ pathto('Tutorial/InstallationWin') }}"
>
在 Windows 上安装 NNI
</a>
。
</li>
<li>
目前,Windows 上的 NNI 支持本机,远程和 OpenPAI 模式。 强烈推荐使用 Anaconda 或 Miniconda
<a
href=
"{{ pathto('Tutorial/InstallationWin') }}"
>
在 Windows 上安装 NNI
</a>
。
</li>
<li>
如果遇到如 Segmentation fault 这样的任何错误请参考
<a
<li>
如果遇到如 Segmentation fault 这样的任何错误请参考
<a
href=
"{{ pathto('installation') }}"
>
常见问题
</a>
。 Windows 上的常见问题,参考在
<a
href=
"{{ pathto('Tutorial/InstallationWin') }}"
>
Windows 上使用 NNI
</a>
。
</li>
href=
"{{ pathto('installation') }}"
>
常见问题
</a>
。 Windows 上的常见问题,参考在
<a
href=
"{{ pathto('Tutorial/InstallationWin') }}"
>
Windows 上使用
NNI
</a>
。 Windows 上的常见问题,参考在
<a
href=
"{{ pathto('Tutorial/InstallationWin') }}"
>
Windows 上使用
NNI
</a>
。
</li>
</ul>
</ul>
</div>
</div>
<div>
<div>
...
@@ -296,10 +304,7 @@ You can use these commands to get more information about the experiment
...
@@ -296,10 +304,7 @@ You can use these commands to get more information about the experiment
</li>
</li>
<li>
<li>
在浏览器中打开 Web UI 地址,可看到下图的 Experiment 详细信息,以及所有的 Trial 任务。 查看
<a
href=
"{{ pathto('Tutorial/WebUI') }}"
>
这里的
</a>
更多页面示例。
在浏览器中打开 Web UI 地址,可看到下图的 Experiment 详细信息,以及所有的 Trial 任务。 查看
<a
href=
"{{ pathto('Tutorial/WebUI') }}"
>
这里的
</a>
更多页面示例。
<div
class=
"ui-img"
>
<img
src=
"_static/img/webui.gif"
width=
"100%"
/>
<img
src=
"_images/webui_overview_page.png"
>
<img
src=
"_images/webui_trialdetail_page.png"
>
</div>
</div>
</div>
</li>
</li>
</ul>
</ul>
...
@@ -360,8 +365,7 @@ You can use these commands to get more information about the experiment
...
@@ -360,8 +365,7 @@ You can use these commands to get more information about the experiment
<h2>
外部代码库
</h2>
<h2>
外部代码库
</h2>
<li>
在 NNI 中运行
<a
href=
"{{ pathto('NAS/ENAS') }}"
>
ENAS
</a></li>
<li>
在 NNI 中运行
<a
href=
"{{ pathto('NAS/ENAS') }}"
>
ENAS
</a></li>
<li>
<li>
<a
https://github.com/microsoft/nni/blob/master/examples/feature_engineering/auto-feature-engineering/README_zh_CN.md
href=
"https://github.com/microsoft/nni/blob/master/examples/feature_engineering/auto-feature-engineering/README_zh_CN.md"
>
NNI 中的自动特征工程
</a>
</li>
</li>
<li>
使用 NNI 的
<a
<li>
使用 NNI 的
<a
href=
"https://github.com/microsoft/recommenders/blob/master/examples/04_model_select_and_optimize/nni_surprise_svd.ipynb"
>
矩阵分解超参调优
</a></li>
href=
"https://github.com/microsoft/recommenders/blob/master/examples/04_model_select_and_optimize/nni_surprise_svd.ipynb"
>
矩阵分解超参调优
</a></li>
...
...
docs/zh_CN/builtin_tuner.rst
View file @
403195f0
...
@@ -10,9 +10,7 @@ Tuner 从 Trial 接收指标结果,来评估一组超参或网络结构的性
...
@@ -10,9 +10,7 @@ Tuner 从 Trial 接收指标结果,来评估一组超参或网络结构的性
:maxdepth: 1
:maxdepth: 1
概述<Tuner/BuiltinTuner>
概述<Tuner/BuiltinTuner>
TPE<Tuner/HyperoptTuner>
Random Search(随机搜索)<Tuner/HyperoptTuner>
Random Search(随机搜索)<Tuner/HyperoptTuner>
Anneal(退火)<Tuner/HyperoptTuner>
Naïve Evolution(朴素进化)<Tuner/EvolutionTuner>
Naïve Evolution(朴素进化)<Tuner/EvolutionTuner>
SMAC<Tuner/SmacTuner>
SMAC<Tuner/SmacTuner>
Metis Tuner<Tuner/MetisTuner>
Metis Tuner<Tuner/MetisTuner>
...
@@ -22,5 +20,4 @@ Tuner 从 Trial 接收指标结果,来评估一组超参或网络结构的性
...
@@ -22,5 +20,4 @@ Tuner 从 Trial 接收指标结果,来评估一组超参或网络结构的性
Network Morphism<Tuner/NetworkmorphismTuner>
Network Morphism<Tuner/NetworkmorphismTuner>
Hyperband<Tuner/HyperbandAdvisor>
Hyperband<Tuner/HyperbandAdvisor>
BOHB<Tuner/BohbAdvisor>
BOHB<Tuner/BohbAdvisor>
PPO Tuner <Tuner/PPOTuner>
PBT Tuner <Tuner/PBTTuner>
PBT Tuner <Tuner/PBTTuner>
docs/zh_CN/conf.py
View file @
403195f0
...
@@ -27,7 +27,7 @@ author = 'Microsoft'
...
@@ -27,7 +27,7 @@ author = 'Microsoft'
# The short X.Y version
# The short X.Y version
version
=
''
version
=
''
# The full version, including alpha/beta/rc tags
# The full version, including alpha/beta/rc tags
release
=
'v2.
0
'
release
=
'v2.
3
'
# -- General configuration ---------------------------------------------------
# -- General configuration ---------------------------------------------------
...
@@ -51,7 +51,7 @@ extensions = [
...
@@ -51,7 +51,7 @@ extensions = [
]
]
# 添加示例模块
# 添加示例模块
autodoc_mock_imports
=
[
'apex'
,
'nni_node'
]
autodoc_mock_imports
=
[
'apex'
,
'nni_node'
,
'tensorrt'
,
'pycuda'
]
# Add any paths that contain templates here, relative to this directory.
# Add any paths that contain templates here, relative to this directory.
templates_path
=
[
'_templates'
]
templates_path
=
[
'_templates'
]
...
@@ -201,4 +201,4 @@ extlinks = {
...
@@ -201,4 +201,4 @@ extlinks = {
# -- Extension configuration -------------------------------------------------
# -- Extension configuration -------------------------------------------------
def
setup
(
app
):
def
setup
(
app
):
app
.
add_
stylesheet
(
'css/custom.css'
)
app
.
add_
css_file
(
'css/custom.css'
)
docs/zh_CN/hpo_benchmark.rst
0 → 100644
View file @
403195f0
Tuner 基准测试
====================
我们提供了一个基准测试工具来比较 NNI 提供的 Tuner(和用户自定义的 Tuner)在不同任务上的性能。 该工具的实现基于 automlbenchmark 存储库(https://github.com/openml/automlbenchmark),该存储库提供针对由多个 *tasks* 组成的不同 *benchmarks* 运行不同 *frameworks* 的服务。 该工具位于 ``examples/trials/benchmarking/automlbenchmark``。 本文件简要介绍了该工具及其使用方法。
术语
^^^^^^^^^^^
* **task**\ : 一个任务可以被认为是(数据集,评估器)。 它给出了一个包含(训练、验证、测试)的数据集,评估器根据收到的预测结果评估一个给定的指标(例如,回归的 mse,分类的f1)。
* **benchmark**\ : 基准测试是一组任务,以及其他外部约束,例如时间和资源。
* **framework**\ : 给定一个任务,一个框架构思出对所提出的回归或分类问题的答案并产生预测。 请注意,automlbenchmark 框架对框架的假设空间没有任何限制。 在我们在这个文件夹中的实现中,每个框架都是一个元组(tuner,architecture),其中架构提供了假设空间(和 Tuner 的搜索空间),tuner 决定了超参数优化的策略。
* **tuner**\ : hpo 文件夹中定义的 Tuner 或 Advisor,或用户提供的自定义 Tuner。
* **architecture**\ : 架构是解决任务的特定方法,以及一组要优化的超参数(即搜索空间)。 在我们的实现中,该架构多次调用 Tuner 以获得可能的超参数配置,并为任务生成最终预测。在我们的实现中,该架构多次调用 Tuner 以获得可能的超参数配置,并为任务生成最终预测。 查看 ``./nni/extensions/NNI/architectures`` 获取示例。
注意:目前,唯一支持的架构是随机森林。 架构实现和搜索空间定义可以在 ``./nni/extensions/NNI/architectures/run_random_forest.py`` 中找到。 基准测试 “nnivalid” 和 “nnismall” 中的任务适合用随机森林解决。
设置
^^^^^
由于 automlbenchmark 和 python 3.8 之间存在一些不兼容,建议使用 python 3.7 运行此文件夹中包含的实验。 首先,运行以下 shell 脚本来克隆 automlbenchmark 存储库。 注意:建议在单独的虚拟环境中执行以下步骤,因为安装代码可能会安装多个包。
.. code-block:: bash
./setup.sh
在现有 Tuner 上运行预定义的基准测试
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
./runbenchmark_nni.sh [tuner-names]
该脚本运行基准 “nnivalid”,它由一个回归任务、一个二元分类任务和一个多类分类任务组成。 脚本完成后,您可以在文件夹 results_[time]/reports/ 中找到结果摘要。 要在其他预定义基准上运行,请更改 ``runbenchmark_nni.sh`` 中的 ``benchmark`` 变量。 一些基准在 ``/examples/trials/benchmarking/automlbenchmark/nni/benchmarks``\ 中定义,其他基准测试在 ``/examples/trials/benchmarking/automlbenchmark/automlbenchmark/resources/benchmarks/`` 中定义。 大型基准的一个例子是 "nnismall",它包括8个回归任务、8个二元分类任务和8个多类分类任务。
默认情况下,该脚本在NNI的所有嵌入式 Tuner 上运行该基准测试。 如果在 [tuner-names] 中提供了一个 Tuner 的列表,它只运行列表中的 Tuner。 目前,支持以下 Tuner:"TPE", "Random", "Anneal", "Evolution", "SMAC", "GPTuner", "MetisTuner", "DNGOTuner", "Hyperband", "BOHB"。 也可以评估定制 Tuner。 可参考下一章节。
默认情况下,该脚本针对指定的基准逐一运行指定的 Tuner。 为了在后台同时运行所有的实验,在 ``runbenchmark_nni.sh`` 中设置 "serialize" 标志为 false。
注意:SMAC Tuner 、DNGO Tuner 和 BOHB Advisor 必须在运行任何实验之前手动安装。 关于安装SMAC和BOHB的更多细节,请参考 `本页面 <https://nni.readthedocs.io/zh/stable/Tuner/BuiltinTuner.html?highlight=nni>`_ 。
在自定义 Tuner 上运行预定义的基准测试
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
要运行自定义的基准,在 ``./nni/benchmarks`` 文件夹中添加 benchmark_name.yaml 文件,并在 ``runbenchmark_nni.sh`` 中改变 ``benchmark`` 变量。 参见 ``./automlbenchmark/resources/benchmarks/``,了解一些定义自定义基准的例子。
在自定义 Tuner 上运行基准测试
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
要使用自定义 Tuner,首先要确保 Tuner 继承自 ``nni.tuner.Tuner`` 并正确实现所需的API。 关于实现自定义调谐器的更多信息,请参考 `这里 <https://nni.readthedocs.io/zh/stable/Tuner/CustomizeTuner.html>`_ 。 接下来,执行以下步骤:
#. 用 ``nnictl algo register`` 命令安装自定义 Tuner。 详情请查看 `本文档 <https://nni.readthedocs.io/zh/stable/Tutorial/Nnictl.html>`_ 。
#. 在 ``./nni/frameworks.yaml``\ 中,添加一个扩展基础框架 NNI 的新框架。 确保参数 ``tuner_type`` 对应于在步骤 1 中安装 Tuner 的 “builtinName”。
#. 运行命令
.. code-block:: bash
./runbenchmark_nni.sh new-tuner-builtinName
基准测试示例
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
例如,我们在以下8个 Tuner 上运行 “nnismall” 基准: "TPE", "Random", "Anneal", "Evolution", "SMAC", "GPTuner", "MetisTuner", "DNGOTuner". 由于一些任务包含相当数量的训练数据,在一个 Tuner 上使用单个 CPU 核心运行整个基准测试大约需要2天。 关于任务的详细描述,请查看 ``/examples/trials/benchmarking/automlbenchmark/nni/benchmarks/nnismall_description.txt`` 。 对于二类和多类分类任务,使用了 "AUC "和 "logloss" 指标进行评估,而对于回归,则使用了 "r2" 和 "rmse" 指标。
脚本完成后,每个 Tuner 的最终得分被总结在文件中 ``results[time]/reports/performances.txt``。 由于该文件很大,我们只显示以下屏幕截图并总结其他重要统计数据。
.. image:: ../img/hpo_benchmark/performances.png
:target: ../img/hpo_benchmark/performances.png
:alt:
此外,在对结果进行解析时,根据最终的性能对 Tuner 进行排名。 ``results[time]/reports/rankings.txt`` 显示了在每个指标(logloss, rmse, auc)下,Tuner 的平均排名。 在这里,我们介绍了前三个表中的数据。 此外,对于每个 Tuner,我们总结了对每种类型度量的性能(相同数据的另一视图)。 我们在第四个表格中介绍了这一统计数据。
指标 rmse 的平均排名:
.. list-table::
:header-rows: 1
* - Tuner 名字
- 平均排名
* - Anneal
- 3.75
* - Random
- 4.00
* - Evolution
- 4.44
* - DNGOTuner
- 4.44
* - SMAC
- 4.56
* - TPE
- 4.94
* - GPTuner
- 4.94
* - MetisTuner
- 4.94
指标 auc 的平均排名:
.. list-table::
:header-rows: 1
* - Tuner 名字
- 平均排名
* - SMAC
- 3.67
* - GPTuner
- 4.00
* - Evolution
- 4.22
* - Anneal
- 4.39
* - MetisTuner
- 4.39
* - TPE
- 4.67
* - Random
- 5.33
* - DNGOTuner
- 5.33
指标 logloss 的平均排名:
.. list-table::
:header-rows: 1
* - Tuner 名字
- 平均排名
* - Random
- 3.36
* - DNGOTuner
- 3.50
* - SMAC
- 3.93
* - GPTuner
- 4.64
* - TPE
- 4.71
* - Anneal
- 4.93
* - Evolution
- 5.00
* - MetisTuner
- 5.93
Tuner 的平均排名:
.. list-table::
:header-rows: 1
* - Tuner 名字
- rmse
- auc
- logloss
* - TPE
- 4.94
- 4.67
- 4.71
* - Random
- 4.00
- 5.33
- 3.36
* - Anneal
- 3.75
- 4.39
- 4.93
* - Evolution
- 4.44
- 4.22
- 5.00
* - GPTuner
- 4.94
- 4.00
- 4.64
* - MetisTuner
- 4.94
- 4.39
- 5.93
* - SMAC
- 4.56
- 3.67
- 3.93
* - DNGOTuner
- 4.44
- 5.33
- 3.50
除了这些报告,我们的脚本还为每个任务的每个文件夹生成两个图表。 第一个图表显示了每个 Tuner 在第 x 个 Trial 之前的最佳分数,第二图表显示了 Trial x 中每个 Tuner 的分数。 这两张图可以提供一些关于 Tuner 如何 "收敛" 的信息。 我们发现,对于 "nnismall",随机森林模型上的 Tuner,其搜索空间定义在 ``/examples/trials/benchmarking/automlbenchmark/nni/extensions/NNI/architectures/run_random_forest.py`` ,一般在40到60次试验后收敛到最终解决方案。 由于图表太多,无法包含在一份报告中(共96张图表),我们在此只介绍10张图表。
.. image:: ../img/hpo_benchmark/car_fold1_1.jpg
:target: ../img/hpo_benchmark/car_fold1_1.jpg
:alt:
.. image:: ../img/hpo_benchmark/car_fold1_2.jpg
:target: ../img/hpo_benchmark/car_fold1_2.jpg
:alt:
例如,前面两个图是为任务 "汽车" 的文件夹1生成的。 在第一张图中,我们可以观察到,大多数 Tuner 在40次 Trial 中找到了一个相对较好的解决方案。 在这个实验中,在所有的 Tuner 中,DNGOTuner 最快收敛到最佳解决方案(在10次 Trial 内)。 它的分数在整个实验中提高了三次。 在第二张图中,我们观察到大多数 Tuner 的分数在整个实验期间都在0.8和1之间波动。 然而,似乎 Anneal 调谐器(绿线)更不稳定(有更多的波动),而 GPTune r有一个更稳定的模式。 无论如何,虽然这种模式可以在某种程度上被解释为 Tuner 对探索开采权衡的位置,但它不能用于综合评估 Tuner 的效率。
.. image:: ../img/hpo_benchmark/christine_fold0_1.jpg
:target: ../img/hpo_benchmark/christine_fold0_1.jpg
:alt:
.. image:: ../img/hpo_benchmark/christine_fold0_2.jpg
:target: ../img/hpo_benchmark/christine_fold0_2.jpg
:alt:
.. image:: ../img/hpo_benchmark/cnae-9_fold0_1.jpg
:target: ../img/hpo_benchmark/cnae-9_fold0_1.jpg
:alt:
.. image:: ../img/hpo_benchmark/cnae-9_fold0_2.jpg
:target: ../img/hpo_benchmark/cnae-9_fold0_2.jpg
:alt:
.. image:: ../img/hpo_benchmark/credit-g_fold1_1.jpg
:target: ../img/hpo_benchmark/credit-g_fold1_1.jpg
:alt:
.. image:: ../img/hpo_benchmark/credit-g_fold1_2.jpg
:target: ../img/hpo_benchmark/credit-g_fold1_2.jpg
:alt:
.. image:: ../img/hpo_benchmark/titanic_2_fold1_1.jpg
:target: ../img/hpo_benchmark/titanic_2_fold1_1.jpg
:alt:
.. image:: ../img/hpo_benchmark/titanic_2_fold1_2.jpg
:target: ../img/hpo_benchmark/titanic_2_fold1_2.jpg
:alt:
docs/zh_CN/hyperparameter_tune.rst
View file @
403195f0
...
@@ -24,4 +24,5 @@ NNI 具有高扩展性,高级用户可以定制自己的 Tuner、 Assessor,
...
@@ -24,4 +24,5 @@ NNI 具有高扩展性,高级用户可以定制自己的 Tuner、 Assessor,
示例 <examples>
示例 <examples>
Web 界面 <Tutorial/WebUI>
Web 界面 <Tutorial/WebUI>
如何调试 <Tutorial/HowToDebug>
如何调试 <Tutorial/HowToDebug>
高级 <hpo_advanced>
高级 <hpo_advanced>
\ No newline at end of file
Tuner 基准测试 <hpo_benchmark>
docs/zh_CN/nas.rst
View file @
403195f0
...
@@ -10,20 +10,24 @@
...
@@ -10,20 +10,24 @@
为了促进 NAS 创新 (如, 设计实现新的 NAS 模型,比较不同的 NAS 模型),
为了促进 NAS 创新 (如, 设计实现新的 NAS 模型,比较不同的 NAS 模型),
易于使用且灵活的编程接口非常重要。
易于使用且灵活的编程接口非常重要。
因此,我们为 NAS 提供了统一的接口,
因此,NNI 设计了 `Retiarii <https://www.usenix.org/system/files/osdi20-zhang_quanlu.pdf>`__, 它是一个深度学习框架,支持在神经网络模型空间,而不是单个神经网络模型上进行探索性训练。
来加速 NAS 创新,并更快的将最先进的算法用于现实世界的问题上。
Retiarii 的探索性训练允许用户以高度灵活的方式表达 *神经网络架构搜索* 和 *超参数调整* 的各种搜索空间。
详细信息,参考以下教程:
本文档中的一些常用术语:
* *Model search space(模型搜索空间)* :它意味着一组模型,用于从中探索/搜索出最佳模型。 有时我们简称为 *search space(搜索空间)* 或 *model space(模型空间)* 。
* *Exploration strategy(探索策略)*:用于探索模型搜索空间的算法。
* *Model evaluator(模型评估器)*:用于训练模型并评估模型的性能。
按照以下说明开始您的 Retiarii 之旅。
.. toctree::
.. toctree::
:maxdepth: 2
:maxdepth: 2
概述 <NAS/Overview>
概述 <NAS/Overview>
编写搜索空间 <NAS/WriteSearchSpace>
快速入门 <NAS/QuickStart>
经典 NAS <NAS/ClassicNas>
构建模型空间 <NAS/construct_space>
Multi-trial NAS <NAS/multi_trial_nas>
One-Shot NAS <NAS/one_shot_nas>
One-Shot NAS <NAS/one_shot_nas>
Retiarii NAS(实验性) <NAS/retiarii/retiarii_index>
自定义 NAS 算法 <NAS/Advanced>
NAS 可视化 <NAS/Visualization>
搜索空间集合 <NAS/SearchSpaceZoo>
NAS 基准测试 <NAS/Benchmarks>
NAS 基准测试 <NAS/Benchmarks>
API 参考 <NAS/
Nas
Reference>
NAS
API 参考 <NAS/
Api
Reference>
docs/zh_CN/reference.rst
View file @
403195f0
...
@@ -5,11 +5,12 @@
...
@@ -5,11 +5,12 @@
:maxdepth: 2
:maxdepth: 2
nnictl 命令 <Tutorial/Nnictl>
nnictl 命令 <Tutorial/Nnictl>
Experiment 配置 <
Tutorial/E
xperiment
C
onfig>
Experiment 配置 <
reference/e
xperiment
_c
onfig>
Experiment 配置
第二版 <reference/e
xperiment
_c
onfig>
Experiment 配置
(遗产) <Tutorial/E
xperiment
C
onfig>
搜索空间<Tutorial/SearchSpaceSpec>
搜索空间<Tutorial/SearchSpaceSpec>
NNI Annotation<Tutorial/AnnotationSpec>
NNI Annotation<Tutorial/AnnotationSpec>
SDK API 参考 <sdk_reference>
SDK API 参考 <sdk_reference>
支持的框架和库 <SupportedFramework_Library>
支持的框架和库 <SupportedFramework_Library>
从 Python 发起实验 <Tutorial/HowToLaunchFromPython>
从 Python 发起实验 <Tutorial/HowToLaunchFromPython>
共享存储 <Tutorial/HowToUseSharedStorage>
共享存储 <Tutorial/HowToUseSharedStorage>
Tensorboard <Tutorial/Tensorboard>
docs/zh_CN/reference/experiment_config.rst
View file @
403195f0
===========================
===========================
Experiment
(实验)配置参考
Experiment
配置
===========================
===========================
注意
创建 Experiment 所需要的配置文件。 本文介绍了配置文件的内容,并提供了一些示例。
=====
.. Note::
1. 此文档的字段使用 ``camelCase`` 法命名。 对于 Python 库 ``nni.experiment``,需要转换成 ``snake_case`` 形式。
1. 此文档的字段使用 ``camelCase`` 法命名。
2. 在此文档中,字段类型被格式化为 `Python 类型提示 <https://docs.python.org/3.10/library/typing.html>`__。 因此,JSON 对象被称为 `dict`,数组被称为 `list`。
对于 Python 库 ``nni.experiment``,需要转换成 ``snake_case`` 形式。
2. 在此文档中,字段类型被格式化为 `Python 类型提示 <https://docs.python.org/3.10/library/typing.html>`__。
.. _path:
因此,JSON 对象被称为 `dict`,数组被称为 `list`。
.. _路径:
3. 一些字段采用文件或目录的路径, 除特别说明,均支持绝对路径和相对路径,``~`` 将扩展到 home 目录。
3. 一些字段采用文件或目录的路径,
- 在写入 YAML 文件时,相对路径是相对于包含该文件目录的路径。
除特别说明,均支持绝对路径和相对路径,``~`` 将扩展到 home 目录。
- 在 Python 代码中赋值时,相对路径是相对于当前工作目录的路径。
- 在将 YAML 文件加载到 Python 类,以及将 Python 类保存到 YAML 文件时,所有相对路径都转换为绝对路径。
- 在写入 YAML 文件时,相对路径是相对于包含该文件目录的路径。
4. 将字段设置为 ``None`` 或 ``null`` 时相当于不设置该字段。
- 在 Python 代码中赋值时,相对路径是相对于当前工作目录的路径。
- 在将 YAML 文件加载到 Python 类,以及将 Python 类保存到 YAML 文件时,所有相对路径都转换为绝对路径。
4. 将字段设置为 ``None`` 或 ``null`` 时相当于不设置该字段。
.. contents:: Contents
:local:
:depth: 3
示例
示例
========
========
...
@@ -35,6 +38,7 @@ Experiment(实验)配置参考
...
@@ -35,6 +38,7 @@ Experiment(实验)配置参考
trialCommand: python mnist.py
trialCommand: python mnist.py
trialCodeDirectory: .
trialCodeDirectory: .
trialGpuNumber: 1
trialGpuNumber: 1
trialConcurrency: 2
maxExperimentDuration: 24h
maxExperimentDuration: 24h
maxTrialNumber: 100
maxTrialNumber: 100
tuner:
tuner:
...
@@ -59,6 +63,7 @@ Experiment(实验)配置参考
...
@@ -59,6 +63,7 @@ Experiment(实验)配置参考
_value: [0.0001, 0.1]
_value: [0.0001, 0.1]
trialCommand: python mnist.py
trialCommand: python mnist.py
trialGpuNumber: 1
trialGpuNumber: 1
trialConcurrency: 2
tuner:
tuner:
name: TPE
name: TPE
classArgs:
classArgs:
...
@@ -77,6 +82,7 @@ Experiment(实验)配置参考
...
@@ -77,6 +82,7 @@ Experiment(实验)配置参考
trialCommand: python mnist.py
trialCommand: python mnist.py
trialCodeDirectory: .
trialCodeDirectory: .
trialGpuNumber: 1
trialGpuNumber: 1
trialConcurrency: 2
maxExperimentDuration: 24h
maxExperimentDuration: 24h
maxTrialNumber: 100
maxTrialNumber: 100
tuner:
tuner:
...
@@ -96,8 +102,8 @@ Experiment(实验)配置参考
...
@@ -96,8 +102,8 @@ Experiment(实验)配置参考
参考
参考
=========
=========
Experiment
配置
Experiment
(实验)配置参考
^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^
experimentName
experimentName
--------------
--------------
...
@@ -110,11 +116,11 @@ Experiment 的助记名称, 这将显示在 WebUI 和 nnictl 中。
...
@@ -110,11 +116,11 @@ Experiment 的助记名称, 这将显示在 WebUI 和 nnictl 中。
searchSpaceFile
searchSpaceFile
---------------
---------------
包含搜索空间 JSON 文件的
\ 路径_
。
包含搜索空间 JSON 文件的
路径(path_)
。
类型:``Optional[str]``
类型:``Optional[str]``
搜索空间格式由 Tuner 决定, 内置 Tuner 的通用格式在 `这里 <../Tutorial/SearchSpaceSpec.rst>`__。
搜索空间格式由 Tuner 决定, 内置 Tuner 的通用格式在 `这里 <../Tutorial/SearchSpaceSpec.rst>`__。
内置 Tuner 的通用格式在 `这里 <../Tutorial/SearchSpaceSpec.rst>`__。
与 `searchSpace`_ 互斥。
与 `searchSpace`_ 互斥。
...
@@ -126,7 +132,7 @@ searchSpace
...
@@ -126,7 +132,7 @@ searchSpace
类型:``Optional[JSON]``
类型:``Optional[JSON]``
格式由 Tuner 决定, 内置 Tuner 的通用格式在 `这里 <../Tutorial/SearchSpaceSpec.rst>`__。
格式由 Tuner 决定, 内置 Tuner 的通用格式在 `这里 <../Tutorial/SearchSpaceSpec.rst>`__。
内置 Tuner 的通用格式在 `这里 <../Tutorial/SearchSpaceSpec.rst>`__。
注意,``None`` 意味着“没有这样的字段”,所以空的搜索空间应该写成 ``{}``。
注意,``None`` 意味着“没有这样的字段”,所以空的搜索空间应该写成 ``{}``。
...
@@ -142,11 +148,13 @@ trialCommand
...
@@ -142,11 +148,13 @@ trialCommand
该命令将在 Linux 和 macOS 上的 bash 中执行,在 Windows 上的 PowerShell 中执行。
该命令将在 Linux 和 macOS 上的 bash 中执行,在 Windows 上的 PowerShell 中执行。
注意在 Linux 和 macOS 中使用``python3``,在 Windows 中使用 ``python``。
trialCodeDirectory
trialCodeDirectory
------------------
------------------
到 Trial 源文件的目录的
路径
_
。
到 Trial 源文件的目录的路径
(path_)
。
类型:``str``
类型:``str``
...
@@ -175,7 +183,7 @@ trialGpuNumber
...
@@ -175,7 +183,7 @@ trialGpuNumber
对于各种训练平台,这个字段的含义可能略有不同,
对于各种训练平台,这个字段的含义可能略有不同,
尤其是设置为 ``0`` 或者 ``None`` 时,
尤其是设置为 ``0`` 或者 ``None`` 时,
详情请参阅训练平台文件
。
指定 `训练平台 <../TrainingService/Overview.rst>`__
。
在本地模式下,将该字段设置为零将阻止 Trial 获取 GPU(通过置空 ``CUDA_VISIBLE_DEVICES`` )。
在本地模式下,将该字段设置为零将阻止 Trial 获取 GPU(通过置空 ``CUDA_VISIBLE_DEVICES`` )。
当设置为 ``None`` 时,Trial 将被创建和调度,就像它们不使用 GPU 一样,
当设置为 ``None`` 时,Trial 将被创建和调度,就像它们不使用 GPU 一样,
...
@@ -209,13 +217,13 @@ maxTrialNumber
...
@@ -209,13 +217,13 @@ maxTrialNumber
nniManagerIp
nniManagerIp
------------
------------
当前机器的 IP,用于训练机器访问 NNI 管理器。 本机模式下不可选。
当前机器的 IP,用于训练机器访问 NNI 管理器。 本机模式下不可选。
本机模式下不可选。
类型:``Optional[str]``
类型:``Optional[str]``
如果未指定,将使用 ``eth0`` 的 IPv4 地址。
如果未指定,将使用 ``eth0`` 的 IPv4 地址。
必须在 Windows 和使用可预测网络接口名称的系统上设置,本地模式除外
。
除本地模式外,强烈建议手动设置此字段
。
useAnnotation
useAnnotation
...
@@ -223,7 +231,7 @@ useAnnotation
...
@@ -223,7 +231,7 @@ useAnnotation
启动 `annotation <../Tutorial/AnnotationSpec.rst>`__。
启动 `annotation <../Tutorial/AnnotationSpec.rst>`__。
类型:``bool``
类型:``
Optional[
bool
]
``
默认值:``false``
默认值:``false``
...
@@ -235,7 +243,7 @@ debug
...
@@ -235,7 +243,7 @@ debug
启动调试模式
启动调试模式
类型:``
bool
``
类型:``
str
``
默认值:``false``
默认值:``false``
...
@@ -251,7 +259,7 @@ logLevel
...
@@ -251,7 +259,7 @@ logLevel
候选项:``"trace"``, ``"debug"``, ``"info"``, ``"warning"``, ``"error"``, ``"fatal"``
候选项:``"trace"``, ``"debug"``, ``"info"``, ``"warning"``, ``"error"``, ``"fatal"``
默认为 "info" 或 "debug",取决于 `debug`_ 选项。
默认为 "info" 或 "debug",取决于 `debug`_ 选项。
启用调试模式时,LogLevel 设置为 “debug”,否则,LogLevel 设置为 “Info”。
NNI 的大多数模块都会受到此值的影响,包括 NNI 管理器、Tuner、训练平台等。
NNI 的大多数模块都会受到此值的影响,包括 NNI 管理器、Tuner、训练平台等。
...
@@ -277,7 +285,7 @@ tunerGpuIndices
...
@@ -277,7 +285,7 @@ tunerGpuIndices
设定对 Tuner、Assessor 和 Advisor 可见的 GPU。
设定对 Tuner、Assessor 和 Advisor 可见的 GPU。
类型:``Optional[list[int] | str]``
类型:
``Optional[list[int] | str
| int
]``
这将是 Tuner 进程的 ``CUDA_VISIBLE_DEVICES`` 环境变量,
这将是 Tuner 进程的 ``CUDA_VISIBLE_DEVICES`` 环境变量,
...
@@ -287,35 +295,49 @@ tunerGpuIndices
...
@@ -287,35 +295,49 @@ tunerGpuIndices
tuner
tuner
-----
-----
指定 Tuner。
指定 Tuner。
类型:Optional `AlgorithmConfig`_
类型:Optional `AlgorithmConfig`_
内置的 Tuner 可以在 `这里 <../builtin_tuner.rst>`__ 找到,你可以按照 `此教程 <../Tuner/CustomizeTuner.rst>`__ 来定制一个新的 Tuner。
assessor
assessor
--------
--------
指定 Assessor。
指定 Assessor。
类型:Optional `AlgorithmConfig`_
类型:Optional `AlgorithmConfig`_
内置的 Assessor 可以在 `这里 <../builtin_assessor.rst>`__ 找到,你可以按照 `此教程 <../Assessor/CustomizeAssessor.rst>`__ 来定制一个新的 Assessor。
advisor
advisor
-------
-------
指定 Advisor。
指定 Advisor。
类型:Optional `AlgorithmConfig`_
类型:Optional `AlgorithmConfig`_
NNI 提供了两个内置的 Advisor:`BOHB <../Tuner/BohbAdvisor.rst>`__ 和 `Hyperband <../Tuner/HyperbandAdvisor.rst>`__,你可以按照 `此教程 <../Tuner/CustomizeAdvisor.rst>`__ 来定制一个新的 Advisor。
trainingService
trainingService
---------------
---------------
指定 `训练平台
<../TrainingService/
Overview
.rst>`__。
详情查看 `这里
<../TrainingService/
LocalMode
.rst>`__。
类型:`TrainingServiceConfig`_
类型:`TrainingServiceConfig`_
sharedStorage
-------------
配置共享存储,详细的用法可以在 `这里 <../Tutorial/HowToUseSharedStorage.rst>`__ 找到。
类型:Optional `SharedStorageConfig`_
AlgorithmConfig
AlgorithmConfig
^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^
...
@@ -323,7 +345,7 @@ AlgorithmConfig
...
@@ -323,7 +345,7 @@ AlgorithmConfig
对于自定义算法,有两种方法来描述它们:
对于自定义算法,有两种方法来描述它们:
1. `注册算法 <../Tuner/InstallCustomizedTuner.rst>`__ ,像内置算法一样使用。 (首选)
1. `注册算法 <../Tuner/InstallCustomizedTuner.rst>`__ ,像内置算法一样使用。 (首选)
(首选)
2. 指定代码目录和类名。
2. 指定代码目录和类名。
...
@@ -333,7 +355,7 @@ name
...
@@ -333,7 +355,7 @@ name
内置或注册算法的名称。
内置或注册算法的名称。
类型:对于内置和注册算法使用 ``
str
``,其他自定义算法使用 ``
None
``
类型:对于内置和注册算法使用 ``
None
``,其他自定义算法使用 ``
str
``
className
className
...
@@ -349,9 +371,9 @@ className
...
@@ -349,9 +371,9 @@ className
codeDirectory
codeDirectory
-------------
-------------
到自定义算法类的目录的
路径
_
。
到自定义算法类的目录的路径
(path_)
。
类型:对于内置和注册算法使用 ``
None
``,其他自定义算法使用 ``
str
``
类型:对于内置和注册算法使用 ``
str
``,其他自定义算法使用 ``
None
``
classArgs
classArgs
...
@@ -371,37 +393,47 @@ TrainingServiceConfig
...
@@ -371,37 +393,47 @@ TrainingServiceConfig
- `LocalConfig`_
- `LocalConfig`_
- `RemoteConfig`_
- `RemoteConfig`_
- `OpenpaiConfig <openpai-class>`
_
-
:ref:
`OpenpaiConfig <openpai-class>`
- `AmlConfig`_
- `AmlConfig`_
- `HybridConfig`_
对于
其他
训练平台,目前 NNI 建议使用 `v1 配置模式 <../Tutorial/ExperimentConfig.rst>`_ 。
对于
`Kubeflow <../TrainingService/KubeflowMode.rst>`_, `FrameworkController <../TrainingService/FrameworkControllerMode.rst>`_, 和 `AdaptDL <../TrainingService/AdaptDLMode.rst>`_
训练平台,目前 NNI 建议使用 `v1 配置模式 <../Tutorial/ExperimentConfig.rst>`_ 。
LocalConfig
LocalConfig
^^^^^^^^^^^
-----------
详情查看 `这里 <../TrainingService/
Local
Mode.rst>`__。
详情查看 `这里 <../TrainingService/
AML
Mode.rst>`__。
platform
platform
--------
""""""""
字符串常量 ``"local"``。
字符串常量 ``"local"``。
useActiveGpu
useActiveGpu
------------
""""""""""""
指定 NNI 是否应向被其他任务占用的 GPU 提交 Trial。
指定 NNI 是否应向被其他任务占用的 GPU 提交 Trial。
类型:``Optional[
bool
]``
类型:``Optional[
str
]``
必须在 ``trialgpunmber`` 大于零时设置。
必须在 ``trialgpunmber`` 大于零时设置。
如果您使用带有 GUI 的桌面系统,请将其设置为 ``True``。
以下过程可以使GPU "active" 起来:
- 非 NNI 的 CUDA 程序
- 图形化桌面
- 其他 NNI 实例提交的 Trial,如果您在同一时间运行了多个 NNI Experiment
- 其他用户的 CUDA 程序,如果你使用共享服务器
如果你使用的是图形操作系统,如 Windows 10 或 Ubuntu 桌面,请将此字段设置为 ``True``,否则,图形用户界面将阻止 NNI 启动任何 Trial。
当你创建多个 NNI Experiment 并且将 ``useActiveGpu`` 设置为 ``True`` 时,它们将同时提交多个 Trial 到同一个 GPU。
maxTrialNumberPerGpu
maxTrialNumberPerGpu
---------------------
""""""""""""""""""""
指定可以共享一个 GPU 的 Trial 数目。
指定可以共享一个 GPU 的 Trial 数目。
...
@@ -411,11 +443,11 @@ maxTrialNumberPerGpu
...
@@ -411,11 +443,11 @@ maxTrialNumberPerGpu
gpuIndices
gpuIndices
----------
""""""""""
设定对 Trial 进程可见的 GPU。
设定对 Trial 进程可见的 GPU。
类型:``Optional[list[int] | str]``
类型:
``Optional[list[int] | str
| int
]``
如果 `trialGpuNumber`_ 小于此值的长度,那么每个 Trial 只能看到一个子集。
如果 `trialGpuNumber`_ 小于此值的长度,那么每个 Trial 只能看到一个子集。
...
@@ -423,18 +455,18 @@ gpuIndices
...
@@ -423,18 +455,18 @@ gpuIndices
RemoteConfig
RemoteConfig
^^^^^^^^^^^^
------------
详情查看 `这里 <../TrainingService/RemoteMachineMode.rst>`__。
详情查看 `这里 <../TrainingService/RemoteMachineMode.rst>`__。
platform
platform
--------
""""""""
字符串常量 ``"remote"``。
字符串常量 ``"remote"``。
machineList
machineList
-----------
"""""""""""
训练机器列表
训练机器列表
...
@@ -442,18 +474,18 @@ machineList
...
@@ -442,18 +474,18 @@ machineList
reuseMode
reuseMode
---------
"""""""""
启动 `重用模式 <../Tutorial/ExperimentConfig.rst#reuse>`__。
启动 `重用模式 <../Tutorial/ExperimentConfig.rst#reuse>`__。
类型:``
bool
``
类型:``
str
``
RemoteMachineConfig
RemoteMachineConfig
^^^^^^^^^^^^^^^^^^^
"""""""""""""""""""
host
host
----
****
机器的 IP 或主机名(域名)。
机器的 IP 或主机名(域名)。
...
@@ -461,7 +493,7 @@ host
...
@@ -461,7 +493,7 @@ host
port
port
----
****
SSH 服务端口。
SSH 服务端口。
...
@@ -471,7 +503,7 @@ SSH 服务端口。
...
@@ -471,7 +503,7 @@ SSH 服务端口。
user
user
----
****
登录用户名。
登录用户名。
...
@@ -479,7 +511,7 @@ user
...
@@ -479,7 +511,7 @@ user
password
password
--------
********
登录密码。
登录密码。
...
@@ -489,9 +521,9 @@ password
...
@@ -489,9 +521,9 @@ password
sshKeyFile
sshKeyFile
----------
**********
到 sshKeyFile的
路径
_
。
到 sshKeyFile的路径
(path_)
。
类型:``Optional[str]``
类型:``Optional[str]``
...
@@ -499,7 +531,7 @@ sshKeyFile
...
@@ -499,7 +531,7 @@ sshKeyFile
sshPassphrase
sshPassphrase
-------------
*************
SSH 标识文件的密码。
SSH 标识文件的密码。
...
@@ -507,17 +539,30 @@ SSH 标识文件的密码。
...
@@ -507,17 +539,30 @@ SSH 标识文件的密码。
useActiveGpu
useActiveGpu
------------
************
指定 NNI 是否应向被其他任务占用的 GPU 提交 Trial。
指定 NNI 是否应向被其他任务占用的 GPU 提交 Trial。
类型:``
bool
``
类型:``
str
``
默认值:``false``
默认值:``false``
必须在 ``trialgpunmber`` 大于零时设置。
以下过程可以使GPU "active" 起来:
- 非 NNI 的 CUDA 程序
- 图形化桌面
- 其他 NNI 实例提交的 Trial,如果您在同一时间运行了多个 NNI Experiment
- 其他用户的 CUDA 程序,如果你使用共享服务器
如果你使用的是图形操作系统,如 Ubuntu 桌面,请将此字段设置为 ``True``,否则,图形用户界面将阻止 NNI 启动任何 Trial。
当你创建多个 NNI Experiment 并且将 ``useActiveGpu`` 设置为 ``True`` 时,它们将同时提交多个 Trial 到同一个 GPU。
maxTrialNumberPerGpu
maxTrialNumberPerGpu
--------------------
********************
指定可以共享一个 GPU 的 Trial 数目。
指定可以共享一个 GPU 的 Trial 数目。
...
@@ -527,41 +572,51 @@ maxTrialNumberPerGpu
...
@@ -527,41 +572,51 @@ maxTrialNumberPerGpu
gpuIndices
gpuIndices
----------
**********
设定对 Trial 进程可见的 GPU。
设定对 Trial 进程可见的 GPU。
类型:``Optional[list[int] | str]``
类型:
``Optional[list[int] | str
| int
]``
如果 `trialGpuNumber`_ 小于此值的长度,那么每个 Trial 只能看到一个子集。
如果 `trialGpuNumber`_ 小于此值的长度,那么每个 Trial 只能看到一个子集。
这用作环境变量 ``CUDA_VISIBLE_DEVICES``。
这用作环境变量 ``CUDA_VISIBLE_DEVICES``。
trialPrepareCommand
pythonPath
-------------------
**********
启动 Trial 之前运行的命令
。
指定 Python 环境
。
类型:``Optional[str]``
类型:``Optional[list[int] | str]``
这个路径将被插入到 PATH 的前面。 以下之一:
- (linux) pythonPath: ``/opt/python3.7/bin``
- (windows) pythonPath: ``C:/Python37``
如果你是在 Anaconda 上工作,那就有所不同。 在Windows上,你还必须添加 ``.../script`` 和 ``.../Library/bin``,并用 ``;`` 分隔。 示例如下:
- (linux anaconda) pythonPath: ``/home/yourname/anaconda3/envs/myenv/bin/``
- (windows anaconda) pythonPath: ``C:/Users/yourname/.conda/envs/myenv;C:/Users/yourname/.conda/envs/myenv/Scripts;C:/Users/yourname/.conda/envs/myenv/Library/bin``
如果不同机器的准备步骤不同,这将非常有用。
如果不同机器的准备步骤不同,这将非常有用。
.. _openpai-class:
.. _openpai-class:
OpenpaiConfig
OpenpaiConfig
^^^^^^^^^^^^^
-------------
详情查看 `这里 <../TrainingService/PaiMode.rst>`__。
详情查看 `这里 <../TrainingService/PaiMode.rst>`__。
platform
platform
--------
""""""""
字符串常量 ``"openpai"``。
字符串常量 ``"openpai"``。
host
host
----
""""
OpenPAI 平台的主机名。
OpenPAI 平台的主机名。
...
@@ -573,7 +628,7 @@ OpenPAI 平台的主机名。
...
@@ -573,7 +628,7 @@ OpenPAI 平台的主机名。
username
username
--------
""""""""
OpenPAI 用户名。
OpenPAI 用户名。
...
@@ -581,7 +636,7 @@ OpenPAI 用户名。
...
@@ -581,7 +636,7 @@ OpenPAI 用户名。
token
token
-----
"""""
OpenPAI 用户令牌。
OpenPAI 用户令牌。
...
@@ -590,8 +645,36 @@ OpenPAI 用户令牌。
...
@@ -590,8 +645,36 @@ OpenPAI 用户令牌。
这可以在 OpenPAI 用户设置页面中找到。
这可以在 OpenPAI 用户设置页面中找到。
trialCpuNumber
""""""""""""""
指定每个 Trial 在 OpenPAI 容器中使用的 CPU 数。
类型:``bool``
trialMemorySize
"""""""""""""""
指定每个 Trial 在 OpenPAI 容器中的内存限制。
类型:``str``
格式:``数字 + tb|gb|mb|kb``
示例:``"8gb"``, ``"8192mb"``
storageConfigName
"""""""""""""""""
设置 OpenPAI 中使用的存储名称。
类型:``str``
dockerImage
dockerImage
-----------
"""""""""""
运行 Trial 的 Docker 镜像的名称和标签。
运行 Trial 的 Docker 镜像的名称和标签。
...
@@ -600,8 +683,8 @@ dockerImage
...
@@ -600,8 +683,8 @@ dockerImage
默认:``"msranni/nni:latest"``
默认:``"msranni/nni:latest"``
nniManager
StorageMountPoint
local
StorageMountPoint
---------------------------
""""""""""""""""""""""
当前机器中存储服务(通常是NFS)的挂载点路径。
当前机器中存储服务(通常是NFS)的挂载点路径。
...
@@ -609,27 +692,27 @@ nniManagerStorageMountPoint
...
@@ -609,27 +692,27 @@ nniManagerStorageMountPoint
containerStorageMountPoint
containerStorageMountPoint
--------------------------
""""""""""""""""""""""""""
Docker 容器中存储服务(通常是NFS)的挂载点。
Docker 容器中存储服务(通常是NFS)的挂载点。
类型:``str``
类型:``
Optional[
str
]
``
这必须是绝对路径。
这必须是绝对路径。
reuseMode
reuseMode
---------
"""""""""
启动 `重用模式 <../Tutorial/ExperimentConfig.rst#reuse>`__。
启动 `重用模式 <../Tutorial/ExperimentConfig.rst#reuse>`__。
类型:``
bool
``
类型:``
str
``
默认值:``false``
默认值:``false``
openpaiConfig
openpaiConfig
-------------
"""""""""""""
嵌入的 OpenPAI 配置文件。
嵌入的 OpenPAI 配置文件。
...
@@ -637,39 +720,39 @@ openpaiConfig
...
@@ -637,39 +720,39 @@ openpaiConfig
openpaiConfigFile
openpaiConfigFile
-----------------
"""""""""""""""""
到 OpenPAI 配置文件的
`路径`_
到 OpenPAI 配置文件的
路径(path_)
类型:``Optional[str]``
类型:``Optional[
list[int] |
str]``
示例在 `这里 <https://github.com/microsoft/pai/blob/master/docs/manual/cluster-user/examples/hello-world-job.yaml>`__。
示例在 `这里 <https://github.com/microsoft/pai/blob/master/docs/manual/cluster-user/examples/hello-world-job.yaml>`__。
AmlConfig
AmlConfig
^^^^^^^^^
---------
详
情查看
`这里 <../TrainingService/AMLMode.rst>`__。
详
细用法参考
`这里 <../TrainingService/AMLMode.rst>`__。
platform
platform
--------
""""""""
字符串常量 ``"aml"``。
字符串常量 ``"aml"``。
dockerImage
dockerImage
-----------
"""""""""""
运行 Trial 的 Docker 镜像的名称和标签。
运行 Trial 的 Docker 镜像的名称和标签。
类型:``str``
类型:``
Optional[list[int] |
str
]
``
默认:``"msranni/nni:latest"``
默认:``"msranni/nni:latest"``
subscriptionId
subscriptionId
--------------
""""""""""""""
Azure 订阅 ID。
Azure 订阅 ID。
...
@@ -677,7 +760,7 @@ Azure 订阅 ID。
...
@@ -677,7 +760,7 @@ Azure 订阅 ID。
resourceGroup
resourceGroup
-------------
"""""""""""""
Azure 资源组名称。
Azure 资源组名称。
...
@@ -685,7 +768,7 @@ Azure 资源组名称。
...
@@ -685,7 +768,7 @@ Azure 资源组名称。
workspaceName
workspaceName
-------------
"""""""""""""
Azure 工作区名称。
Azure 工作区名称。
...
@@ -693,8 +776,157 @@ Azure 工作区名称。
...
@@ -693,8 +776,157 @@ Azure 工作区名称。
computeTarget
computeTarget
-------------
"""""""""""""
AML 计算集群名称。
AML 计算集群名称。
类型:``str``
类型:``str``
HybridConfig
------------
目前仅支持 `LocalConfig`_, `RemoteConfig`_, :ref:`OpenpaiConfig <openpai-class>` 和 `AmlConfig`_ 配置。 详细用法参考 `这里 <../TrainingService/HybridMode.rst>`__。
类型:`TrainingServiceConfig`_ 列表
SharedStorageConfig
^^^^^^^^^^^^^^^^^^^
详细用法参考 `这里 <../Tutorial/HowToUseSharedStorage.rst>`__。
nfsConfig
---------
storageType
"""""""""""
字符串常量 ``"NFS"``
localMountPoint
"""""""""""""""
已经或将要在本地挂载存储的路径。
类型:``str``
如果路径不存在,则会自动创建。 推荐使用绝对路径,即 ``/tmp/nni-shared-storage``
remoteMountPoint
""""""""""""""""
远程挂载存储的路径。
类型:``str``
如果路径不存在,则会自动创建。 推荐使用相对路径。 即, ``./nni-shared-storage``
localMounted
""""""""""""
指定挂载共享存储的对象和状态。
类型:``str``
候选项:``"usermount"``, ``"nnimount"``, ``"nomount"``
``usermount`` 表示已经在 localMountPoint 上挂载了此存储。 ``nnimount`` 表示 NNI 将尝试在 localMountPoint 上挂载此存储。 ``nomount`` 表示存储不会挂载在本地机器上,将在未来支持部分存储。
nfsServer
"""""""""
NFS 服务器主机
类型:``str``
exportedDirectory
"""""""""""""""""
NFS 服务器导出目录,详情参考 `这里 <https://www.ibm.com/docs/en/aix/7.2?topic=system-nfs-exporting-mounting>`_ 。
类型:``str``
azureBlobConfig
---------------
storageType
"""""""""""
字符串常量 ``"AzureBlob"``
localMountPoint
"""""""""""""""
已经或将要在本地挂载存储的路径。
类型:``str``
如果路径不存在,则会自动创建。 推荐使用绝对路径,即 ``/tmp/nni-shared-storage``
remoteMountPoint
""""""""""""""""
远程挂载存储的路径。
类型:``str``
如果路径不存在,它将被自动创建。 建议使用相对路径。 即, ``./nni-shared-storage``
注意:使用 AzureBlob 时,此目录必须是空的。
localMounted
""""""""""""
指定挂载共享存储的对象和状态。
类型:``str``
候选值:``"usermount"``, ``"nnimount"``, ``"nomount"``
``usermount`` 表示已经在 localMountPoint 上挂载了此存储。 ``nnimount`` 表示 NNI 将尝试在 localMountPoint 上挂载此存储。 ``nomount`` 表示存储不会挂载在本地机器上,将在未来支持部分存储。
storageAccountName
""""""""""""""""""
Azure 存储账户名称。
类型:``str``
storageAccountKey
"""""""""""""""""
Azure 存储账户密钥。
类型:``Optional[str]``
如果未设置 storageAccountKey,则首先需要在 Azure CLI 中使用 ``az login`` 并设置 `resourceGroupName`_ 。
resourceGroupName
"""""""""""""""""
AzureBlob 容器所属的资源组。
类型:``Optional[str]``
如果 ``storageAccountKey`` 没有设置则必必需。
containerName
"""""""""""""
AzureBlob 容器名。
类型:``str``
docs/zh_CN/sdk_reference.rst
View file @
403195f0
...
@@ -7,5 +7,5 @@ Python API 参考
...
@@ -7,5 +7,5 @@ Python API 参考
:maxdepth: 1
:maxdepth: 1
自动调优 <autotune_ref>
自动调优 <autotune_ref>
NAS <NAS/
Nas
Reference>
NAS <NAS/
Api
Reference>
模型压缩 <Compression/CompressionReference>
模型压缩 <Compression/CompressionReference>
\ No newline at end of file
examples/model_compress/pruning/basic_pruners_torch.py
View file @
403195f0
...
@@ -143,7 +143,7 @@ def get_model_optimizer_scheduler(args, device, train_loader, test_loader, crite
...
@@ -143,7 +143,7 @@ def get_model_optimizer_scheduler(args, device, train_loader, test_loader, crite
model
.
load_state_dict
(
torch
.
load
(
args
.
pretrained_model_dir
))
model
.
load_state_dict
(
torch
.
load
(
args
.
pretrained_model_dir
))
best_acc
=
test
(
args
,
model
,
device
,
criterion
,
test_loader
)
best_acc
=
test
(
args
,
model
,
device
,
criterion
,
test_loader
)
# setup new opotimizer for
fine-t
uning
# setup new opotimizer for
pr
uning
optimizer
=
torch
.
optim
.
SGD
(
model
.
parameters
(),
lr
=
0.01
,
momentum
=
0.9
,
weight_decay
=
5e-4
)
optimizer
=
torch
.
optim
.
SGD
(
model
.
parameters
(),
lr
=
0.01
,
momentum
=
0.9
,
weight_decay
=
5e-4
)
scheduler
=
MultiStepLR
(
optimizer
,
milestones
=
[
int
(
args
.
pretrain_epochs
*
0.5
),
int
(
args
.
pretrain_epochs
*
0.75
)],
gamma
=
0.1
)
scheduler
=
MultiStepLR
(
optimizer
,
milestones
=
[
int
(
args
.
pretrain_epochs
*
0.5
),
int
(
args
.
pretrain_epochs
*
0.75
)],
gamma
=
0.1
)
...
@@ -192,10 +192,10 @@ def main(args):
...
@@ -192,10 +192,10 @@ def main(args):
# prepare model and data
# prepare model and data
train_loader
,
test_loader
,
criterion
=
get_data
(
args
.
dataset
,
args
.
data_dir
,
args
.
batch_size
,
args
.
test_batch_size
)
train_loader
,
test_loader
,
criterion
=
get_data
(
args
.
dataset
,
args
.
data_dir
,
args
.
batch_size
,
args
.
test_batch_size
)
model
,
optimizer
,
scheduler
=
get_model_optimizer_scheduler
(
args
,
device
,
train_loader
,
test_loader
,
criterion
)
model
,
optimizer
,
_
=
get_model_optimizer_scheduler
(
args
,
device
,
train_loader
,
test_loader
,
criterion
)
dummy_input
=
get_dummy_input
(
args
,
device
)
dummy_input
=
get_dummy_input
(
args
,
device
)
flops
,
params
,
results
=
count_flops_params
(
model
,
dummy_input
)
flops
,
params
,
_
=
count_flops_params
(
model
,
dummy_input
)
print
(
f
"FLOPs:
{
flops
}
, params:
{
params
}
"
)
print
(
f
"FLOPs:
{
flops
}
, params:
{
params
}
"
)
print
(
f
'start
{
args
.
pruner
}
pruning...'
)
print
(
f
'start
{
args
.
pruner
}
pruning...'
)
...
@@ -243,6 +243,7 @@ def main(args):
...
@@ -243,6 +243,7 @@ def main(args):
# Reproduced result in paper 'PRUNING FILTERS FOR EFFICIENT CONVNETS',
# Reproduced result in paper 'PRUNING FILTERS FOR EFFICIENT CONVNETS',
# Conv_1, Conv_8, Conv_9, Conv_10, Conv_11, Conv_12 are pruned with 50% sparsity, as 'VGG-16-pruned-A'
# Conv_1, Conv_8, Conv_9, Conv_10, Conv_11, Conv_12 are pruned with 50% sparsity, as 'VGG-16-pruned-A'
# If you want to skip some layer, you can use 'exclude' like follow.
if
args
.
pruner
==
'slim'
:
if
args
.
pruner
==
'slim'
:
config_list
=
[{
config_list
=
[{
'sparsity'
:
args
.
sparsity
,
'sparsity'
:
args
.
sparsity
,
...
@@ -252,7 +253,10 @@ def main(args):
...
@@ -252,7 +253,10 @@ def main(args):
config_list
=
[{
config_list
=
[{
'sparsity'
:
args
.
sparsity
,
'sparsity'
:
args
.
sparsity
,
'op_types'
:
[
'Conv2d'
],
'op_types'
:
[
'Conv2d'
],
'op_names'
:
[
'feature.0'
,
'feature.24'
,
'feature.27'
,
'feature.30'
,
'feature.34'
,
'feature.37'
]
'op_names'
:
[
'feature.0'
,
'feature.10'
,
'feature.24'
,
'feature.27'
,
'feature.30'
,
'feature.34'
,
'feature.37'
]
},
{
'exclude'
:
True
,
'op_names'
:
[
'feature.10'
]
}]
}]
pruner
=
pruner_cls
(
model
,
config_list
,
**
kw_args
)
pruner
=
pruner_cls
(
model
,
config_list
,
**
kw_args
)
...
@@ -273,11 +277,16 @@ def main(args):
...
@@ -273,11 +277,16 @@ def main(args):
if
args
.
speed_up
:
if
args
.
speed_up
:
# Unwrap all modules to normal state
# Unwrap all modules to normal state
pruner
.
_unwrap_model
()
pruner
.
_unwrap_model
()
m_speedup
=
ModelSpeedup
(
model
,
dummy_input
,
mask_path
,
device
)
m_speedup
=
ModelSpeedup
(
model
,
dummy_input
,
mask_path
,
device
)
m_speedup
.
speedup_model
()
m_speedup
.
speedup_model
()
print
(
'start finetuning...'
)
print
(
'start finetuning...'
)
# Optimizer used in the pruner might be patched, so recommend to new an optimizer for fine-tuning stage.
optimizer
=
torch
.
optim
.
SGD
(
model
.
parameters
(),
lr
=
0.01
,
momentum
=
0.9
,
weight_decay
=
5e-4
)
scheduler
=
MultiStepLR
(
optimizer
,
milestones
=
[
int
(
args
.
pretrain_epochs
*
0.5
),
int
(
args
.
pretrain_epochs
*
0.75
)],
gamma
=
0.1
)
best_top1
=
0
best_top1
=
0
save_path
=
os
.
path
.
join
(
args
.
experiment_data_dir
,
f
'finetuned.pth'
)
save_path
=
os
.
path
.
join
(
args
.
experiment_data_dir
,
f
'finetuned.pth'
)
for
epoch
in
range
(
args
.
fine_tune_epochs
):
for
epoch
in
range
(
args
.
fine_tune_epochs
):
...
...
examples/model_compress/pruning/model_speedup.py
→
examples/model_compress/pruning/
speedup/
model_speedup.py
View file @
403195f0
...
@@ -7,7 +7,7 @@ import torch.nn.functional as F
...
@@ -7,7 +7,7 @@ import torch.nn.functional as F
from
torchvision
import
datasets
,
transforms
from
torchvision
import
datasets
,
transforms
import
sys
import
sys
sys
.
path
.
append
(
'../models'
)
sys
.
path
.
append
(
'../
../
models'
)
from
cifar10.vgg
import
VGG
from
cifar10.vgg
import
VGG
from
mnist.lenet
import
LeNet
from
mnist.lenet
import
LeNet
...
...
examples/model_compress/pruning/speedup/speedup_mobilnetv2.py
0 → 100644
View file @
403195f0
import
torch
from
torchvision.models
import
mobilenet_v2
from
nni.compression.pytorch
import
ModelSpeedup
from
nni.algorithms.compression.pytorch.pruning
import
L1FilterPruner
model
=
mobilenet_v2
(
pretrained
=
True
)
dummy_input
=
torch
.
rand
(
8
,
3
,
416
,
416
)
cfg_list
=
[{
'op_types'
:[
'Conv2d'
],
'sparsity'
:
0.5
}]
pruner
=
L1FilterPruner
(
model
,
cfg_list
)
pruner
.
compress
()
pruner
.
export_model
(
'./model'
,
'./mask'
)
# need call _unwrap_model if you want run the speedup on the same model
pruner
.
_unwrap_model
()
# Speedup the nanodet
ms
=
ModelSpeedup
(
model
,
dummy_input
,
'./mask'
)
ms
.
speedup_model
()
model
(
dummy_input
)
\ No newline at end of file
examples/model_compress/pruning/speedup/speedup_nanodet.py
0 → 100644
View file @
403195f0
import
torch
from
nanodet.model.arch
import
build_model
from
nanodet.util
import
cfg
,
load_config
from
nni.compression.pytorch
import
ModelSpeedup
from
nni.algorithms.compression.pytorch.pruning
import
L1FilterPruner
"""
NanoDet model can be installed from https://github.com/RangiLyu/nanodet.git
"""
cfg_path
=
r
"nanodet/config/nanodet-RepVGG-A0_416.yml"
load_config
(
cfg
,
cfg_path
)
model
=
build_model
(
cfg
.
model
)
dummy_input
=
torch
.
rand
(
8
,
3
,
416
,
416
)
op_names
=
[]
# these three conv layers are followed by reshape-like functions
# that cannot be replaced, so we skip these three conv layers,
# you can also get such layers by `not_safe_to_prune` function
excludes
=
[
'head.gfl_cls.0'
,
'head.gfl_cls.1'
,
'head.gfl_cls.2'
]
for
name
,
module
in
model
.
named_modules
():
if
isinstance
(
module
,
torch
.
nn
.
Conv2d
):
if
name
not
in
excludes
:
op_names
.
append
(
name
)
cfg_list
=
[{
'op_types'
:[
'Conv2d'
],
'sparsity'
:
0.5
,
'op_names'
:
op_names
}]
pruner
=
L1FilterPruner
(
model
,
cfg_list
)
pruner
.
compress
()
pruner
.
export_model
(
'./model'
,
'./mask'
)
# need call _unwrap_model if you want run the speedup on the same model
pruner
.
_unwrap_model
()
# Speedup the nanodet
ms
=
ModelSpeedup
(
model
,
dummy_input
,
'./mask'
)
ms
.
speedup_model
()
model
(
dummy_input
)
\ No newline at end of file
examples/model_compress/pruning/speedup/speedup_yolov3.py
0 → 100644
View file @
403195f0
import
torch
from
pytorchyolo
import
models
from
nni.compression.pytorch
import
ModelSpeedup
from
nni.algorithms.compression.pytorch.pruning
import
L1FilterPruner
,
LevelPruner
from
nni.compression.pytorch.utils
import
not_safe_to_prune
# The Yolo can be downloaded at https://github.com/eriklindernoren/PyTorch-YOLOv3.git
prefix
=
'/home/user/PyTorch-YOLOv3'
# replace this path with yours
# Load the YOLO model
model
=
models
.
load_model
(
"%s/config/yolov3.cfg"
%
prefix
,
"%s/yolov3.weights"
%
prefix
)
model
.
eval
()
dummy_input
=
torch
.
rand
(
8
,
3
,
320
,
320
)
model
(
dummy_input
)
# Generate the config list for pruner
# Filter the layers that may not be able to prune
not_safe
=
not_safe_to_prune
(
model
,
dummy_input
)
cfg_list
=
[]
for
name
,
module
in
model
.
named_modules
():
if
name
in
not_safe
:
continue
if
isinstance
(
module
,
torch
.
nn
.
Conv2d
):
cfg_list
.
append
({
'op_types'
:[
'Conv2d'
],
'sparsity'
:
0.6
,
'op_names'
:[
name
]})
# Prune the model
pruner
=
L1FilterPruner
(
model
,
cfg_list
)
pruner
.
compress
()
pruner
.
export_model
(
'./model'
,
'./mask'
)
pruner
.
_unwrap_model
()
# Speedup the model
ms
=
ModelSpeedup
(
model
,
dummy_input
,
'./mask'
)
ms
.
speedup_model
()
model
(
dummy_input
)
Prev
1
2
3
4
5
6
7
8
9
10
11
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment