Unverified Commit 25db55ca authored by kvartet's avatar kvartet Committed by GitHub
Browse files

Update Chinese documents (#3243)

parent 53b565e4
# 贡献代码
非常感谢您有兴趣对 NNI 做出贡献!
除了编写代码外,您还可以通过多种方式参与, 本文档的目的是提供一个如何参与贡献的高层次概述。
# 反馈或提问
* 在 Github 上创建 [issue](https://github.com/microsoft/nni/issues/new/choose)
*[Stack Overflow](https://stackoverflow.com/questions/tagged/nni?sort=Newest&edited=true) 上使用 nni 标签提问。
*[Gitter](https://gitter.im/Microsoft/nni?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 中参与讨论。
加入聊天组:
| Gitter | | 微信 |
| -------------------------------------------------------------------------------------------------------------- | - | ----------------------------------------------------------------------- |
| ![image](https://user-images.githubusercontent.com/39592018/80665738-e0574a80-8acc-11ea-91bc-0836dc4cbf89.png) | 或 | ![image](https://github.com/scarlett2018/nniutil/raw/master/wechat.png) |
# 查找现有问题
在创建新 issue 之前,请在 [open issues](https://github.com/microsoft/nni/issues) 中进行搜索,以查看问题或功能请求是否已经存在。
确保已经浏览了 [最热门](https://github.com/microsoft/nni/issues?q=is%3Aopen+is%3Aissue+label%3AFAQ+sort%3Areactions-%2B1-desc) 的功能请求。
如果您的问题已经存在,请在下方发表评论或添加[回应](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments)。 通过回应来代替“+1”评论:
* 👍 - 赞成
* 👎 - 反对
如果未能找到描述您 Bug 或功能的现有问题,请使用以下指南创建一个新问题。
# 编写良好的错误报告或功能请求
针对每个错误和功能请求提交一个问题, 不要在同一问题中列举多个 Bug 或功能请求。
尽可能多地提供您认为与上下文相关的信息(思考问题如果分配给您,您需要什么样的信息来调试它)。 为了让您大致了解哪些信息对开发人员解决问题有帮助,我们为您提供了问题模板。
提交问题后,请务必跟进问题并参与讨论。
修正 Bug 或实现功能后,请务必关闭此问题。
# 贡献修复或示例
此项目欢迎任何贡献和建议。 大多数贡献需要您同意参与者许可协议(CLA),来声明您有权并授予我们使用您贡献的权利。 有关详细信息,请访问 https://cla.opensource.microsoft.com。
当你提交拉取请求时,CLA 机器人会自动检查你是否需要提供 CLA,并修饰这个拉取请求(例如标签、注释等)。 只需要按照机器人提供的说明进行操作即可。 CLA 只需要同意一次,就能应用到所有的代码仓库上。
# 行为准则
该项目采用了 [ Microsoft 开源行为准则 ](https://opensource.microsoft.com/codeofconduct/)。 有关详细信息,请参阅[行为守则常见问题解答](https://opensource.microsoft.com/codeofconduct/faq/)或联系 opencode@microsoft.com 咨询问题或评论。
# 参与贡献
熟悉贡献协议后,即可按照 NNI 开发人员教程,创建第一个 PR =):
* 推荐新贡献者先从简单的问题开始:['good first issue'](https://github.com/Microsoft/nni/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)['help-wanted'](https://github.com/microsoft/nni/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22)
* [NNI 开发环境安装教程](docs/zh_CN/Tutorial/SetupNniDeveloperEnvironment.rst)
* [如何调试](docs/zh_CN/Tutorial/HowToDebug.rst)
* 如果有使用上的问题,可先查看[常见问题解答](https://github.com/microsoft/nni/blob/master/docs/zh_CN/Tutorial/FAQ.rst)。如果没能解决问题,可通过 [Gitter](https://gitter.im/Microsoft/nni?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 联系 NNI 开发团队或在 GitHub 上 [报告问题](https://github.com/microsoft/nni/issues/new/choose)
* [自定义 Tuner](docs/zh_CN/Tuner/CustomizeTuner.rst)
* [实现定制的训练平台](docs/zh_CN/TrainingService/HowToImplementTrainingService.rst)
* [在 NNI 上实现新的 NAS Trainer](docs/zh_CN/NAS/Advanced.rst)
* [自定义 Advisor](docs/zh_CN/Tuner/CustomizeAdvisor.rst)
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
* * * * * *
[![MIT 许可证](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE) [![生成状态](https://msrasrg.visualstudio.com/NNIOpenSource/_apis/build/status/integration-test-local?branchName=master)](https://msrasrg.visualstudio.com/NNIOpenSource/_build/latest?definitionId=17&branchName=master) [![问题](https://img.shields.io/github/issues-raw/Microsoft/nni.svg)](https://github.com/Microsoft/nni/issues?q=is%3Aissue+is%3Aopen) [![Bug](https://img.shields.io/github/issues/Microsoft/nni/bug.svg)](https://github.com/Microsoft/nni/issues?q=is%3Aissue+is%3Aopen+label%3Abug) [![拉取请求](https://img.shields.io/github/issues-pr-raw/Microsoft/nni.svg)](https://github.com/Microsoft/nni/pulls?q=is%3Apr+is%3Aopen) [![版本](https://img.shields.io/github/release/Microsoft/nni.svg)](https://github.com/Microsoft/nni/releases) [![进入 https://gitter.im/Microsoft/nni 聊天室提问](https://badges.gitter.im/Microsoft/nni.svg)](https://gitter.im/Microsoft/nni?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![文档状态](https://readthedocs.org/projects/nni/badge/?version=latest)](https://nni.readthedocs.io/zh/latest/?badge=latest) [![MIT 许可证](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE) [![生成状态](https://msrasrg.visualstudio.com/NNIOpenSource/_apis/build/status/full%20test%20-%20linux?branchName=master)](https://msrasrg.visualstudio.com/NNIOpenSource/_build/latest?definitionId=62&branchName=master) [![问题](https://img.shields.io/github/issues-raw/Microsoft/nni.svg)](https://github.com/Microsoft/nni/issues?q=is%3Aissue+is%3Aopen) [![Bug](https://img.shields.io/github/issues/Microsoft/nni/bug.svg)](https://github.com/Microsoft/nni/issues?q=is%3Aissue+is%3Aopen+label%3Abug) [![拉取请求](https://img.shields.io/github/issues-pr-raw/Microsoft/nni.svg)](https://github.com/Microsoft/nni/pulls?q=is%3Apr+is%3Aopen) [![版本](https://img.shields.io/github/release/Microsoft/nni.svg)](https://github.com/Microsoft/nni/releases) [![进入 https://gitter.im/Microsoft/nni 聊天室提问](https://badges.gitter.im/Microsoft/nni.svg)](https://gitter.im/Microsoft/nni?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![文档状态](https://readthedocs.org/projects/nni/badge/?version=latest)](https://nni.readthedocs.io/zh/latest/?badge=latest)
[English](README.md) [English](README.md)
**NNI (Neural Network Intelligence)** 是一个轻量但强大的工具包,帮助用户**自动**的进行[特征工程](docs/zh_CN/FeatureEngineering/Overview.md)[神经网络架构搜索](docs/zh_CN/NAS/Overview.md)[超参调优](docs/zh_CN/Tuner/BuiltinTuner.md)以及[模型压缩](docs/zh_CN/Compressor/Overview.md) **NNI (Neural Network Intelligence)** 是一个轻量但强大的工具包,帮助用户**自动**的进行[特征工程](docs/zh_CN/FeatureEngineering/Overview.rst)[神经网络架构搜索](docs/zh_CN/NAS/Overview.rst)[超参调优](docs/zh_CN/Tuner/BuiltinTuner.rst)以及[模型压缩](docs/zh_CN/Compression/Overview.rst)
NNI 管理自动机器学习 (AutoML) 的 Experiment,**调度运行**由调优算法生成的 Trial 任务来找到最好的神经网络架构和/或超参,支持**各种训练环境**,如[本机](docs/zh_CN/TrainingService/LocalMode.md)[远程服务器](docs/zh_CN/TrainingService/RemoteMachineMode.md)[OpenPAI](docs/zh_CN/TrainingService/PaiMode.md)[Kubeflow](docs/zh_CN/TrainingService/KubeflowMode.md)[基于 K8S 的 FrameworkController(如,AKS 等)](docs/zh_CN/TrainingService/FrameworkControllerMode.md)[DLWorkspace](docs/zh_CN/TrainingService/DLTSMode.md) (又称 DLTS)</a>, [AML](docs/zh_CN/TrainingService/AMLMode.md) (Azure Machine Learning) 以及其它环境 NNI 管理自动机器学习 (AutoML) 的 Experiment,**调度运行**由调优算法生成的 Trial 任务来找到最好的神经网络架构和/或超参,支持**各种训练环境**,如[本机](docs/zh_CN/TrainingService/LocalMode.rst)[远程服务器](docs/zh_CN/TrainingService/RemoteMachineMode.rst)[OpenPAI](docs/zh_CN/TrainingService/PaiMode.rst)[Kubeflow](docs/zh_CN/TrainingService/KubeflowMode.rst)[基于 K8S 的 FrameworkController(如,AKS 等](docs/zh_CN/TrainingService/FrameworkControllerMode.rst)[DLWorkspace (又称 DLTS)](docs/zh_CN/TrainingService/DLTSMode.rst), [AML (Azure Machine Learning)](docs/zh_CN/TrainingService/AMLMode.rst), [AdaptDL(又称 ADL)](docs/zh_CN/TrainingService/AdaptDLMode.rst) 和其他云服务
## **使用场景** ## **使用场景**
...@@ -19,7 +19,7 @@ NNI 管理自动机器学习 (AutoML) 的 Experiment,**调度运行**由调优 ...@@ -19,7 +19,7 @@ NNI 管理自动机器学习 (AutoML) 的 Experiment,**调度运行**由调优
* 想要更容易**实现或试验新的自动机器学习算法**的研究员或数据科学家,包括:超参调优算法,神经网络搜索算法以及模型压缩算法。 * 想要更容易**实现或试验新的自动机器学习算法**的研究员或数据科学家,包括:超参调优算法,神经网络搜索算法以及模型压缩算法。
* 在机器学习平台中**支持自动机器学习** * 在机器学习平台中**支持自动机器学习**
### **[NNI v1.8 已发布!](https://github.com/microsoft/nni/releases) &nbsp;[<img width="48" src="docs/img/release_icon.png" />](#nni-released-reminder)** ### **[NNI v1.9 已发布!](https://github.com/microsoft/nni/releases) &nbsp;[<img width="48" src="docs/img/release_icon.png" />](#nni-released-reminder)**
## **NNI 功能一览** ## **NNI 功能一览**
...@@ -62,7 +62,7 @@ NNI 提供命令行工具以及友好的 WebUI 来管理训练的 Experiment。 ...@@ -62,7 +62,7 @@ NNI 提供命令行工具以及友好的 WebUI 来管理训练的 Experiment。
<li>TensorFlow</li> <li>TensorFlow</li>
<li>MXNet</li> <li>MXNet</li>
<li>Caffe2</li> <li>Caffe2</li>
<a href="docs/zh_CN/SupportedFramework_Library.md">更多...</a><br/> <a href="docs/zh_CN/SupportedFramework_Library.rst">更多...</a><br/>
</ul> </ul>
</ul> </ul>
<ul> <ul>
...@@ -71,7 +71,7 @@ NNI 提供命令行工具以及友好的 WebUI 来管理训练的 Experiment。 ...@@ -71,7 +71,7 @@ NNI 提供命令行工具以及友好的 WebUI 来管理训练的 Experiment。
<li>Scikit-learn</li> <li>Scikit-learn</li>
<li>XGBoost</li> <li>XGBoost</li>
<li>LightGBM</li> <li>LightGBM</li>
<a href="docs/zh_CN/SupportedFramework_Library.md">更多...</a><br/> <a href="docs/zh_CN/SupportedFramework_Library.rst">更多...</a><br/>
</ul> </ul>
</ul> </ul>
<ul> <ul>
...@@ -80,97 +80,100 @@ NNI 提供命令行工具以及友好的 WebUI 来管理训练的 Experiment。 ...@@ -80,97 +80,100 @@ NNI 提供命令行工具以及友好的 WebUI 来管理训练的 Experiment。
<li><a href="examples/trials/mnist-pytorch">MNIST-pytorch</li></a> <li><a href="examples/trials/mnist-pytorch">MNIST-pytorch</li></a>
<li><a href="examples/trials/mnist-tfv1">MNIST-tensorflow</li></a> <li><a href="examples/trials/mnist-tfv1">MNIST-tensorflow</li></a>
<li><a href="examples/trials/mnist-keras">MNIST-keras</li></a> <li><a href="examples/trials/mnist-keras">MNIST-keras</li></a>
<li><a href="docs/zh_CN/TrialExample/GbdtExample.md">Auto-gbdt</a></li> <li><a href="docs/zh_CN/TrialExample/GbdtExample.rst">Auto-gbdt</a></li>
<li><a href="docs/zh_CN/TrialExample/Cifar10Examples.md">Cifar10-pytorch</li></a> <li><a href="docs/zh_CN/TrialExample/Cifar10Examples.rst">Cifar10-pytorch</li></a>
<li><a href="docs/zh_CN/TrialExample/SklearnExamples.md">Scikit-learn</a></li> <li><a href="docs/zh_CN/TrialExample/SklearnExamples.rst">Scikit-learn</a></li>
<li><a href="docs/zh_CN/TrialExample/EfficientNet.md">EfficientNet</a></li> <li><a href="docs/zh_CN/TrialExample/EfficientNet.rst">EfficientNet</a></li>
<li><a href="docs/zh_CN/TrialExample/OpEvoExamples.md">GPU Kernel 调优</li></a> <li><a href="docs/zh_CN/TrialExample/OpEvoExamples.rst">GPU Kernel 调优</li></a>
<a href="docs/zh_CN/SupportedFramework_Library.md">更多...</a><br/> <a href="docs/zh_CN/SupportedFramework_Library.rst">更多...</a><br/>
</ul> </ul>
</ul> </ul>
</td> </td>
<td align="left" > <td align="left" >
<a href="docs/zh_CN/Tuner/BuiltinTuner.md">超参调优</a> <a href="docs/zh_CN/Tuner/BuiltinTuner.rst">超参调优</a>
<ul> <ul>
<b>穷举搜索</b> <b>穷举搜索</b>
<ul> <ul>
<li><a href="docs/zh_CN/Tuner/BuiltinTuner.md#Random">Random Search(随机搜索)</a></li> <li><a href="docs/zh_CN/Tuner/BuiltinTuner.rst#Random">Random Search(随机搜索)</a></li>
<li><a href="docs/zh_CN/Tuner/BuiltinTuner.md#GridSearch">Grid Search(遍历搜索)</a></li> <li><a href="docs/zh_CN/Tuner/BuiltinTuner.rst#GridSearch">Grid Search(遍历搜索)</a></li>
<li><a href="docs/zh_CN/Tuner/BuiltinTuner.md#Batch">Batch(批处理)</a></li> <li><a href="docs/zh_CN/Tuner/BuiltinTuner.rst#Batch">Batch(批处理)</a></li>
</ul> </ul>
<b>启发式搜索</b> <b>启发式搜索</b>
<ul> <ul>
<li><a href="docs/zh_CN/Tuner/BuiltinTuner.md#Evolution">Naïve Evolution(朴素进化)</a></li> <li><a href="docs/zh_CN/Tuner/BuiltinTuner.rst#Evolution">Naïve Evolution(朴素进化)</a></li>
<li><a href="docs/zh_CN/Tuner/BuiltinTuner.md#Anneal">Anneal(退火算法)</a></li> <li><a href="docs/zh_CN/Tuner/BuiltinTuner.rst#Anneal">Anneal(退火算法)</a></li>
<li><a href="docs/zh_CN/Tuner/BuiltinTuner.md#Hyperband">Hyperband</a></li> <li><a href="docs/zh_CN/Tuner/BuiltinTuner.rst#Hyperband">Hyperband</a></li>
<li><a href="docs/zh_CN/Tuner/BuiltinTuner.md#PBTTuner">PBT</a></li> <li><a href="docs/zh_CN/Tuner/BuiltinTuner.rst#PBTTuner">PBT</a></li>
</ul> </ul>
<b>贝叶斯优化</b> <b>贝叶斯优化</b>
<ul> <ul>
<li><a href="docs/zh_CN/Tuner/BuiltinTuner.md#BOHB">BOHB</a></li> <li><a href="docs/zh_CN/Tuner/BuiltinTuner.rst#BOHB">BOHB</a></li>
<li><a href="docs/zh_CN/Tuner/BuiltinTuner.md#TPE">TPE</a></li> <li><a href="docs/zh_CN/Tuner/BuiltinTuner.rst#TPE">TPE</a></li>
<li><a href="docs/zh_CN/Tuner/BuiltinTuner.md#SMAC">SMAC</a></li> <li><a href="docs/zh_CN/Tuner/BuiltinTuner.rst#SMAC">SMAC</a></li>
<li><a href="docs/zh_CN/Tuner/BuiltinTuner.md#MetisTuner">Metis Tuner</a></li> <li><a href="docs/zh_CN/Tuner/BuiltinTuner.rst#MetisTuner">Metis Tuner</a></li>
<li><a href="docs/zh_CN/Tuner/BuiltinTuner.md#GPTuner">GP Tuner</a></li> <li><a href="docs/zh_CN/Tuner/BuiltinTuner.rst#GPTuner">GP Tuner</a></li>
</ul> </ul>
<b>基于强化学习</b> <b>基于强化学习</b>
<ul> <ul>
<li><a href="docs/zh_CN/Tuner/BuiltinTuner.md#PPOTuner">PPO Tuner</a> </li> <li><a href="docs/zh_CN/Tuner/BuiltinTuner.rst#PPOTuner">PPO Tuner</a> </li>
</ul> </ul>
</ul> </ul>
<a href="docs/zh_CN/NAS/Overview.md">神经网络架构搜索</a> <a href="docs/zh_CN/NAS/Overview.rst">神经网络架构搜索</a>
<ul> <ul>
<ul> <ul>
<li><a href="docs/zh_CN/NAS/ENAS.md">ENAS</a></li> <li><a href="docs/zh_CN/NAS/ENAS.rst">ENAS</a></li>
<li><a href="docs/zh_CN/NAS/DARTS.md">DARTS</a></li> <li><a href="docs/zh_CN/NAS/DARTS.rst">DARTS</a></li>
<li><a href="docs/zh_CN/NAS/PDARTS.md">P-DARTS</a></li> <li><a href="docs/zh_CN/NAS/PDARTS.rst">P-DARTS</a></li>
<li><a href="docs/zh_CN/NAS/CDARTS.md">CDARTS</a></li> <li><a href="docs/zh_CN/NAS/CDARTS.rst">CDARTS</a></li>
<li><a href="docs/zh_CN/NAS/SPOS.md">SPOS</a></li> <li><a href="docs/zh_CN/NAS/SPOS.rst">SPOS</a></li>
<li><a href="docs/zh_CN/NAS/Proxylessnas.md">ProxylessNAS</a></li> <li><a href="docs/zh_CN/NAS/Proxylessnas.rst">ProxylessNAS</a></li>
<li><a href="docs/zh_CN/Tuner/BuiltinTuner.md#NetworkMorphism">Network Morphism</a></li> <li><a href="docs/zh_CN/Tuner/BuiltinTuner.rst#NetworkMorphism">Network Morphism</a></li>
<li><a href="docs/zh_CN/NAS/TextNAS.md">TextNAS</a></li> <li><a href="docs/zh_CN/NAS/TextNAS.rst">TextNAS</a></li>
<li><a href="docs/zh_CN/NAS/Cream.rst">Cream</a></li>
</ul> </ul>
</ul> </ul>
<a href="docs/zh_CN/Compressor/Overview.md">模型压缩</a> <a href="docs/zh_CN/Compression/Overview.rst">模型压缩</a>
<ul> <ul>
<b>剪枝</b> <b>剪枝</b>
<ul> <ul>
<li><a href="docs/zh_CN/Compressor/Pruner.md#agp-pruner">AGP Pruner</a></li> <li><a href="docs/zh_CN/Compression/Pruner.rst#agp-pruner">AGP Pruner</a></li>
<li><a href="docs/zh_CN/Compressor/Pruner.md#slim-pruner">Slim Pruner</a></li> <li><a href="docs/zh_CN/Compression/Pruner.rst#slim-pruner">Slim Pruner</a></li>
<li><a href="docs/zh_CN/Compressor/Pruner.md#fpgm-pruner">FPGM Pruner</a></li> <li><a href="docs/zh_CN/Compression/Pruner.rst#fpgm-pruner">FPGM Pruner</a></li>
<li><a href="docs/zh_CN/Compressor/Pruner.md#netadapt-pruner">NetAdapt Pruner</a></li> <li><a href="docs/zh_CN/Compression/Pruner.rst#netadapt-pruner">NetAdapt Pruner</a></li>
<li><a href="docs/zh_CN/Compressor/Pruner.md#simulatedannealing-pruner">SimulatedAnnealing Pruner</a></li> <li><a href="docs/zh_CN/Compression/Pruner.rst#simulatedannealing-pruner">SimulatedAnnealing Pruner</a></li>
<li><a href="docs/zh_CN/Compressor/Pruner.md#admm-pruner">ADMM Pruner</a></li> <li><a href="docs/zh_CN/Compression/Pruner.rst#admm-pruner">ADMM Pruner</a></li>
<li><a href="docs/zh_CN/Compressor/Pruner.md#autocompress-pruner">AutoCompress Pruner</a></li> <li><a href="docs/zh_CN/Compression/Pruner.rst#autocompress-pruner">AutoCompress Pruner</a></li>
</ul> </ul>
<b>量化</b> <b>量化</b>
<ul> <ul>
<li><a href="docs/zh_CN/Compressor/Quantizer.md#qat-quantizer">QAT Quantizer</a></li> <li><a href="docs/zh_CN/Compression/Quantizer.rst#qat-quantizer">QAT Quantizer</a></li>
<li><a href="docs/zh_CN/Compressor/Quantizer.md#dorefa-quantizer">DoReFa Quantizer</a></li> <li><a href="docs/zh_CN/Compression/Quantizer.rst#dorefa-quantizer">DoReFa Quantizer</a></li>
</ul> </ul>
</ul> </ul>
<a href="docs/zh_CN/FeatureEngineering/Overview.md">特征工程(测试版)</a> <a href="docs/zh_CN/FeatureEngineering/Overview.rst">特征工程(测试版)</a>
<ul> <ul>
<li><a href="docs/zh_CN/FeatureEngineering/GradientFeatureSelector.md">GradientFeatureSelector</a></li> <li><a href="docs/zh_CN/FeatureEngineering/GradientFeatureSelector.rst">GradientFeatureSelector</a></li>
<li><a href="docs/zh_CN/FeatureEngineering/GBDTSelector.md">GBDTSelector</a></li> <li><a href="docs/zh_CN/FeatureEngineering/GBDTSelector.rst">GBDTSelector</a></li>
</ul> </ul>
<a href="docs/zh_CN/Assessor/BuiltinAssessor.md">提前终止算法</a> <a href="docs/zh_CN/Assessor/BuiltinAssessor.rst">提前终止算法</a>
<ul> <ul>
<li><a href="docs/zh_CN/Assessor/BuiltinAssessor.md#Medianstop">Median Stop(中位数终止)</a></li> <li><a href="docs/zh_CN/Assessor/BuiltinAssessor.rst#Medianstop">Median Stop(中位数终止)</a></li>
<li><a href="docs/zh_CN/Assessor/BuiltinAssessor.md#Curvefitting">Curve Fitting(曲线拟合)</a></li> <li><a href="docs/zh_CN/Assessor/BuiltinAssessor.rst#Curvefitting">Curve Fitting(曲线拟合)</a></li>
</ul> </ul>
</td> </td>
<td> <td>
<ul> <ul>
<li><a href="docs/zh_CN/TrainingService/LocalMode.md">本机</a></li> <li><a href="docs/zh_CN/TrainingService/LocalMode.rst">本机</a></li>
<li><a href="docs/zh_CN/TrainingService/RemoteMachineMode.md">远程计算机</a></li> <li><a href="docs/zh_CN/TrainingService/RemoteMachineMode.rst">远程计算机</a></li>
<li><a href="docs/zh_CN/TrainingService/AMLMode.md">AML(Azure Machine Learning)</a></li> <li><a href="docs/zh_CN/TrainingService/AMLMode.rst">AML(Azure Machine Learning)</a></li>
<li><b>基于 Kubernetes 的平台</b></li> <li><b>基于 Kubernetes 的平台</b></li>
<ul><li><a href="docs/zh_CN/TrainingService/PaiMode.md">OpenPAI</a></li> <ul>
<li><a href="docs/zh_CN/TrainingService/KubeflowMode.md">Kubeflow</a></li> <li><a href="docs/zh_CN/TrainingService/PaiMode.rst">OpenPAI</a></li>
<li><a href="docs/zh_CN/TrainingService/FrameworkControllerMode.md">基于 Kubernetes(AKS 等)的 FrameworkController</a></li> <li><a href="docs/zh_CN/TrainingService/KubeflowMode.rst">Kubeflow</a></li>
</ul> <li><a href="docs/zh_CN/TrainingService/FrameworkControllerMode.rst">基于 Kubernetes(AKS 等)的 FrameworkController</a></li>
<ul><li><a href="docs/zh_CN/TrainingService/DLTSMode.md">DLWorkspace (又称 DLTS)</a></li> <li><a href="docs/zh_CN/TrainingService/DLTSMode.rst">DLWorkspace(又称 DLTS)</a></li>
<li><a href="docs/zh_CN/TrainingService/AdaptDLMode.rst">AdaptDL(又称 ADL)</a></li>
</ul>
</ul> </ul>
</td> </td>
</tr> </tr>
...@@ -184,21 +187,21 @@ NNI 提供命令行工具以及友好的 WebUI 来管理训练的 Experiment。 ...@@ -184,21 +187,21 @@ NNI 提供命令行工具以及友好的 WebUI 来管理训练的 Experiment。
<td style="border-top:#FF0000 solid 0px;"> <td style="border-top:#FF0000 solid 0px;">
<ul> <ul>
<li><a href="https://nni.readthedocs.io/zh/latest/autotune_ref.html#trial">Python API</a></li> <li><a href="https://nni.readthedocs.io/zh/latest/autotune_ref.html#trial">Python API</a></li>
<li><a href="docs/zh_CN/Tutorial/AnnotationSpec.md">NNI Annotation</a></li> <li><a href="docs/zh_CN/Tutorial/AnnotationSpec.rst">NNI Annotation</a></li>
<li><a href="https://nni.readthedocs.io/zh/latest/installation.html">支持的操作系统</a></li> <li><a href="https://nni.readthedocs.io/zh/latest/installation.html">支持的操作系统</a></li>
</ul> </ul>
</td> </td>
<td style="border-top:#FF0000 solid 0px;"> <td style="border-top:#FF0000 solid 0px;">
<ul> <ul>
<li><a href="docs/zh_CN/Tuner/CustomizeTuner.md">自定义 Tuner</a></li> <li><a href="docs/zh_CN/Tuner/CustomizeTuner.rst">自定义 Tuner</a></li>
<li><a href="docs/zh_CN/Assessor/CustomizeAssessor.md">自定义 Assessor</a></li> <li><a href="docs/zh_CN/Assessor/CustomizeAssessor.rst">自定义 Assessor</a></li>
<li><a href="docs/zh_CN/Tutorial/InstallCustomizedAlgos.md">安装自定义的 Tuner,Assessor,Advisor</a></li> <li><a href="docs/zh_CN/Tutorial/InstallCustomizedAlgos.rst">安装自定义的 Tuner,Assessor,Advisor</a></li>
</ul> </ul>
</td> </td>
<td style="border-top:#FF0000 solid 0px;"> <td style="border-top:#FF0000 solid 0px;">
<ul> <ul>
<li><a href="docs/zh_CN/TrainingService/Overview.md">支持训练平台</li> <li><a href="docs/zh_CN/TrainingService/Overview.rst">支持训练平台</li>
<li><a href="docs/zh_CN/TrainingService/HowToImplementTrainingService.md">实现训练平台</a></li> <li><a href="docs/zh_CN/TrainingService/HowToImplementTrainingService.rst">实现训练平台</a></li>
</ul> </ul>
</td> </td>
</tr> </tr>
...@@ -230,8 +233,8 @@ Linux 和 macOS 下 NNI 系统需求[参考这里](https://nni.readthedocs.io/zh ...@@ -230,8 +233,8 @@ Linux 和 macOS 下 NNI 系统需求[参考这里](https://nni.readthedocs.io/zh
注意: 注意:
* 如果遇到任何权限问题,可添加 `--user` 在用户目录中安装 NNI。 * 如果遇到任何权限问题,可添加 `--user` 在用户目录中安装 NNI。
* 目前,Windows 上的 NNI 支持本机,远程和 OpenPAI 模式。 强烈推荐使用 Anaconda 或 Miniconda [在 Windows 上安装 NNI](docs/zh_CN/Tutorial/InstallationWin.md) * 目前,Windows 上的 NNI 支持本机,远程和 OpenPAI 模式。 强烈推荐使用 Anaconda 或 Miniconda [在 Windows 上安装 NNI](docs/zh_CN/Tutorial/InstallationWin.rst)
* 如果遇到如 `Segmentation fault` 等错误参考[常见问题](docs/zh_CN/Tutorial/FAQ.md)。 Windows 上的 FAQ 参考[在 Windows 上使用 NNI](docs/zh_CN/Tutorial/InstallationWin.md#faq) * 如果遇到如 `Segmentation fault` 等错误参考[常见问题](docs/zh_CN/Tutorial/FAQ.rst)。 Windows 上的 FAQ 参考[在 Windows 上使用 NNI](docs/zh_CN/Tutorial/InstallationWin.rst#faq)
### **验证安装** ### **验证安装**
...@@ -240,7 +243,7 @@ Linux 和 macOS 下 NNI 系统需求[参考这里](https://nni.readthedocs.io/zh ...@@ -240,7 +243,7 @@ Linux 和 macOS 下 NNI 系统需求[参考这里](https://nni.readthedocs.io/zh
* 通过克隆源代码下载示例。 * 通过克隆源代码下载示例。
```bash ```bash
git clone -b v1.8 https://github.com/Microsoft/nni.git git clone -b v1.9 https://github.com/Microsoft/nni.git
``` ```
* 运行 MNIST 示例。 * 运行 MNIST 示例。
...@@ -286,11 +289,11 @@ You can use these commands to get more information about the experiment ...@@ -286,11 +289,11 @@ You can use these commands to get more information about the experiment
----------------------------------------------------------------------- -----------------------------------------------------------------------
``` ```
* 在浏览器中打开 `Web UI url`,可看到下图的 Experiment 详细信息,以及所有的 Trial 任务。 查看[这里](docs/zh_CN/Tutorial/WebUI.md)的更多页面。 * 在浏览器中打开 `Web UI url`,可看到下图的 Experiment 详细信息,以及所有的 Trial 任务。 查看[这里](docs/zh_CN/Tutorial/WebUI.rst)的更多页面。
<table style="border: none"> <table style="border: none">
<th><img src="./docs/img/webui_overview_page.png" alt="drawing" width="395"/></th> <th><img src="./docs/img/webui-img/full-oview.png" alt="drawing" width="395" height="300"/></th>
<th><img src="./docs/img/webui_trialdetail_page.png" alt="drawing" width="410"/></th> <th><img src="./docs/img/webui-img/full-detail.png" alt="drawing" width="410" height="300"/></th>
</table> </table>
## **文档** ## **文档**
...@@ -310,13 +313,13 @@ You can use these commands to get more information about the experiment ...@@ -310,13 +313,13 @@ You can use these commands to get more information about the experiment
熟悉贡献协议后,即可按照 NNI 开发人员教程,创建第一个 PR: 熟悉贡献协议后,即可按照 NNI 开发人员教程,创建第一个 PR:
* 推荐新贡献者先从简单的问题开始:['good first issue'](https://github.com/Microsoft/nni/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)['help-wanted'](https://github.com/microsoft/nni/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) * 推荐新贡献者先从简单的问题开始:['good first issue'](https://github.com/Microsoft/nni/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)['help-wanted'](https://github.com/microsoft/nni/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22)
* [NNI 开发环境安装教程](docs/zh_CN/Tutorial/SetupNniDeveloperEnvironment.md) * [NNI 开发环境安装教程](docs/zh_CN/Tutorial/SetupNniDeveloperEnvironment.rst)
* [如何调试](docs/zh_CN/Tutorial/HowToDebug.md) * [如何调试](docs/zh_CN/Tutorial/HowToDebug.rst)
* 如果有使用上的问题,可先查看[常见问题解答](https://github.com/microsoft/nni/blob/master/docs/zh_CN/Tutorial/FAQ.md)。如果没能解决问题,可通过 [Gitter](https://gitter.im/Microsoft/nni?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 联系 NNI 开发团队或在 GitHub 上 [报告问题](https://github.com/microsoft/nni/issues/new/choose) * 如果有使用上的问题,可先查看[常见问题解答](https://github.com/microsoft/nni/blob/master/docs/zh_CN/Tutorial/FAQ.rst)。如果没能解决问题,可通过 [Gitter](https://gitter.im/Microsoft/nni?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 联系 NNI 开发团队或在 GitHub 上 [报告问题](https://github.com/microsoft/nni/issues/new/choose)
* [自定义 Tuner](docs/zh_CN/Tuner/CustomizeTuner.md) * [自定义 Tuner](docs/zh_CN/Tuner/CustomizeTuner.rst)
* [实现定制的训练平台](docs/zh_CN/TrainingService/HowToImplementTrainingService.md) * [实现定制的训练平台](docs/zh_CN/TrainingService/HowToImplementTrainingService.rst)
* [在 NNI 上实现新的 NAS Trainer](docs/zh_CN/NAS/Advanced.md) * [在 NNI 上实现新的 NAS Trainer](docs/zh_CN/NAS/Advanced.rst)
* [自定义 Advisor](docs/zh_CN/Tuner/CustomizeAdvisor.md) * [自定义 Advisor](docs/zh_CN/Tuner/CustomizeAdvisor.rst)
## **其它代码库和参考** ## **其它代码库和参考**
...@@ -325,14 +328,14 @@ You can use these commands to get more information about the experiment ...@@ -325,14 +328,14 @@ You can use these commands to get more information about the experiment
* ### **外部代码库** ### * ### **外部代码库** ###
* 在 NNI 中运行 [ENAS](examples/nas/enas/README_zh_CN.md) * 在 NNI 中运行 [ENAS](examples/nas/enas/README_zh_CN.md)
* [NNI 中的自动特征工程](examples/feature_engineering/auto-feature-engineering/README_zh_CN.md) * [NNI 中的自动特征工程](examples/feature_engineering/auto-feature-engineering/README_zh_CN.md)
* 使用 NNI 的 [矩阵分解超参调优](https://github.com/microsoft/recommenders/blob/master/notebooks/04_model_select_and_optimize/nni_surprise_svd.ipynb) * 使用 NNI 的 [矩阵分解超参调优](https://github.com/microsoft/recommenders/blob/master/examples/04_model_select_and_optimize/nni_surprise_svd.ipynb)
* [scikit-nni](https://github.com/ksachdeva/scikit-nni) 使用 NNI 为 scikit-learn 开发的超参搜索。 * [scikit-nni](https://github.com/ksachdeva/scikit-nni) 使用 NNI 为 scikit-learn 开发的超参搜索。
* ### **相关文章** ### * ### **相关文章** ###
* [超参数优化的对比](docs/zh_CN/CommunitySharings/HpoComparison.md) * [超参数优化的对比](docs/zh_CN/CommunitySharings/HpoComparison.rst)
* [神经网络结构搜索的对比](docs/zh_CN/CommunitySharings/NasComparison.md) * [神经网络结构搜索的对比](docs/zh_CN/CommunitySharings/NasComparison.rst)
* [并行化顺序算法:TPE](docs/zh_CN/CommunitySharings/ParallelizingTpeSearch.md) * [并行化顺序算法:TPE](docs/zh_CN/CommunitySharings/ParallelizingTpeSearch.rst)
* [使用 NNI 为 SVD 自动调参](docs/zh_CN/CommunitySharings/RecommendersSvd.md) * [使用 NNI 为 SVD 自动调参](docs/zh_CN/CommunitySharings/RecommendersSvd.rst)
* [使用 NNI 为 SPTAG 自动调参](docs/zh_CN/CommunitySharings/SptagAutoTune.md) * [使用 NNI 为 SPTAG 自动调参](docs/zh_CN/CommunitySharings/SptagAutoTune.rst)
* [使用 NNI 为 scikit-learn 查找超参](https://towardsdatascience.com/find-thy-hyper-parameters-for-scikit-learn-pipelines-using-microsoft-nni-f1015b1224c1) * [使用 NNI 为 scikit-learn 查找超参](https://towardsdatascience.com/find-thy-hyper-parameters-for-scikit-learn-pipelines-using-microsoft-nni-f1015b1224c1)
* **博客** - [AutoML 工具(Advisor,NNI 与 Google Vizier)的对比](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) 作者:[@gaocegege](https://github.com/gaocegege) - kubeflow/katib 的设计与实现的总结与分析章节 * **博客** - [AutoML 工具(Advisor,NNI 与 Google Vizier)的对比](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) 作者:[@gaocegege](https://github.com/gaocegege) - kubeflow/katib 的设计与实现的总结与分析章节
* **博客** - [NNI 2019 新功能汇总](https://mp.weixin.qq.com/s/7_KRT-rRojQbNuJzkjFMuA) by @squirrelsc * **博客** - [NNI 2019 新功能汇总](https://mp.weixin.qq.com/s/7_KRT-rRojQbNuJzkjFMuA) by @squirrelsc
...@@ -351,7 +354,7 @@ You can use these commands to get more information about the experiment ...@@ -351,7 +354,7 @@ You can use these commands to get more information about the experiment
## 相关项目 ## 相关项目
以探索先进技术和开放为目标,[Microsoft Research (MSR)](https://www.microsoft.com/en-us/research/group/systems-research-group-asia/) 还发布了一些相关的开源项目。 以探索先进技术和开放为目标,[Microsoft Research (MSR)](https://www.microsoft.com/en-us/research/group/systems-and-networking-research-group-asia/) 还发布了一些相关的开源项目。
* [OpenPAI](https://github.com/Microsoft/pai):作为开源平台,提供了完整的 AI 模型训练和资源管理能力,能轻松扩展,并支持各种规模的私有部署、云和混合环境。 * [OpenPAI](https://github.com/Microsoft/pai):作为开源平台,提供了完整的 AI 模型训练和资源管理能力,能轻松扩展,并支持各种规模的私有部署、云和混合环境。
* [FrameworkController](https://github.com/Microsoft/frameworkcontroller):开源的通用 Kubernetes Pod 控制器,通过单个控制器来编排 Kubernetes 上所有类型的应用。 * [FrameworkController](https://github.com/Microsoft/frameworkcontroller):开源的通用 Kubernetes Pod 控制器,通过单个控制器来编排 Kubernetes 上所有类型的应用。
......
# 内置 Assessor
NNI 提供了先进的评估算法,使用上也很简单。 下面是内置 Assessor 的介绍。
注意:点击 **Assessor 的名称**可了解每个 Assessor 的安装需求,建议的场景以及示例。 在每个 Assessor 建议场景最后,还有算法的详细说明。
当前支持以下 Assessor:
| Assessor | 算法简介 |
| --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [**Medianstop**](#MedianStop) | Medianstop 是一个简单的提前终止算法。 如果 Trial X 在步骤 S 的最好目标值低于所有已完成 Trial 前 S 个步骤目标平均值的中位数,这个 Trial 就会被提前停止。 [参考论文](https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/46180.pdf) |
| [**Curvefitting**](#Curvefitting) | Curve Fitting Assessor 是一个 LPA (learning, predicting, assessing,即学习、预测、评估) 的算法。 如果预测的 Trial X 在 step S 比性能最好的 Trial 要差,就会提前终止它。 此算法中采用了 12 种曲线来拟合精度曲线。 [参考论文](http://aad.informatik.uni-freiburg.de/papers/15-IJCAI-Extrapolation_of_Learning_Curves.pdf) |
## 用法
要使用 NNI 内置的 Assessor,需要在 `config.yml` 文件中添加 **builtinAssessorName****classArgs**。 这一节会介绍推荐的场景、参数等详细用法以及示例。
注意:参考示例中的格式来创建新的 `config.yml` 文件。
<a name="MedianStop"></a>
### Median Stop Assessor
> 名称:**Medianstop**
**建议场景**
适用于各种性能曲线,可用到各种场景中来加速优化过程。 [详细说明](./MedianstopAssessor.md)
**classArgs 要求:**
* **optimize_mode** (*maximize 或 minimize, 可选, 默认值为 maximize*) - 如果为 'maximize', Assessor 会在结果小于期望值时**终止** Trial。 如果为 'minimize',Assessor 会在结果大于期望值时**终止** Trial。
* **start_step** (*int, 可选, 默认值为 0*) - 只有收到 start_step 个中间结果后,才开始判断是否一个 Trial 应该被终止。
**使用示例:**
```yaml
# config.yml
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
start_step: 5
```
<br />
<a name="Curvefitting"></a>
### Curve Fitting Assessor
> 名称:**Curvefitting**
**建议场景**
适用于各种性能曲线,可用到各种场景中来加速优化过程。 更好的是,它能够处理并评估性能类似的曲线。 [详细说明](./CurvefittingAssessor.md)
**注意**,根据原始论文,仅支持递增函数。 因此,此 Assessor 仅可用于最大化优化指标的场景。 例如,它可用于准确度,但不能用于损失值。
**classArgs 要求:**
* **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... 个中间结果。
**使用示例:**
```yaml
# config.yml
assessor:
builtinAssessorName: Curvefitting
classArgs:
epoch_num: 20
start_step: 6
threshold: 0.95
gap: 1
```
\ No newline at end of file
.. role:: raw-html(raw)
:format: html
内置 Assessor
==================
NNI 提供了先进的评估算法,使用上也很简单。 下面是内置 Assessor 的介绍。
注意:点击 **Assessor 的名称** 可了解每个 Assessor 的安装需求,建议的场景以及示例。 在每个 Assessor 建议场景最后,还有算法的详细说明。
当前支持以下 Assessor:
.. list-table::
:header-rows: 1
:widths: auto
* - Assessor
- 算法简介
* - `Medianstop <#MedianStop>`__
- Medianstop 是一个简单的提前终止算法。 如果尝试 X 的在步骤 S 的最好目标值比所有已完成尝试的步骤 S 的中位数值明显低,就会停止运行尝试 X。 `参考论文 <https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/46180.pdf>`__
* - `Curvefitting <#Curvefitting>`__
- Curve Fitting Assessor 是一个 LPA (learning, predicting, assessing,即学习、预测、评估) 的算法。 如果预测的 Trial X 在 step S 比性能最好的 Trial 要差,就会提前终止它。 此算法中采用了 12 种曲线来拟合精度曲线。 `参考论文 <http://aad.informatik.uni-freiburg.de/papers/15-IJCAI-Extrapolation_of_Learning_Curves.pdf>`__
用法
--------------------------
要使用 NNI 内置的 Assessor,需要在 ``config.yml`` 文件中添加 **builtinAssessorName** 和 **classArgs**。 这一节会介绍推荐的场景、参数等详细用法以及示例。
注意:参考示例中的格式来创建新的 ``config.yml`` 文件。
:raw-html:`<a name="MedianStop"></a>`
Median Stop Assessor
^^^^^^^^^^^^^^^^^^^^
..
名称:**Medianstop**
**建议场景**
适用于各种性能曲线,可用到各种场景中来加速优化过程。 `详细说明 <./MedianstopAssessor.rst>`__
**classArgs 要求:**
* **optimize_mode** (*maximize 或 minimize,可选默认值是maximize*)。如果为 'maximize',Assessor 会在结果小于期望值时**中止** Trial。 如果为 'minimize',Assessor 会在结果大于期望值时**终止** Trial。
* **start_step** (*int,可选,默认值为 0*)。只有收到 start_step 个中间结果后,才开始判断是否一个 Trial 应该被终止。
**使用示例:**
.. code-block:: yaml
# config.yml
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
start_step: 5
:raw-html:`<br>`
:raw-html:`<a name="Curvefitting"></a>`
Curve Fitting Assessor
^^^^^^^^^^^^^^^^^^^^^^
..
名称:**Curvefitting**
**建议场景**
适用于各种性能曲线,可用到各种场景中来加速优化过程。 更好的是,它能够处理并评估性能类似的曲线。 `详细说明 <./CurvefittingAssessor.rst>`__
**注意**,根据原始论文,仅支持递增函数。 因此,此 Assessor 仅可用于最大化优化指标的场景。 例如,它可用于准确度,但不能用于损失值。
**classArgs 要求:**
* **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... 个中间结果。
**使用示例:**
.. code-block:: yaml
# config.yml
assessor:
builtinAssessorName: Curvefitting
classArgs:
epoch_num: 20
start_step: 6
threshold: 0.95
gap: 1
# NNI 中的 Curve Fitting Assessor NNI 中的 Curve Fitting Assessor
===============================
## 介绍 介绍
------------
Curve Fitting Assessor 是一个 LPA (learning, predicting, assessing,即学习、预测、评估) 的算法。 如果预测的 Trial X 在 step S 比性能最好的 Trial 要差,就会提前终止它。 Curve Fitting Assessor 是一个 LPA (learning, predicting, assessing,即学习、预测、评估) 的算法。 如果预测的 Trial X 在 step S 比性能最好的 Trial 要差,就会提前终止它。
此算法中采用了 12 种曲线来拟合学习曲线。 这组参数曲线模型来自于[参考论文](http://aad.informatik.uni-freiburg.de/papers/15-IJCAI-Extrapolation_of_Learning_Curves.pdf)。 学习曲线的形状与先验知识是一致的:都是典型的递增的、饱和的函数。 此算法中采用了 12 种曲线来拟合学习曲线。 这组参数曲线模型来自于 `参考论文 <http://aad.informatik.uni-freiburg.de/papers/15-IJCAI-Extrapolation_of_Learning_Curves.pdf>`__。 学习曲线的形状与先验知识是一致的:都是典型的递增的、饱和的函数。
.. image:: ../../img/curvefitting_learning_curve.PNG
:target: ../../img/curvefitting_learning_curve.PNG
:alt: learning_curve
![learning_curve](../../img/curvefitting_learning_curve.PNG)
所有学习曲线模型被合并到了单个,更强大的模型中。 合并的模型通过加权线性混合: 所有学习曲线模型被合并到了单个,更强大的模型中。 合并的模型通过加权线性混合:
![f_comb](../../img/curvefitting_f_comb.gif)
.. image:: ../../img/curvefitting_f_comb.gif
:target: ../../img/curvefitting_f_comb.gif
:alt: f_comb
合并后的新参数向量 合并后的新参数向量
![expression_xi](../../img/curvefitting_expression_xi.gif)
.. image:: ../../img/curvefitting_expression_xi.gif
:target: ../../img/curvefitting_expression_xi.gif
:alt: expression_xi
假设增加一个高斯噪声,且噪声参数初始化为最大似然估计。 假设增加一个高斯噪声,且噪声参数初始化为最大似然估计。
...@@ -22,52 +36,66 @@ Curve Fitting Assessor 是一个 LPA (learning, predicting, assessing,即学 ...@@ -22,52 +36,66 @@ Curve Fitting Assessor 是一个 LPA (learning, predicting, assessing,即学
具体来说,该算法有学习、预测和评估三个阶段。 具体来说,该算法有学习、预测和评估三个阶段。
* 步骤 1:学习。 从当前 Trial 的历史中学习,并从贝叶斯角度决定 \xi 。 首先,使用由 `fit_theta` 实现的最小二乘法。 获得参数后,过滤曲线并移除异常点(由 `filter_curve` 实现)。 最后,使用 MCMC 采样方法。 由 `mcmc_sampling` 实现,来调整每条曲线的权重。 至此,确定了 \xi 中的所有参数。
* 步骤 2:预测。 用 \xi 和混合模型公式,由 `f_comb` 实现了,在目标位置(例如 epoch 的总数)来计算期望的最终结果精度。 *
步骤 1:学习。 从当前 Trial 的历史中学习,并从贝叶斯角度决定 \xi 。 首先,使用由 ``fit_theta`` 实现的最小二乘法。 获得参数后,过滤曲线并移除异常点(由 ``filter_curve`` 实现)。 最后,使用 MCMC 采样方法。 由 ``mcmc_sampling`` 实现,来调整每条曲线的权重。 至此,确定了 \xi 中的所有参数。
* 步骤 3:如果拟合结果不收敛,则预测值将为 `None`。 在这种情况下,会返回 `AssessResult.Good/code> 来请求进一步的精度和预测信息。 此外,将从 <code>predict()` 函数获得正确值。 如果该值大于历史最好结果 * `THRESHOLD`(默认为 0.95),则返回 `AssessResult.Good`,否则返回 `AssessResult.Bad` *
步骤 2:预测。 用 \xi 和混合模型公式,由 ``f_comb`` 实现了,在目标位置(例如 epoch 的总数)来计算期望的最终结果精度。
*
步骤 3:如果拟合结果不收敛,则预测值将为 ``None``。 在这种情况下,会返回 ``AssessResult.Good`` 来请求进一步的精度和预测信息。 此外,将从 ``predict()`` 函数获得正确值。 如果该值大于历史最好结果 * ``THRESHOLD``(默认为 0.95),则返回 ``AssessResult.Good``,否则返回 ``AssessResult.Bad``。
下图显示了此算法在 MNIST Trial 历史数据上结果。其中绿点表示 Assessor 获得的数据,蓝点表示将来,但未知的数据,红色线条是 Curve fitting Assessor 的预测曲线。 下图显示了此算法在 MNIST Trial 历史数据上结果。其中绿点表示 Assessor 获得的数据,蓝点表示将来,但未知的数据,红色线条是 Curve fitting Assessor 的预测曲线。
![示例](../../img/curvefitting_example.PNG)
## 用法 .. image:: ../../img/curvefitting_example.PNG
:target: ../../img/curvefitting_example.PNG
:alt: examples
用法
-----
要使用 Curve Fitting Assessor,需要在 Experiment 的 YAML 配置文件进行如下改动。 要使用 Curve Fitting Assessor,需要在 Experiment 的 YAML 配置文件进行如下改动。
```yaml .. code-block:: yaml
assessor:
builtinAssessorName: Curvefitting assessor:
classArgs: builtinAssessorName: Curvefitting
# (必须) epoch 的总数。 classArgs:
# 需要此数据来决定需要预测的点。 # (必需)epoch总数
epoch_num: 20 # 需要此数据来决定需要预测的点。
# (可选) 为了节约计算资源,仅在收到 start_step 个中间结果后,才开始进行预测。 epoch_num: 20
# start_step 的默认值是 6。 #(可选)为了节约计算资源,仅在收到 start_step 个中间结果后,才开始进行预测。
start_step: 6 # start_step 的默认值是 6。
# (可选) 决定是否提前终止的阈值。 start_step: 6
# 例如,如果 threshold = 0.95,最好的历史结果是 0.9,那么会在 Trial 的预测值低于 0.95 * 0.9 = 0.855 时停止。 # (可选)决定是否提前终止的阈值。
# 阈值的默认值是 0.95。 # 例如,如果 threshold = 0.95,最好的历史结果是 0.9,那么会在 Trial 的预测值低于 0.95 * 0.9 = 0.855 时停止。
threshold: 0.95 # 阈值的默认值是 0.95。
# (可选) gap 是两次评估之间的间隔次数。 threshold: 0.95
# 例如:如果 gap = 2, start_step = 6,就会评估第 6, 8, 10, 12... 个中间结果。 #(可选)gap 是两次评估之间的间隔次数。
# gap 的默认值是 1。 # 例如:如果 gap = 2, start_step = 6,就会评估第 6, 8, 10, 12... 个中间结果。
gap: 1 # gap 的默认值是 1。
``` gap: 1
## 局限性 局限性
----------
根据原始论文,仅支持递增函数。 因此,此 Assessor 仅可用于最大化优化指标的场景。 例如,它可用于准确度,但不能用于损失值。 根据原始论文,仅支持递增函数。 因此,此 Assessor 仅可用于最大化优化指标的场景。 例如,它可用于准确度,但不能用于损失值。
## 文件结构 文件结构
--------------
Assessor 有大量的文件、函数和类。 在这里,会简要描述其中一部分。 Assessor 有大量的文件、函数和类。 在这里,会简要描述其中一部分。
* `curvefunctions.py` 包含了所有函数表达式和默认参数。
* `modelfactory.py` 包括学习和预测部分,并实现了相应的计算部分。
* `curvefitting_assessor.py` 是接收 Trial 历史数据并评估是否需要提前终止的 Assessor。
## TODO * ``curvefunctions.py`` 包含了所有函数表达式和默认参数。
* ``curvefunctions.py`` 包括学习和预测部分,并实现了相应的计算部分。
* ``curvefitting_assessor.py`` 是接收 Trial 历史数据并评估是否需要提前终止的 Assessor。
TODO
----
* 进一步提高预测精度,并在更多模型上测试。 * 进一步提高预测精度,并在更多模型上测试。
\ No newline at end of file
# 自定义 Assessor
NNI 支持自定义 Assessor。
实现自定义的 Assessor,需要如下几步:
1. 继承 Assessor 基类
2. 实现 assess_trial 函数
3. 在 Experiment 的 YAML 文件中配置好自定义的 Assessor
**1. 继承 Assessor 基类**
```python
from nni.assessor import Assessor
class CustomizedAssessor(Assessor):
def __init__(self, ...):
...
```
**2. 实现 assess_trial 函数**
```python
from nni.assessor import Assessor, AssessResult
class CustomizedAssessor(Assessor):
def __init__(self, ...):
...
def assess_trial(self, trial_history):
"""
确定是否要停止该 Trial。 必须重载。
trial_history: 中间结果列表对象。
返回 AssessResult.Good 或 AssessResult.Bad。
"""
# 代码实现于此处。
...
```
**3. 在 Experiment 的 YAML 文件中配置好自定义的 Assessor**
NNI 需要定位到自定义的 Assessor 类,并实例化它,因此需要指定自定义 Assessor 类的文件位置,并将参数值传给 \_\_init__ 构造函数。
```yaml
assessor:
codeDir: /home/abc/myassessor
classFileName: my_customized_assessor.py
className: CustomizedAssessor
# 任何传入 __init__ 构造函数的参数,
# 都需要在 classArgs 字段中指定,如
classArgs:
arg1: value1
```
注意在 **2** 中, `trial_history` 对象与 Trial 通过 `report_intermediate_result` 函数返回给 Assessor 的对象完全一致。
Assessor 的工作目录是`<home>/nni-experiments/<experiment_id>/log` 可从环境变量 `NNI_LOG_DIRECTORY` 中获取。
更多示例,可参考:
> * [medianstop-assessor](https://github.com/Microsoft/nni/tree/master/src/sdk/pynni/nni/medianstop_assessor)
> * [curvefitting-assessor](https://github.com/Microsoft/nni/tree/master/src/sdk/pynni/nni/curvefitting_assessor)
\ No newline at end of file
自定义 Assessor
==================
NNI 支持自定义 Assessor。
实现自定义的 Assessor,需要如下几步:
#. 继承 Assessor 基类
#. 实现 assess_trial 函数
#. 在 Experiment 的 YAML 文件中配置好自定义的 Assessor
**1. 继承 Assessor 基类**
.. code-block:: python
from nni.assessor import Assessor
class CustomizedAssessor(Assessor):
def __init__(self, ...):
...
**2. 实现 assess_trial 函数**
.. code-block:: python
from nni.assessor import Assessor, AssessResult
class CustomizedAssessor(Assessor):
def __init__(self, ...):
...
def assess_trial(self, trial_history):
"""
决定 Trial 是否应该被终止。 必须重载。
trial_history: 中间结果列表对象。
返回 AssessResult.Good 或 AssessResult.Bad。
"""
# 你的代码
...
**3. 在 Experiment 的 YAML 文件中配置好自定义的 Assessor**
NNI 需要定位到自定义的 Assessor 类,并实例化它,因此需要指定自定义 Assessor 类的文件位置,并将参数值传给 __init__ 构造函数。
`论文 <https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/46180.pdf>`__。
.. code-block:: yaml
assessor:
codeDir: /home/abc/myassessor
classFileName: my_customized_assessor.py
className: CustomizedAssessor
# 所有的参数都需要传递给你 Assessor 的构造函数 __init__
# 例如,可以在可选的 classArgs 字段中指定
classArgs:
arg1: value1
注意 **2** 中: 对象 ``trial_history`` 和 ``report_intermediate_result`` 函数返回给 Assessor 的完全一致。
Assessor 的工作目录是 ``<home>/nni-experiments/<experiment_id>/log``\ ,可从环境变量 ``NNI_LOG_DIRECTORY``\ 中获取。
更多示例,可参考:
..
* :githublink:`medianstop-assessor <src/sdk/pynni/nni/medianstop_assessor>`
* :githublink:`curvefitting-assessor <src/sdk/pynni/nni/curvefitting_assessor>`
# Medianstop Assessor
## Median Stop
Medianstop 是一种简单的提前终止策略,可参考[论文](https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/46180.pdf)。 如果 Trial X 在步骤 S 的最好目标值低于所有已完成 Trial 前 S 个步骤目标平均值的中位数,这个 Trial 就会被提前停止。
\ No newline at end of file
Medianstop Assessor
==========================
Median Stop
-----------
Medianstop 是一种简单的提前终止策略,可参考 `论文 <https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/46180.pdf>`__。 如果 Trial X 在步骤 S 的最好目标值低于所有已完成 Trial 前 S 个步骤目标平均值的中位数,这个 Trial 就会被提前停止。
自动补全 nnictl 命令
===================================
NNI的命令行工具 **nnictl** 支持自动补全,也就是说,您可以通过按 ``tab`` 键来完成 nnictl 命令。
例如当前命令是
.. code-block:: bash
nnictl cre
按下 ``tab`` 键,它可以被自动补全成:
.. code-block:: bash
nnictl create
目前,如果您通过 ``pip`` 安装 NNI ,默认情况下不会启用自动补全,并且它只在bash shell 的 Linux 上工作。 如果要启用此功能,请参阅以下步骤:
步骤 1. 下载 ``bash-completion``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
cd ~
wget https://raw.githubusercontent.com/microsoft/nni/{nni-version}/tools/bash-completion
{nni-version} 应该填充 NNI 的版本,例如 ``master``\ , ``v1.9``。 你也可以 :githublink:`在这里 <tools/bash-completion>` 查看最新的 ``bash-completion`` 脚本。
步骤 2. 安装脚本
^^^^^^^^^^^^^^^^^^^^^^^^^^
如果您运行的是 root 帐户并希望为所有用户安装此脚本
.. code-block:: bash
install -m644 ~/bash-completion /usr/share/bash-completion/completions/nnictl
如果您只是想自己安装这个脚本
.. code-block:: bash
mkdir -p ~/.bash_completion.d
install -m644 ~/bash-completion ~/.bash_completion.d/nnictl
echo '[[ -f ~/.bash_completion.d/nnictl ]] && source ~/.bash_completion.d/nnictl' >> ~/.bash_completion
步骤 3. 重启终端
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
重新打开终端,您应该能够使用自动补全功能。 享受它吧!
步骤 4. 卸载
^^^^^^^^^^^^^^^^^
如果要卸载此功能,只需还原上述步骤中的更改。
# 超参数优化的对比
*匿名作者*
超参优化算法(HPO)在几个问题上的对比。
超参数优化算法如下:
- [Random Search](../Tuner/BuiltinTuner.md)
- [Grid Search](../Tuner/BuiltinTuner.md)
- [Evolution](../Tuner/BuiltinTuner.md)
- [Anneal](../Tuner/BuiltinTuner.md)
- [Metis](../Tuner/BuiltinTuner.md)
- [TPE](../Tuner/BuiltinTuner.md)
- [SMAC](../Tuner/BuiltinTuner.md)
- [HyperBand](../Tuner/BuiltinTuner.md)
- [BOHB](../Tuner/BuiltinTuner.md)
所有算法都在 NNI 本机环境下运行。
环境:
```
OS: Linux Ubuntu 16.04 LTS
CPU: Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz 2600 MHz
Memory: 112 GB
NNI Version: v0.7
NNI 模式(local|pai|remote): local
Python 版本: 3.6
使用的虚拟环境: Conda
是否在 Docker 中运行: no
```
## AutoGBDT 示例
### 问题描述
超参搜索上的非凸问题 [AutoGBDT](../TrialExample/GbdtExample.md)
### 搜索空间
```json
{
"num_leaves": {
"_type": "choice",
"_value": [10, 12, 14, 16, 18, 20, 22, 24, 28, 32, 48, 64, 96, 128]
},
"learning_rate": {
"_type": "choice",
"_value": [0.00001, 0.0001, 0.001, 0.01, 0.05, 0.1, 0.2, 0.5]
},
"max_depth": {
"_type": "choice",
"_value": [-1, 2, 3, 4, 5, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28, 32, 48, 64, 96, 128]
},
"feature_fraction": {
"_type": "choice",
"_value": [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2]
},
"bagging_fraction": {
"_type": "choice",
"_value": [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2]
},
"bagging_freq": {
"_type": "choice",
"_value": [1, 2, 4, 8, 10, 12, 14, 16]
}
}
```
总搜索空间为 1, 204, 224 次,将最大 Trial 次数设置为 1000。 时间限制为 48 小时。
### 结果
| 算法 | 最好的损失值 | 最好的 5 次损失的平均值 | 最好的 10 次损失的平均值 |
| ------------- | ------------ | ------------- | -------------- |
| Random Search | 0.418854 | 0.420352 | 0.421553 |
| Random Search | 0.417364 | 0.420024 | 0.420997 |
| Random Search | 0.417861 | 0.419744 | 0.420642 |
| Grid Search | 0.498166 | 0.498166 | 0.498166 |
| Evolution | 0.409887 | 0.409887 | 0.409887 |
| Evolution | 0.413620 | 0.413875 | 0.414067 |
| Evolution | 0.409887 | 0.409887 | 0.409887 |
| Anneal | 0.414877 | 0.417289 | 0.418281 |
| Anneal | 0.409887 | 0.409887 | 0.410118 |
| Anneal | 0.413683 | 0.416949 | 0.417537 |
| Metis | 0.416273 | 0.420411 | 0.422380 |
| Metis | 0.420262 | 0.423175 | 0.424816 |
| Metis | 0.421027 | 0.424172 | 0.425714 |
| TPE | 0.414478 | 0.414478 | 0.414478 |
| TPE | 0.415077 | 0.417986 | 0.418797 |
| TPE | 0.415077 | 0.417009 | 0.418053 |
| SMAC | **0.408386** | **0.408386** | **0.408386** |
| SMAC | 0.414012 | 0.414012 | 0.414012 |
| SMAC | **0.408386** | **0.408386** | **0.408386** |
| BOHB | 0.410464 | 0.415319 | 0.417755 |
| BOHB | 0.418995 | 0.420268 | 0.422604 |
| BOHB | 0.415149 | 0.418072 | 0.418932 |
| HyperBand | 0.414065 | 0.415222 | 0.417628 |
| HyperBand | 0.416807 | 0.417549 | 0.418828 |
| HyperBand | 0.415550 | 0.415977 | 0.417186 |
| GP | 0.414353 | 0.418563 | 0.420263 |
| GP | 0.414395 | 0.418006 | 0.420431 |
| GP | 0.412943 | 0.416566 | 0.418443 |
此例中,所有算法都使用了默认参数。 Metis 算法因为其高斯计算过程的复杂度为 O(n^3) 而运行非常慢,因此仅执行了 300 次 Trial。
## RocksDB 的 'fillrandom' 和 'readrandom' 基准测试
### 问题描述
[DB_Bench](https://github.com/facebook/rocksdb/wiki/Benchmarking-tools) 是用来做 [RocksDB](https://rocksdb.org/) 性能基准测试的工具。 有多个参数需要调优。
`DB_Bench` 的性能与计算机配置和安装方法有关。 在 `DB_Bench` Linux 系统上运行,并将 Rock 作为共享库安装。
#### 计算机配置
```
RocksDB: version 6.1
CPU: 6 * Intel(R) Xeon(R) CPU E5-2690 v4 @ 2.60GHz
CPUCache: 35840 KB
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
```
#### 存储性能
**延迟**:每个 IO 请求都需要一些时间才能完成,这称为平均延迟。 有几个因素会影响此时间,包括网络连接质量和硬盘IO性能。
**IOPS****每秒的 IO 操作数量**,这意味着可以在一秒钟内完成的_读取或写入操作次数_。
**IO 大小****每个 IO 请求的大小**。 根据操作系统和需要磁盘访问的应用程序、服务,它将同时发出读取或写入一定数量数据的请求。
**吞吐量(以 MB/s 为单位)= 平均 IO 大小 x IOPS **
IOPS 与在线处理能力有关,我们在实验中使用 IOPS 作为指标。
### 搜索空间
```json
{
"max_background_compactions": {
"_type": "quniform",
"_value": [1, 256, 1]
},
"block_size": {
"_type": "quniform",
"_value": [1, 500000, 1]
},
"write_buffer_size": {
"_type": "quniform",
"_value": [1, 130000000, 1]
},
"max_write_buffer_number": {
"_type": "quniform",
"_value": [1, 128, 1]
},
"min_write_buffer_number_to_merge": {
"_type": "quniform",
"_value": [1, 32, 1]
},
"level0_file_num_compaction_trigger": {
"_type": "quniform",
"_value": [1, 256, 1]
},
"level0_slowdown_writes_trigger": {
"_type": "quniform",
"_value": [1, 1024, 1]
},
"level0_stop_writes_trigger": {
"_type": "quniform",
"_value": [1, 1024, 1]
},
"cache_size": {
"_type": "quniform",
"_value": [1, 30000000, 1]
},
"compaction_readahead_size": {
"_type": "quniform",
"_value": [1, 30000000, 1]
},
"new_table_reader_for_compaction_inputs": {
"_type": "randint",
"_value": [1]
}
}
```
搜索空间非常大(约10 的 40 次方),将最大 Trial 次数设置为 100 以限制资源。
### 结果
#### fillrandom 基准
| 模型 | 最高 IOPS(重复 1 次) | 最高 IOPS(重复 2 次) | 最高 IOPS(重复 3 次) |
| --------- | --------------- | --------------- | --------------- |
| Random | 449901 | 427620 | 477174 |
| Anneal | 461896 | 467150 | 437528 |
| Evolution | 436755 | 389956 | 389790 |
| TPE | 378346 | 482316 | 468989 |
| SMAC | 491067 | 490472 | **491136** |
| Metis | 444920 | 457060 | 454438 |
图:
![](../../img/hpo_rocksdb_fillrandom.png)
#### readrandom 基准
| 模型 | 最高 IOPS(重复 1 次) | 最高 IOPS(重复 2 次) | 最高 IOPS(重复 3 次) |
| --------- | --------------- | --------------- | --------------- |
| Random | 2276157 | 2285301 | 2275142 |
| Anneal | 2286330 | 2282229 | 2284012 |
| Evolution | 2286524 | 2283673 | 2283558 |
| TPE | 2287366 | 2282865 | 2281891 |
| SMAC | 2270874 | 2284904 | 2282266 |
| Metis | **2287696** | 2283496 | 2277701 |
图:
![](../../img/hpo_rocksdb_readrandom.png)
超参数优化的对比
=======================================
*匿名作者*
超参优化算法(HPO)在几个问题上的对比。
超参数优化算法如下:
* `Random Search(随机搜索) <../Tuner/BuiltinTuner.rst>`__
* `Grid Search(网格搜索) <../Tuner/BuiltinTuner.rst>`__
* `Evolution <../Tuner/BuiltinTuner.rst>`__
* `Anneal <../Tuner/BuiltinTuner.rst>`__
* `Metis <../Tuner/BuiltinTuner.rst>`__
* `TPE <../Tuner/BuiltinTuner.rst>`__
* `SMAC <../Tuner/BuiltinTuner.rst>`__
* `HyperBand <../Tuner/BuiltinTuner.rst>`__
* `BOHB <../Tuner/BuiltinTuner.rst>`__
所有算法都在 NNI 本机环境下运行。
环境:
.. code-block:: bash
OS: Linux Ubuntu 16.04 LTS
CPU: Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz 2600 MHz
Memory: 112 GB
NNI Version: v0.7
NNI Mode(local|pai|remote): local
Python version: 3.6
Is conda or virtualenv used?: Conda
is running in docker?: no
AutoGBDT 示例
----------------
问题描述
^^^^^^^^^^^^^^^^^^^
超参搜索上的非凸问题 `AutoGBDT <../TrialExample/GbdtExample.rst>`__ 示例。
搜索空间
^^^^^^^^^^^^
.. code-block:: json
{
"num_leaves": {
"_type": "choice",
"_value": [10, 12, 14, 16, 18, 20, 22, 24, 28, 32, 48, 64, 96, 128]
},
"learning_rate": {
"_type": "choice",
"_value": [0.00001, 0.0001, 0.001, 0.01, 0.05, 0.1, 0.2, 0.5]
},
"max_depth": {
"_type": "choice",
"_value": [-1, 2, 3, 4, 5, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28, 32, 48, 64, 96, 128]
},
"feature_fraction": {
"_type": "choice",
"_value": [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2]
},
"bagging_fraction": {
"_type": "choice",
"_value": [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2]
},
"bagging_freq": {
"_type": "choice",
"_value": [1, 2, 4, 8, 10, 12, 14, 16]
}
}
总搜索空间为 1, 204, 224 次,将最大 Trial 次数设置为 1000。 时间限制为 48 小时。
结果
^^^^^^^
.. list-table::
:header-rows: 1
:widths: auto
* - 算法
- 最好的损失值
- 最好的 5 次损失的平均值
- 最好的 10 次损失的平均值
* - Random Search
- 0.418854
- 0.420352
- 0.421553
* - Random Search
- 0.417364
- 0.420024
- 0.420997
* - Random Search
- 0.417861
- 0.419744
- 0.420642
* - Grid Search
- 0.498166
- 0.498166
- 0.498166
* - Evolution
- 0.409887
- 0.409887
- 0.409887
* - Evolution
- 0.413620
- 0.413875
- 0.414067
* - Evolution
- 0.409887
- 0.409887
- 0.409887
* - Anneal
- 0.414877
- 0.417289
- 0.418281
* - Anneal
- 0.409887
- 0.409887
- 0.410118
* - Anneal
- 0.413683
- 0.416949
- 0.417537
* - Metis
- 0.416273
- 0.420411
- 0.422380
* - Metis
- 0.420262
- 0.423175
- 0.424816
* - Metis
- 0.421027
- 0.424172
- 0.425714
* - TPE
- 0.414478
- 0.414478
- 0.414478
* - TPE
- 0.415077
- 0.417986
- 0.418797
* - TPE
- 0.415077
- 0.417009
- 0.418053
* - SMAC
- **0.408386**
- **0.408386**
- **0.408386**
* - SMAC
- 0.414012
- 0.414012
- 0.414012
* - SMAC
- **0.408386**
- **0.408386**
- **0.408386**
* - BOHB
- 0.410464
- 0.415319
- 0.417755
* - BOHB
- 0.418995
- 0.420268
- 0.422604
* - BOHB
- 0.415149
- 0.418072
- 0.418932
* - HyperBand
- 0.414065
- 0.415222
- 0.417628
* - HyperBand
- 0.416807
- 0.417549
- 0.418828
* - HyperBand
- 0.415550
- 0.415977
- 0.417186
* - GP
- 0.414353
- 0.418563
- 0.420263
* - GP
- 0.414395
- 0.418006
- 0.420431
* - GP
- 0.412943
- 0.416566
- 0.418443
此例中,所有算法都使用了默认参数。 Metis 算法因为其高斯计算过程的复杂度为 O(n^3) 而运行非常慢,因此仅执行了 300 次 Trial。
RocksDB 的 'fillrandom' 和 'readrandom' 基准测试
------------------------------------------------------
问题描述
^^^^^^^^^^^^^^^^^^^
`DB_Bench <https://github.com/facebook/rocksdb/wiki/Benchmarking-tools>`__ 是用来做 `RocksDB <https://rocksdb.org/>`__ 性能基准测试的工具。 有多个参数需要调优。
``DB_Bench`` 的性能与计算机配置和安装方法有关。 在 ``DB_Bench`` Linux 系统上运行,并将 Rock 作为共享库安装。
计算机配置
^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
RocksDB: version 6.1
CPU: 6 * Intel(R) Xeon(R) CPU E5-2690 v4 @ 2.60GHz
CPUCache: 35840 KB
Keys: 16 bytes each
Values: 100 bytes each (50 bytes after compression)
Entries: 1000000
存储性能
^^^^^^^^^^^^^^^^^^^
**延迟** :每个 IO 请求都需要一些时间才能完成,这称为平均延迟。 有几个因素会影响此时间,包括网络连接质量和硬盘IO性能。
**IOPS**: **每秒的 IO 操作数量**,这意味着可以在一秒钟内完成的 *读取或写入操作次数*。
**IO 大小**: **每个 IO 请求的大小**。 根据操作系统和需要磁盘访问的应用程序、服务,它将同时发出读取或写入一定数量数据的请求。
**吞吐量(以 MB/s 为单位)= 平均 IO 大小 x IOPS**
IOPS 与在线处理能力有关,我们在实验中使用 IOPS 作为指标。
搜索空间
^^^^^^^^^^^^
.. code-block:: json
{
"max_background_compactions": {
"_type": "quniform",
"_value": [1, 256, 1]
},
"block_size": {
"_type": "quniform",
"_value": [1, 500000, 1]
},
"write_buffer_size": {
"_type": "quniform",
"_value": [1, 130000000, 1]
},
"max_write_buffer_number": {
"_type": "quniform",
"_value": [1, 128, 1]
},
"min_write_buffer_number_to_merge": {
"_type": "quniform",
"_value": [1, 32, 1]
},
"level0_file_num_compaction_trigger": {
"_type": "quniform",
"_value": [1, 256, 1]
},
"level0_slowdown_writes_trigger": {
"_type": "quniform",
"_value": [1, 1024, 1]
},
"level0_stop_writes_trigger": {
"_type": "quniform",
"_value": [1, 1024, 1]
},
"cache_size": {
"_type": "quniform",
"_value": [1, 30000000, 1]
},
"compaction_readahead_size": {
"_type": "quniform",
"_value": [1, 30000000, 1]
},
"new_table_reader_for_compaction_inputs": {
"_type": "randint",
"_value": [1]
}
}
搜索空间非常大(约10 的 40 次方),将最大 Trial 次数设置为 100 以限制资源。
结果
^^^^^^^
fillrandom 基准
^^^^^^^^^^^^^^^^^^^^^
.. list-table::
:header-rows: 1
:widths: auto
* - 模型
- 最高 IOPS(重复 1 次)
- 最高 IOPS(重复 2 次)
- 最高 IOPS(重复 3 次)
* - Random
- 449901
- 427620
- 477174
* - Anneal
- 461896
- 467150
- 437528
* - Evolution
- 436755
- 389956
- 389790
* - TPE
- 378346
- 482316
- 468989
* - SMAC
- 491067
- 490472
- **491136**
* - Metis
- 444920
- 457060
- 454438
图:
.. image:: ../../img/hpo_rocksdb_fillrandom.png
:target: ../../img/hpo_rocksdb_fillrandom.png
:alt:
readrandom 基准
^^^^^^^^^^^^^^^^^^^^^^
.. list-table::
:header-rows: 1
:widths: auto
* - 模型
- 最高 IOPS(重复 1 次)
- 最高 IOPS(重复 2 次)
- 最高 IOPS(重复 3 次)
* - Random
- 2276157
- 2285301
- 2275142
* - Anneal
- 2286330
- 2282229
- 2284012
* - Evolution
- 2286524
- 2283673
- 2283558
* - TPE
- 2287366
- 2282865
- 2281891
* - SMAC
- 2270874
- 2284904
- 2282266
* - Metis
- **2287696**
- 2283496
- 2277701
图:
.. image:: ../../img/hpo_rocksdb_readrandom.png
:target: ../../img/hpo_rocksdb_readrandom.png
:alt:
# 滤波器剪枝算法比较
为了初步了解各种滤波器剪枝算法的性能,在一些基准模型和数据集上使用各种剪枝算法进行了广泛的实验。 此文档中展示了实验结果。 此外,还对这些实验的复现提供了友好的说明,以促进对这项工作的进一步贡献。
## 实验设置
实验使用以下剪枝器/数据集/模型进行:
* 模型:[VGG16, ResNet18, ResNet50](https://github.com/microsoft/nni/tree/master/examples/model_compress/models/cifar10)
* 数据集:CIFAR-10
* 剪枝器:
- 剪枝器包括:
- 迭代式剪枝器 : `SimulatedAnnealing Pruner`, `NetAdapt Pruner`, `AutoCompress Pruner`。 给定总体稀疏度要求,这类剪枝器可以在不同层中自动分配稀疏度。
- 单轮剪枝器:`L1Filter Pruner``L2Filter Pruner``FPGM Pruner`。 每层的稀疏度与实验设置的总体稀疏度相同。
- 这里只比较 **filter pruning** 的剪枝效果。
对于迭代式剪枝器,使用 `L1Filter Pruner` 作为基础算法。 也就是说, 在迭代式剪枝器决定了稀疏度分布之后,使用 `L1Filter Pruner` 进行真正的剪枝。
- 上面列出来的所有的剪枝器都已经在 [NNI](https://github.com/microsoft/nni/tree/master/docs/zh_CN/Compressor/Overview.md) 中实现。
## 实验结果
对于每一个数据集/模型/剪枝器的组合,设置不同的目标稀疏度对模型进行剪枝。
这里展示了**权重数量 - 性能**曲线,还展示了**FLOPs - 性能**曲线。 同时在图上画出论文 [AutoCompress: An Automatic DNN Structured Pruning Framework for Ultra-High Compression Rates](http://arxiv.org/abs/1907.03141) 中对 VGG16 和 ResNet18 在 CIFAR-10 上的剪枝结果作为对比。
实验结果如下图所示:
CIFAR-10, VGG16:
![](../../../examples/model_compress/comparison_of_pruners/img/performance_comparison_vgg16.png)
CIFAR-10, ResNet18:
![](../../../examples/model_compress/comparison_of_pruners/img/performance_comparison_resnet18.png)
CIFAR-10, ResNet50:
![](../../../examples/model_compress/comparison_of_pruners/img/performance_comparison_resnet50.png)
## 分析
从实验结果中,得到以下结论:
* 如果稀疏度是通过限制参数量,那么迭代式剪枝器 ( `AutoCompress Pruner` , `SimualatedAnnealing Pruner` ) 比单轮剪枝器表现好。 但是在以 FLOPs 稀疏度为标准的情况下,它们相比于单轮剪枝器就没有了优势,因为当前的这些剪枝算法都是根据参数稀疏度来剪枝的。
* 在上述实验中,简单的单轮剪枝器 `L1Filter Pruner` , `L2Filter Pruner` , `FPGM Pruner` 表现比较相近。
* `NetAdapt Pruner` 无法达到比较高的压缩率。 因为它的机制是一次迭代只剪枝一层。 这就导致如果每次迭代剪掉的稀疏度远小于指定的总的稀疏度的话,会导致不可接受的剪枝复杂度。
## 实验复现
### 实现细节
* 实验结果都是在 NNI 中使用剪枝器的默认配置收集的,这意味着当我们在 NNI 中调用一个剪枝器类时,我们不会更改任何默认的类参数。
* FLOPs 和 参数数量均通过 [模型 FLOPs 和参数计数器](https://github.com/microsoft/nni/blob/master/docs/zh_CN/Compressor/CompressionUtils.md#model-flopsparameters-counter)[模型加速](https://github.com/microsoft/nni/blob/master/docs/zh_CN/Compressor/ModelSpeedup.md)后计算。 这避免了依据掩码模型计算的潜在问题。
* 实验代码在[这里](https://github.com/microsoft/nni/tree/master/examples/model_compress/auto_pruners_torch.py)
### 实验结果展示
* 如果遵循[示例](https://github.com/microsoft/nni/tree/master/examples/model_compress/auto_pruners_torch.py)的做法,对于每一次剪枝实验,实验结果将以JSON格式保存如下:
``` json
{
"performance": {"original": 0.9298, "pruned": 0.1, "speedup": 0.1, "finetuned": 0.7746},
"params": {"original": 14987722.0, "speedup": 167089.0},
"flops": {"original": 314018314.0, "speedup": 38589922.0}
}
```
* 实验结果保存在[这里](https://github.com/microsoft/nni/tree/master/examples/model_compress/comparison_of_pruners)。 可以参考[分析](https://github.com/microsoft/nni/blob/master/examples/model_compress/comparison_of_pruners/analyze.py)来绘制新的性能比较图。
## 贡献
### 待办事项
* 有 FLOPS/延迟 限制的剪枝器
* 更多剪枝算法/数据集/模型
### 问题
关于算法实现及实验问题,请[发起 issue](https://github.com/microsoft/nni/issues/new/)
滤波器剪枝算法比较
=======================================
为了初步了解各种滤波器剪枝算法的性能,
NNI 在一些基准模型和数据集上使用各种剪枝算法进行了广泛的实验。
此文档中展示了实验结果。
此外,还对这些实验的复现提供了友好的说明,以促进对这项工作的进一步贡献。
实验设置
------------------
实验使用以下剪枝器/数据集/模型进行:
*
模型: :githublink:`VGG16, ResNet18, ResNet50 <examples/model_compress/models/cifar10>`
*
数据集:CIFAR-10
*
剪枝器:
* 剪枝器包括:
迭代式剪枝器 : ``SimulatedAnnealing Pruner``\ , ``NetAdapt Pruner``\ , ``AutoCompress Pruner``。
给定总体稀疏度要求,这类剪枝器可以在不同层中自动分配稀疏度。
单轮剪枝器:``L1Filter Pruner``\ , ``L2Filter Pruner``\ , ``FPGM Pruner``。
每层的稀疏度与实验设置的总体稀疏度相同。
*
这里只比较 **filter pruning** 的剪枝效果。
对于迭代式剪枝器,使用 ``L1Filter Pruner`` 作为基础算法。 也就是说, 在迭代式剪枝器决定了稀疏度分布之后,使用 ``L1Filter Pruner`` 进行真正的剪枝。
*
上面列出来的所有的剪枝器都已经在 :githublink:`nni <docs/zh_CN/Compression/Overview.rst>` 中实现。
实验结果
-----------------
对于每一个数据集/模型/剪枝器的组合,设置不同的目标稀疏度对模型进行剪枝。
这里展示了 **权重数量 - 性能** 曲线,还展示了 **FLOPs - 性能** 曲线。
同时在图上画出论文 `AutoCompress: An Automatic DNN Structured Pruning Framework for Ultra-High Compression Rates <http://arxiv.org/abs/1907.03141>`__ 中对 VGG16 和 ResNet18 在 CIFAR-10 上的剪枝结果作为对比。
实验结果如下图所示:
CIFAR-10, VGG16:
.. image:: ../../../examples/model_compress/comparison_of_pruners/img/performance_comparison_vgg16.png
:target: ../../../examples/model_compress/comparison_of_pruners/img/performance_comparison_vgg16.png
:alt:
CIFAR-10, ResNet18:
.. image:: ../../../examples/model_compress/comparison_of_pruners/img/performance_comparison_resnet18.png
:target: ../../../examples/model_compress/comparison_of_pruners/img/performance_comparison_resnet18.png
:alt:
CIFAR-10, ResNet50:
.. image:: ../../../examples/model_compress/comparison_of_pruners/img/performance_comparison_resnet50.png
:target: ../../../examples/model_compress/comparison_of_pruners/img/performance_comparison_resnet50.png
:alt:
分析
--------
从实验结果中,得到以下结论:
* 如果稀疏度是通过限制参数量,那么迭代式剪枝器 ( ``AutoCompress Pruner`` , ``SimualatedAnnealing Pruner`` ) 比单轮剪枝器表现好。 但是在以 FLOPs 稀疏度为标准的情况下,它们相比于单轮剪枝器就没有了优势,因为当前的这些剪枝算法都是根据参数稀疏度来剪枝的。
* 在上述实验中,简单的单轮剪枝器 ``L1Filter Pruner`` , ``L2Filter Pruner`` , ``FPGM Pruner`` 表现比较相近。
* ``NetAdapt Pruner`` 无法达到比较高的压缩率。 因为它的机制是一次迭代只剪枝一层。 这就导致如果每次迭代剪掉的稀疏度远小于指定的总的稀疏度的话,会导致不可接受的剪枝复杂度。
实验复现
------------------------
实现细节
^^^^^^^^^^^^^^^^^^^^^^
*
实验结果都是在 NNI 中使用剪枝器的默认配置收集的,这意味着当我们在 NNI 中调用一个剪枝器类时,我们不会更改任何默认的类参数。
*
FLOPs 和 参数数量均通过 :githublink:`模型 FLOPs 和参数量计数器 <docs/zh_CN/Compression/CompressionUtils.md#model-flopsparameters-counter>` 在 :githublink:`模型加速 <docs/zh_CN/Compression/ModelSpeedup.rst>` 后计算。
这避免了依据掩码模型计算的潜在问题。
*
实验代码在 :githublink:`这里 <examples/model_compress/auto_pruners_torch.py>`。
实验结果展示
^^^^^^^^^^^^^^^^^^^^^^^^^^^
*
如果遵循 :githublink:`示例 <examples/model_compress/auto_pruners_torch.py>` 的做法,对于每一次剪枝实验,实验结果将以JSON格式保存如下:
.. code-block:: json
{
"performance": {"original": 0.9298, "pruned": 0.1, "speedup": 0.1, "finetuned": 0.7746},
"params": {"original": 14987722.0, "speedup": 167089.0},
"flops": {"original": 314018314.0, "speedup": 38589922.0}
}
*
实验代码在 :githublink:`这里 <examples/model_compress/comparison_of_pruners>`。可以参考 :githublink:`分析 <examples/model_compress/comparison_of_pruners/analyze.py>` 来绘制新的性能比较图。
贡献
------------
待办事项
^^^^^^^^^^
* 有 FLOPS/延迟 限制的剪枝器
* 更多剪枝算法/数据集/模型
问题
^^^^^^
关于算法实现及实验问题,请 `发起 issue <https://github.com/microsoft/nni/issues/new/>`__。
# 来自知乎的评论: <an open source project with highly reasonable design> - 作者 Garvin Li .. role:: raw-html(raw)
:format: html
本文由 NNI 用户在知乎论坛上发表。 在这篇文章中,Garvin 分享了在使用 NNI 进行自动特征工程方面的体验。 我们认为本文对于有兴趣使用 NNI 进行特征工程的用户非常有用。 经作者许可,将原始文章摘编如下。
**原文**: [如何看待微软最新发布的AutoML平台NNI?作者 Garvin Li](https://www.zhihu.com/question/297982959/answer/964961829?utm_source=wechat_session&utm_medium=social&utm_oi=28812108627968&from=singlemessage&isappinstalled=0) 来自知乎的评论::raw-html:`<an open source project with highly reasonable design>` - 作者 Garvin Li
========================================================================================================================
## 01 AutoML概述 本文由 NNI 用户在知乎论坛上发表。 在这篇文章中,Garvin 分享了在使用 NNI 进行自动特征工程方面的体验。 我们认为本文对于有兴趣使用 NNI 进行特征工程的用户非常有用。 经作者许可,将原始文章摘编如下。
作者认为 AutoML 不光是调参,应该包含自动特征工程。AutoML 是一个系统化的体系,包括:自动特征工程(AutoFeatureEng)、自动调参(AutoTuning)、自动神经网络探索(NAS)等。 **原文**\ : `如何看待微软最新发布的AutoML平台NNI?By Garvin Li <https://www.zhihu.com/question/297982959/answer/964961829?utm_source=wechat_session&utm_medium=social&utm_oi=28812108627968&from=singlemessage&isappinstalled=0>`__
## 02 NNI 概述 01 AutoML概述
---------------------
NNI((Neural Network Intelligence)是一个微软的开源 AutoML 工具包,通过自动而有效的方法来帮助用户设计并调优机器学习模型,神经网络架构,或复杂系统的参数。 作者认为 AutoML 不光是调参,
也可以针对机器学习过程不同阶段,
包括特征工程、神经网络架构搜索等。
链接:[ https://github.com/Microsoft/nni](https://github.com/Microsoft/nni) 02 NNI 概述
------------------
我目前只学习了自动特征工程这一个模块,总体看微软的工具都有一个比较大的特点,技术可能不一定多新颖,但是设计都非常赞。 NNI 的 AutoFeatureENG 基本包含了用户对于 AutoFeatureENG 的一切幻想。在微软做 PD 应该挺幸福吧,底层的这些个框架的设计都极为合理。 NNI (Neural Network Intelligence) 是一个微软开源的自动机器学习工具包。
通过自动而有效的方法来帮助用户设计并调优机器学习模型,神经网络架构,
或复杂系统的参数
链接: `https://github.com/Microsoft/nni <https://github.com/Microsoft/nni>`__
总体看微软的工具都有一个比较大的特点,
技术可能不一定多新颖,但是设计都非常赞。
NNI 的 AutoFeatureENG 基本包含了用户对于 AutoFeatureENG 的一切幻想。
底层的框架的设计都极为合理。
03 细说NNI - AutoFeatureENG
--------------------------------
本文使用了此项目: `https://github.com/SpongebBob/tabular_automl_NNI <https://github.com/SpongebBob/tabular_automl_NNI>`__。
## 03 细说NNI - AutoFeatureENG
> 本文使用了此项目: [https://github.com/SpongebBob/tabular_automl_NNI](https://github.com/SpongebBob/tabular_automl_NNI)。
新用户可以使用 NNI 轻松高效地进行 AutoFeatureENG。 使用是非常简单的,安装下文件中的 require,然后 pip install NNI。 新用户可以使用 NNI 轻松高效地进行 AutoFeatureENG。 使用是非常简单的,安装下文件中的 require,然后 pip install NNI。
![](https://pic3.zhimg.com/v2-8886eea730cad25f5ac06ef1897cd7e4_r.jpg) NNI把 AutoFeatureENG 拆分成 exploration 和 selection 两个模块。 exploration 主要是特征衍生和交叉,selection 讲的是如何做特征筛选。
## 04 特征 Exploration .. image:: https://pic3.zhimg.com/v2-8886eea730cad25f5ac06ef1897cd7e4_r.jpg
:target: https://pic3.zhimg.com/v2-8886eea730cad25f5ac06ef1897cd7e4_r.jpg
:alt:
NNI把 AutoFeatureENG 拆分成 exploration 和 selection 两个模块。 exploration 主要是特征衍生和交叉,selection 讲的是如何做特征筛选。
对于功能派生,NNI 提供了许多可自动生成新功能的操作,[列表](https://github.com/SpongebBob/tabular_automl_NNI/blob/master/AutoFEOp.md)如下: 04 特征 Exploration
----------------------
对于功能派生,NNI 提供了许多可自动生成新功能的操作, `列表如下 <https://github.com/SpongebBob/tabular_automl_NNI/blob/master/AutoFEOp.rst>`__
**count**:传统的统计,统计一些数据的出现频率 **count**:传统的统计,统计一些数据的出现频率
...@@ -43,38 +67,65 @@ NNI((Neural Network Intelligence)是一个微软的开源 AutoML 工具包 ...@@ -43,38 +67,65 @@ NNI((Neural Network Intelligence)是一个微软的开源 AutoML 工具包
具体特征怎么交叉,哪一列和哪一列交叉,每一列特征用什么方式衍生呢?可以通过 **search_space. json** 这个文件控制。 具体特征怎么交叉,哪一列和哪一列交叉,每一列特征用什么方式衍生呢?可以通过 **search_space. json** 这个文件控制。
![](https://pic1.zhimg.com/v2-3c3eeec6eea9821e067412725e5d2317_r.jpg)
图片展示了定义搜索空间的过程。 NNI 为 1 阶运算提供计数编码,并为 2 阶运算提供聚合的统计(min max var mean median nunique)。 .. image:: https://pic1.zhimg.com/v2-3c3eeec6eea9821e067412725e5d2317_r.jpg
:target: https://pic1.zhimg.com/v2-3c3eeec6eea9821e067412725e5d2317_r.jpg
:alt:
图片展示了定义搜索空间的过程。 NNI 为 1 阶运算提供计数编码,并为 2 阶运算提供聚合的统计(min max var mean median nunique)。
例如,希望以下列方式搜索列名称 {"C1"、"...","C26"} 上的频率编码(valuecount)功能的功能: 例如,希望以下列方式搜索列名称 {"C1"、"...","C26"} 上的频率编码(valuecount)功能的功能:
![](https://github.com/JSong-Jia/Pic/blob/master/images/pic%203.jpg)
.. image:: https://github.com/JSong-Jia/Pic/blob/master/images/pic%203.jpg
:target: https://github.com/JSong-Jia/Pic/blob/master/images/pic%203.jpg
:alt:
可以在列 {"C1",...,"C26"} x {"C1",...,"C26"} 上定义交叉频率编码(交叉维度的值计数)方法: 可以在列 {"C1",...,"C26"} x {"C1",...,"C26"} 上定义交叉频率编码(交叉维度的值计数)方法:
![](https://github.com/JSong-Jia/Pic/blob/master/images/pic%204.jpg)
.. image:: https://github.com/JSong-Jia/Pic/blob/master/images/pic%204.jpg
:target: https://github.com/JSong-Jia/Pic/blob/master/images/pic%204.jpg
:alt:
Exploration 的目的就是长生出新的特征。 在代码里可以用 **get_next_parameter** 的方式获取 tuning 的参数: Exploration 的目的就是长生出新的特征。 在代码里可以用 **get_next_parameter** 的方式获取 tuning 的参数:
> RECEIVED_PARAMS = nni.get_next_parameter()
## 05 特征 Selection ..
RECEIVED_PARAMS = nni.get_next_parameter()
05 特征 Selection
--------------------
为了避免特征泛滥的情况,避免过拟合,一定要有 Selection 的机制挑选特征。 在 NNI-AutoFeatureENG 的 Selection 中,主要使用了微软开发的梯度提升框架 LightGBM(Light Gradient Boosting Machine)。 为了避免特征泛滥的情况,避免过拟合,一定要有 Selection 的机制挑选特征。 在 NNI-AutoFeatureENG 的 Selection 中,主要使用了微软开发的梯度提升框架 LightGBM(Light Gradient Boosting Machine)。
![](https://pic2.zhimg.com/v2-7bf9c6ae1303692101a911def478a172_r.jpg)
.. image:: https://pic2.zhimg.com/v2-7bf9c6ae1303692101a911def478a172_r.jpg
:target: https://pic2.zhimg.com/v2-7bf9c6ae1303692101a911def478a172_r.jpg
:alt:
了解 xgboost 或者 GBDT 算法同学应该知道,这种树形结构的算法是很容易计算出每个特征对于结果的影响的。 所以使用 lightGBM 可以天然的进行特征筛选。 了解 xgboost 或者 GBDT 算法同学应该知道,这种树形结构的算法是很容易计算出每个特征对于结果的影响的。 所以使用 lightGBM 可以天然的进行特征筛选。
弊病就是,如果下游是个 *LR*(逻辑回归)这种线性算法,筛选出来的特征是否具备普适性。 弊病就是,如果下游是个 *LR* (逻辑回归)这种线性算法,筛选出来的特征是否具备普适性。
.. image:: https://pic4.zhimg.com/v2-d2f919497b0ed937acad0577f7a8df83_r.jpg
:target: https://pic4.zhimg.com/v2-d2f919497b0ed937acad0577f7a8df83_r.jpg
:alt:
![](https://pic4.zhimg.com/v2-d2f919497b0ed937acad0577f7a8df83_r.jpg)
## 06 总结 06 总结
----------
NNI 的 AutoFeature 模块是给整个行业制定了一个教科书般的标准,告诉大家这个东西要怎么做,有哪些模块,使用起来非常方便。 但是如果只是基于这样简单的模式,不一定能达到很好的效果。 NNI 的 AutoFeature 模块是给整个行业制定了一个教科书般的标准,告诉大家这个东西要怎么做,有哪些模块,使用起来非常方便。 但是如果只是基于这样简单的模式,不一定能达到很好的效果。
## 对 NNI 的建议 对 NNI 的建议
------------------
我觉得在Exploration方面可以引用一些 DNN(如:xDeepFM) 的特征组合方式,提取更高维度的特征。 我觉得在Exploration方面可以引用一些 DNN(如:xDeepFM) 的特征组合方式,提取更高维度的特征。
...@@ -84,5 +135,6 @@ NNI 的 AutoFeature 模块是给整个行业制定了一个教科书般的标准 ...@@ -84,5 +135,6 @@ NNI 的 AutoFeature 模块是给整个行业制定了一个教科书般的标准
大家用的时候如果是 Mac 电脑可能会遇到 gcc 的问题,因为开源项目自带的脚本是基于 gcc7 编译的, 可以用下面的方法绕过去: 大家用的时候如果是 Mac 电脑可能会遇到 gcc 的问题,因为开源项目自带的脚本是基于 gcc7 编译的, 可以用下面的方法绕过去:
# brew install libomp .. code-block:: bash
brew install libomp
# 在 Google Colab 上使用 NNI
在 Google Colab 上轻松使用 NNI。 Colab 没有暴露它的公网 IP 及端口,因此默认情况下无法在 Colab 中访问 NNI 的 Web 界面。 为解决此问题,需要使用反向代理软件,例如 `ngrok``frp`。 此教程将展示如何使用 ngrok 在 Colab 上访问 NNI 的Web 界面。
## 如何在 Google Colab 上打开 NNI 的 Web 界面
1. 安装需要的包和软件。
```
! pip install nni # install nni
! wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip # download ngrok and unzip it
! unzip ngrok-stable-linux-amd64.zip
! mkdir -p nni_repo
! git clone https://github.com/microsoft/nni.git nni_repo/nni # clone NNI's offical repo to get examples
```
2.[此处](https://ngrok.com/)注册 ngrok 账号,然后通过 authtoken 来连接。
```
! ./ngrok authtoken <your-authtoken>
```
3. 在大于 1024 的端口号上启动 NNI 样例,之后在相同端口上启动 ngrok。 如果希望使用 GPU,确保 config.yml 中 gpuNum >= 1 。 因为使用 `! ngrok http 5000 &` 会停止响应,要使用 </0> get_ipython()</code> 来启动 ngrok。
```
! nnictl create --config nni_repo/nni/examples/trials/mnist-pytorch/config.yml --port 5000 &
get_ipython().system_raw('./ngrok http 5000 &')
```
4. 查看公网 url 。
```
! curl -s http://localhost:4040/api/tunnels # don't change the port number 4040
```
在步骤 4 后将会看到类似 http://xxxx.ngrok.io 的 url,打开此url即可看到 NNI 的Web 界面。 玩得开心 :)
## 使用 frp 访问 Web 界面
frp 是另一款提供了相似功能的反向代理软件。 但 frp 不提供免费的公网 url,因此可能需要一台拥有公网 IP 的服务器来作为 frp 的服务器端。 参考[这里](https://github.com/fatedier/frp)来了解如何部署 frp。
在 Google Colab 上使用 NNI
===============================
在 Google Colab 上轻松使用 NNI。 Colab 没有暴露它的公网 IP 及端口,因此默认情况下无法在 Colab 中访问 NNI 的 Web 界面。 为解决此问题,需要使用反向代理软件,例如 ``ngrok`` 或 ``frp``。 此教程将展示如何使用 ngrok 在 Colab 上访问 NNI 的Web 界面。
如何在 Google Colab 上打开 NNI 的 Web 界面
--------------------------------------------------
#. 安装需要的包和软件。
.. code-block:: bash
! pip install nni # install nni
! wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip # download ngrok and unzip it
! unzip ngrok-stable-linux-amd64.zip
! mkdir -p nni_repo
! git clone https://github.com/microsoft/nni.git nni_repo/nni # clone NNI's offical repo to get examples
#. 在 `here <https://ngrok.com/>`__ 注册 ngrok 账号,然后通过 authtoken 来连接。
.. code-block:: bash
! ./ngrok authtoken <your-authtoken>
#. 在大于 1024 的端口号上启动 NNI 样例,之后在相同端口上启动 ngrok。 如果希望使用 GPU,确保 config.yml 中 gpuNum >= 1 。 因为使用 ``ngrok http 5000 &`` 会停止响应,所以要使用 ``get_ipython()`` 来启动 ngrok。
.. code-block:: bash
! nnictl create --config nni_repo/nni/examples/trials/mnist-pytorch/config.yml --port 5000 &
get_ipython().system_raw('./ngrok http 5000 &')
#. 查看公网 url 。
.. code-block:: bash
! curl -s http://localhost:4040/api/tunnels # don't change the port number 4040
在步骤 4 后将会看到类似 http://xxxx.ngrok.io 的 url,打开此url即可看到 NNI 的Web 界面。 玩得开心 :)
使用 frp 访问 Web 界面
----------------------
frp 是另一款提供了相似功能的反向代理软件。 但 frp 不提供免费的公网 url,因此可能需要一台拥有公网 IP 的服务器来作为 frp 的服务器端。 参考 `这里 <https://github.com/fatedier/frp>`__ 来了解如何部署 frp。
# 神经网络结构搜索的对比 神经网络结构搜索的对比
=====================================
*匿名作者* *匿名作者*
训练和比较 NAS(神经网络架构搜索)的模型,包括 Autokeras,DARTS,ENAS 和 NAO。 训练和比较 NAS(神经网络架构搜索)的模型,包括 Autokeras,DARTS,ENAS 和 NAO。
源码链接如下: 源码链接如下:
- Autokeras: [https://github.com/jhfjhfj1/autokeras](https://github.com/jhfjhfj1/autokeras)
- DARTS: [https://github.com/quark0/darts](https://github.com/quark0/darts) *
Autokeras: `https://github.com/jhfjhfj1/autokeras <https://github.com/jhfjhfj1/autokeras>`__
- ENAS: [https://github.com/melodyguan/enas](https://github.com/melodyguan/enas) *
DARTS: `https://github.com/quark0/darts <https://github.com/quark0/darts>`__
- NAO: [https://github.com/renqianluo/NAO](https://github.com/renqianluo/NAO) *
ENAS: `https://github.com/melodyguan/enas <https://github.com/melodyguan/enas>`__
## 实验说明 *
NAO: `https://github.com/renqianluo/NAO <https://github.com/renqianluo/NAO>`__
为了避免算法仅仅在 **CIFAR-10** 数据集上过拟合,还对比了包括 Fashion-MNIST, CIFAR-100, OUI-Adience-Age, ImageNet-10-1 (ImageNet的子集) 和 ImageNet-10-2 (ImageNet 的另一个子集) 在内的其它 5 个数据集。 分别从 ImageNet 中抽取 10 种不同类别标签的子集,组成 ImageNet10-1 和 ImageNet10-2 数据集 。 实验说明
----------------------
| 数据集 | 训练数据集大小 | 类别标签数 | 数据集说明 | 为了避免算法仅仅在 **CIFAR-10** 数据集上过拟合,还对比了包括 Fashion-MNIST, CIFAR-100, OUI-Adience-Age, ImageNet-10-1 (ImageNet的子集) 和 ImageNet-10-2 (ImageNet 的另一个子集) 在内的其它 5 个数据集。 分别从 ImageNet 中抽取 10 种不同类别标签的子集,组成 ImageNet10-1 和 ImageNet10-2 数据集 。
|:--------------------------------------------------------------------------------------- | ------- | ----- | ----------------------------------------------------------- |
| [Fashion-MNIST](https://github.com/zalandoresearch/fashion-mnist) | 60,000 | 10 | T恤上衣,裤子,套头衫,连衣裙,外套,凉鞋,衬衫,运动鞋,包和踝靴。 |
| [CIFAR-10](https://www.cs.toronto.edu/~kriz/cifar.html) | 50,000 | 10 | 飞机,汽车,鸟类,猫,鹿,狗,青蛙,马,船和卡车。 |
| [CIFAR-100](https://www.cs.toronto.edu/~kriz/cifar.html) | 50,000 | 100 | 和 CIFAR-10 类似,但总共有 100 个类,每个类有 600 张图。 |
| [OUI-Adience-Age](https://talhassner.github.io/home/projects/Adience/Adience-data.html) | 26,580 | 8 | 8 个年龄组类别 (0-2, 4-6, 8-13, 15-20, 25-32, 38-43, 48-53, 60-)。 |
| [ImageNet-10-1](http://www.image-net.org/) | 9,750 | 10 | 咖啡杯、电脑键盘、餐桌、衣柜、割草机、麦克风、秋千、缝纫机、里程表和燃气泵。 |
| [ImageNet-10-2](http://www.image-net.org/) | 9,750 | 10 | 鼓,班吉,口哨,三角钢琴,小提琴,管风琴,原声吉他,长号,长笛和萨克斯。 |
.. list-table::
:header-rows: 1
:widths: auto
* - 数据集
- 训练数据集大小
- 类别标签数
- 数据集说明
* - `Fashion-MNIST <https://github.com/zalandoresearch/fashion-mnist>`__
- 60,000
- 10
- T恤上衣,裤子,套头衫,连衣裙,外套,凉鞋,衬衫,运动鞋,包和踝靴。
* - `CIFAR-10 <https://www.cs.toronto.edu/~kriz/cifar.html>`__
- 50,000
- 10
- 飞机,汽车,鸟类,猫,鹿,狗,青蛙,马,船和卡车。
* - `CIFAR-100 <https://www.cs.toronto.edu/~kriz/cifar.html>`__
- 50,000
- 100
- 和 CIFAR-10 类似,但总共有 100 个类,每个类有 600 张图。
* - `OUI-Adience-Age <https://talhassner.github.io/home/projects/Adience/Adience-data.html>`__
- 26,580
- 8
- 8 个年龄组类别 (0-2, 4-6, 8-13, 15-20, 25-32, 38-43, 48-53, 60-)。
* - `ImageNet-10-1 <http://www.image-net.org/>`__
- 9,750
- 10
- 咖啡杯、电脑键盘、餐桌、衣柜、割草机、麦克风、秋千、缝纫机、里程表和燃气泵。
* - `ImageNet-10-2 <http://www.image-net.org/>`__
- 9,750
- 10
- 鼓,班吉,口哨,三角钢琴,小提琴,管风琴,原声吉他,长号,长笛和萨克斯。
没有改变源码中的 Fine-tuning 方法。 为了匹配每个任务,改变了源码中模型的输入图片大小和输出类别数目的部分。 没有改变源码中的 Fine-tuning 方法。 为了匹配每个任务,改变了源码中模型的输入图片大小和输出类别数目的部分。
所有 NAS 方法模型搜索时间和重训练时间都是**两天**。 所有结果都是基于**三次重复实验**。 评估计算机有一块 Nvidia Tesla P100 GPU、112GB 内存和 2.60GHz CPU (Intel E5-2690)。 所有 NAS 方法模型搜索时间和重训练时间都是 **两天**。 所有结果都是基于 **三次重复实验**。 评估计算机有一块 Nvidia Tesla P100 GPU、112GB 内存和 2.60GHz CPU (Intel E5-2690)。
NAO 需要太多的计算资源,因此只使用提供 Pipeline 脚本的 NAO-WS。 NAO 需要太多的计算资源,因此只使用提供 Pipeline 脚本的 NAO-WS。
对于 AutoKeras,使用了 0.2.18 版本的代码, 因为这是开始实验时的最新版本。 对于 AutoKeras,使用了 0.2.18 版本的代码, 因为这是开始实验时的最新版本。
## NAS 结果对比 NAS 结果对比
---------------
.. list-table::
:header-rows: 1
:widths: auto
* - NAS
- AutoKeras (%)
- ENAS (macro) (%)
- ENAS (micro) (%)
- DARTS (%)
- NAO-WS (%)
* - Fashion-MNIST
- 91.84
- 95.44
- 95.53
- **95.74**
- 95.20
* - CIFAR-10
- 75.78
- 95.68
- **96.16**
- 94.23
- 95.64
* - CIFAR-100
- 43.61
- 78.13
- 78.84
- **79.74**
- 75.75
* - OUI-Adience-Age
- 63.20
- **80.34**
- 78.55
- 76.83
- 72.96
* - ImageNet-10-1
- 61.80
- 77.07
- 79.80
- **80.48**
- 77.20
* - ImageNet-10-2
- 37.20
- 58.13
- 56.47
- 60.53
- **61.20**
| NAS | AutoKeras (%) | ENAS (macro) (%) | ENAS (micro) (%) | DARTS (%) | NAO-WS (%) |
| --------------- |:-------------:|:----------------:|:----------------:|:---------:|:----------:|
| Fashion-MNIST | 91.84 | 95.44 | 95.53 | **95.74** | 95.20 |
| CIFAR-10 | 75.78 | 95.68 | **96.16** | 94.23 | 95.64 |
| CIFAR-100 | 43.61 | 78.13 | 78.84 | **79.74** | 75.75 |
| OUI-Adience-Age | 63.20 | **80.34** | 78.55 | 76.83 | 72.96 |
| ImageNet-10-1 | 61.80 | 77.07 | 79.80 | **80.48** | 77.20 |
| ImageNet-10-2 | 37.20 | 58.13 | 56.47 | 60.53 | **61.20** |
很遗憾,我们无法复现论文中所有的结果。 很遗憾,我们无法复现论文中所有的结果。
论文中提供的最佳或平均结果: 论文中提供的最佳或平均结果:
| NAS | AutoKeras(%) | ENAS (macro) (%) | ENAS (micro) (%) | DARTS (%) | NAO-WS (%) | .. list-table::
| --------- | ------------ |:----------------:|:----------------:|:--------------:|:-----------:| :header-rows: 1
| CIFAR- 10 | 88.56(best) | 96.13(best) | 97.11(best) | 97.17(average) | 96.47(best) | :widths: auto
对于 AutoKeras,由于其算法中的随机因素,它在所有数据集中的表现相对较差。 * - NAS
- AutoKeras(%)
- ENAS (macro) (%)
- ENAS (micro) (%)
- DARTS (%)
- NAO-WS (%)
* - CIFAR- 10
- 88.56(best)
- 96.13(best)
- 97.11(best)
- 97.17(average)
- 96.47(best)
AutoKeras,由于其算法中的随机因素,它在所有数据集中的表现相对较差。
对于 ENAS,ENAS(macro)在 OUI-Adience-Age 数据集中表现较好,并且 ENAS(micro)在 CIFAR-10 数据集中表现较好。 对于 ENAS,ENAS(macro)在 OUI-Adience-Age 数据集中表现较好,并且 ENAS(micro)在 CIFAR-10 数据集中表现较好。
...@@ -63,12 +148,18 @@ NAO 需要太多的计算资源,因此只使用提供 Pipeline 脚本的 NAO-W ...@@ -63,12 +148,18 @@ NAO 需要太多的计算资源,因此只使用提供 Pipeline 脚本的 NAO-W
NAO-WS 在 ImageNet-10-2 中表现良好,但在 OUI-Adience-Age 中表现非常差。 NAO-WS 在 ImageNet-10-2 中表现良好,但在 OUI-Adience-Age 中表现非常差。
## 参考 参考
---------
1. Jin, Haifeng, Qingquan Song, and Xia Hu. "Efficient neural architecture search with network morphism." *arXiv preprint arXiv:1806.10282* (2018). #.
Jin, Haifeng, Qingquan Song, and Xia Hu. "Efficient neural architecture search with network morphism." *arXiv preprint arXiv:1806.10282* (2018).
2. Liu, Hanxiao, Karen Simonyan, and Yiming Yang. "Darts: Differentiable architecture search." arXiv preprint arXiv:1806.09055 (2018). #.
Liu, Hanxiao, Karen Simonyan, and Yiming Yang. "Darts: Differentiable architecture search." arXiv preprint arXiv:1806.09055 (2018).
3. Pham, Hieu, et al. "Efficient Neural Architecture Search via Parameters Sharing." international conference on machine learning (2018): 4092-4101. #.
Pham, Hieu, et al. "Efficient Neural Architecture Search via Parameters Sharing." international conference on machine learning (2018): 4092-4101.
4. Luo, Renqian, et al. "Neural Architecture Optimization." neural information processing systems (2018): 7827-7838. #.
Luo, Renqian, et al. "Neural Architecture Optimization." neural information processing systems (2018): 7827-7838.
# 并行化顺序算法:TPE .. role:: raw-html(raw)
:format: html
并行化顺序算法:TPE
========================================
为了利用多个计算节点,TPE 方法是异步运行的,这样能避免浪费时间等待 Trial 评估的完成。 TPE 方法使用了叫做 constant liar 的方法:每次候选点 x* 生成时,会临时分配一个假的评估结果 y。在评估完成后,用返回的真实损失值 f(x*) 来替换假的评估结果。 为了利用多个计算节点,TPE 方法是异步运行的,这样能避免浪费时间等待 Trial 评估的完成。 TPE 方法使用了叫做 constant liar 的方法:每次候选点 x* 生成时,会临时分配一个假的评估结果 y。在评估完成后,用返回的真实损失值 f(x*) 来替换假的评估结果。
## 介绍和问题 介绍和问题
-------------------------
### 基于顺序模型的全局优化 基于顺序模型的全局优化
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
基于顺序模型的全局优化(SMBO)算法已经用于许多应用中,但适应度函数的评估成本比较高。 在应用中,真实的适应度函数 f: X → R 评估成本较高,通过采用基于模型算法近似的 f 来替代,可降低其评估成本。 通常,在 SMBO 算法内层循环是用数值优化或其它转换方式来替代。 点 x* 最大化的替代项(或它的转换形式)作为真实函数 f 评估的替代值。 这种类似于主动学习的算法模板总结如下。 SMBO 算法的不同之处在于,给定一个 f 的模型(或替代项)的情况下,获得 x* 的优化的标准,以及通过观察历史 H 来模拟 f。 基于顺序模型的全局优化(SMBO)算法已经用于许多应用中,但适应度函数的评估成本比较高。 在应用中,真实的适应度函数 f: X → R 评估成本较高,通过采用基于模型算法近似的 f 来替代,可降低其评估成本。 通常,在 SMBO 算法内层循环是用数值优化或其它转换方式来替代。 点 x* 最大化的替代项(或它的转换形式)作为真实函数 f 评估的替代值。 这种类似于主动学习的算法模板总结如下。 SMBO 算法的不同之处在于,给定一个 f 的模型(或替代项)的情况下,获得 x* 的优化的标准,以及通过观察历史 H 来模拟 f。
![](../../img/parallel_tpe_search4.PNG)
.. image:: ../../img/parallel_tpe_search4.PNG
:target: ../../img/parallel_tpe_search4.PNG
:alt:
本算法优化了预期改进(Expected Improvement,EI)的标准。 其它建议的标准包括,概率改进(Probability of Improvement)、预期改进(Expected Improvement)最小化条件熵(minimizing the Conditional Entropy of the Minimizer)、以及 bandit-based 的标准。 在 TPE 中考虑到直观,选择了 EI,其在多种设置下都展示了较好的效果。 预期改进(EI)是在模型 M 下,当 f(x) (负向)超过某个阈值 y* 时,对 f 的预期:X → RN。 本算法优化了预期改进(Expected Improvement,EI)的标准。 其它建议的标准包括,概率改进(Probability of Improvement)、预期改进(Expected Improvement)最小化条件熵(minimizing the Conditional Entropy of the Minimizer)、以及 bandit-based 的标准。 在 TPE 中考虑到直观,选择了 EI,其在多种设置下都展示了较好的效果。 预期改进(EI)是在模型 M 下,当 f(x) (负向)超过某个阈值 y* 时,对 f 的预期:X → RN。
![](../../img/parallel_tpe_search_ei.PNG)
.. image:: ../../img/parallel_tpe_search_ei.PNG
:target: ../../img/parallel_tpe_search_ei.PNG
:alt:
由于 p(y|x) 计算成本较高,TPE 通过 p(x|y) 和 p(y) 来为 p(y|x) 建模。TPE 通过下列两个密度来定义 p(x|y): 由于 p(y|x) 计算成本较高,TPE 通过 p(x|y) 和 p(y) 来为 p(y|x) 建模。TPE 通过下列两个密度来定义 p(x|y):
![](../../img/parallel_tpe_search_tpe.PNG)
l(x) 是通过观察 {x(i)} 来形成的密度,使得相应的损失 f(x(i)) 小于 y∗,而 g(x) 是使用剩余的观测值来形成的密度。 TPE 算法取决于 y∗ 大于观测到的最好的 f(x),这样可以使用一些点来形成 l(x)。 TPE 算法选择了 y* 来作为一些观测值 y 的分位数 γ,因此 p(y<`y∗`) = γ,但不需要为特定的 p(y) 建模。 l 和 g 的树形结构使得根据 l 来计算多个候选项变得容易,可根据 g(x)/l(x) 来进行评估。 在每次迭代中,算法返回了具有最大 EI 的候选 x* .. image:: ../../img/parallel_tpe_search_tpe.PNG
:target: ../../img/parallel_tpe_search_tpe.PNG
:alt:
l(x) 是通过观察 {x(i)} 来形成的密度,使得相应的损失 f(x(i)) 小于 y∗,
而 g(x) 是使用剩余的观测值来形成的密度。 TPE 算法取决于 y∗ 大于观测到的最好的 f(x),这样可以使用一些点来形成 l(x)。 TPE 算法选择了 y* 来作为一些观测值 y 的分位数 γ,因此 p(y<\ ``y∗``\ ) = γ,但不需要为特定的 p(y) 建模。 l 和 g 的树形结构使得根据 l 来计算多个候选项变得容易,可根据 g(x)/l(x) 来进行评估。 在每次迭代中,算法返回了具有最大 EI 的候选 x*。
这是 TPE 算法在二维搜索空间上的模拟。 不同的背景色表示了不同的值。 可以看出,TPE 在探索(exploration)和挖掘(exploitation)方面的表现都很好。 (黑色表示此轮样本的点,黄色表示历史点。) 这是 TPE 算法在二维搜索空间上的模拟。 不同的背景色表示了不同的值。 可以看出,TPE 在探索(exploration)和挖掘(exploitation)方面的表现都很好。 (黑色表示此轮样本的点,黄色表示历史点。)
![](../../img/parallel_tpe_search1.gif)
.. image:: ../../img/parallel_tpe_search1.gif
:target: ../../img/parallel_tpe_search1.gif
:alt:
**由于 EI 是连续函数,因此 EI 的最高 x 在某个状态下是确定的 。** 如下图所示,蓝色三角形表示在当前状态下最有可能进行采样的点。 **由于 EI 是连续函数,因此 EI 的最高 x 在某个状态下是确定的 。** 如下图所示,蓝色三角形表示在当前状态下最有可能进行采样的点。
![](../../img/parallel_tpe_search_ei2.PNG)
TPE 在顺序执行时表现很好,但当并发性较大时,会**在相同的 EI 状态下产生大量的点**,过于集中的点会减少 Tuner 探索的能力,造成了资源的浪费。 .. image:: ../../img/parallel_tpe_search_ei2.PNG
:target: ../../img/parallel_tpe_search_ei2.PNG
:alt:
TPE 在顺序执行时表现很好,但当并发性较大时,会 **在相同的 EI 状态下产生大量的点**,过于集中的点会减少 Tuner 探索的能力,造成了资源的浪费。
这是当 ``concurrency=60`` 时的模拟图,这种现象非常明显。
这是当 `concurrency=60` 时的模拟图,这种现象非常明显。
![](../../img/parallel_tpe_search2.gif) .. image:: ../../img/parallel_tpe_search2.gif
:target: ../../img/parallel_tpe_search2.gif
:alt:
## 研究的解决方案
### 近似 q-EI 最大化 研究的解决方案
-----------------
近似 q-EI 最大化
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
下面介绍的多点标准的新的 Experiment 设计一步解决此优化问题。 下面介绍的多点标准的新的 Experiment 设计一步解决此优化问题。
![](../../img/parallel_tpe_search_qEI.PNG)
.. image:: ../../img/parallel_tpe_search_qEI.PNG
:target: ../../img/parallel_tpe_search_qEI.PNG
:alt:
但是,当 q 增加时,q-EI 的计算变得很密集。 研究发现,四种流行的贪心策略可在解决此问题时,减少计算成本。 但是,当 q 增加时,q-EI 的计算变得很密集。 研究发现,四种流行的贪心策略可在解决此问题时,减少计算成本。
#### 方案 1: Believing the OK Predictor: KB(Kriging Believer) 启发式策略 方案 1: Believing the OK Predictor: KB(Kriging Believer) 启发式策略
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Kriging Believer 策略用等价于 Kriging 预测期望值的确定性值替换在最后一次迭代中选择的位置的响应的条件知识。 保持与上次相同的记号,此策略可归纳如下: Kriging Believer 策略用等价于 Kriging 预测期望值的确定性值替换在最后一次迭代中选择的位置的响应的条件知识。 保持与上次相同的记号,此策略可归纳如下:
![](../../img/parallel_tpe_search_kb.PNG)
.. image:: ../../img/parallel_tpe_search_kb.PNG
:target: ../../img/parallel_tpe_search_kb.PNG
:alt:
这种顺序策略使用了 q-points 设计,在计算量上是可承受的,因为它依赖于分析已知的 EI,在 d 维上进行了优化。 但此方法有失败的风险,因为相信 OK Predictor 可以预测超过观察到的数据,可能导致多轮迭代中的序列会陷入非最优区域。 第二种策略可降低这种风险。 这种顺序策略使用了 q-points 设计,在计算量上是可承受的,因为它依赖于分析已知的 EI,在 d 维上进行了优化。 但此方法有失败的风险,因为相信 OK Predictor 可以预测超过观察到的数据,可能导致多轮迭代中的序列会陷入非最优区域。 第二种策略可降低这种风险。
#### 方案 2: CL(Constant Liar) 启发式策略 方案 2: CL(Constant Liar) 启发式策略
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
考虑一种顺序策略,在每次迭代时会更新元模型(但不会重新估计超参),其中值 L 来自外部固定值,称为”lie(谎言)”。 Constant Liar 策略在每次迭代时使用相同的值 L:最大化 EI(即找到 xn+1),将模型实现为 y(xn+1) = L, 始终使用 L∈R:
考虑一种顺序策略,在每次迭代时会更新元模型(但不会重新估计超参),其中值 L 来自外部固定值,称为”lie(谎言)”。 Constant Liar 策略在每次迭代时使用相同的值 L:最大化 EI(即找到 xn+1),将模型实现为 y(xn+1) = L,始终使用 L∈R: .. image:: ../../img/parallel_tpe_search_cl.PNG
:target: ../../img/parallel_tpe_search_cl.PNG
:alt:
![](../../img/parallel_tpe_search_cl.PNG)
L 应在逻辑上根据 y 在 X 处获取的值来确定,可考虑使用的三个值:min{Y}, mean{Y}, 以及 max{Y}。 **L 越大,算法的探索性就越大,反之亦然。** L 应在逻辑上根据 y 在 X 处获取的值来确定,可考虑使用的三个值:min{Y}, mean{Y}, 以及 max{Y}。 **L 越大,算法的探索性就越大,反之亦然。**
根据上述方法进行模拟。 下图显示了使用均值 liar,来最大化 q-EI。 能看到这些点开始分散了。 根据上述方法进行模拟。 下图显示了使用均值 liar,来最大化 q-EI。 能看到这些点开始分散了。
![](../../img/parallel_tpe_search3.gif)
## Experiment .. image:: ../../img/parallel_tpe_search3.gif
:target: ../../img/parallel_tpe_search3.gif
:alt:
### Branin-Hoo
实验
----------
Branin-Hoo
^^^^^^^^^^
最后一章介绍的四种优化方法通过 Branin-Hoo 函数进行了比较,这是全局优化中的经典测试用例。 最后一章介绍的四种优化方法通过 Branin-Hoo 函数进行了比较,这是全局优化中的经典测试用例。
![](../../img/parallel_tpe_search_branin.PNG)
.. image:: ../../img/parallel_tpe_search_branin.PNG
:target: ../../img/parallel_tpe_search_branin.PNG
:alt:
a, b, c, r, s 以及 t 的推荐值分别为:a = 1, b = 5.1 ⁄ (4π2), c = 5 ⁄ π, r = 6, s = 10, t = 1 ⁄ (8π)。 此函数有三个全局最小值点 (-3.14, 12.27), (3.14, 2.27), (9.42, 2.47)。 a, b, c, r, s 以及 t 的推荐值分别为:a = 1, b = 5.1 ⁄ (4π2), c = 5 ⁄ π, r = 6, s = 10, t = 1 ⁄ (8π)。 此函数有三个全局最小值点 (-3.14, 12.27), (3.14, 2.27), (9.42, 2.47)。
下表为给定 constant liar 策略(最小、最大值)下,比较了前 q 个点(q ∈ [1,10])。每个 q 绘制 2000 个 q 点,这 2000 个 q 点随机采用 LHS。 下表为给定 constant liar 策略(最小、最大值)下,比较了前 q 个点(q ∈ [1,10])。每个 q 绘制 2000 个 q 点,这 2000 个 q 点随机采用 LHS。
![](../../img/parallel_tpe_search_result.PNG)
.. image:: ../../img/parallel_tpe_search_result.PNG
:target: ../../img/parallel_tpe_search_result.PNG
:alt:
正如图中所见,,CL[max] 和 CL[min] 与随机相比,产生了更好的 q-EI 结果,尤其是 q 值很小时。 正如图中所见,,CL[max] 和 CL[min] 与随机相比,产生了更好的 q-EI 结果,尤其是 q 值很小时。
### 高斯混合模型函数(Gaussian Mixed Model function) 高斯混合模型函数(Gaussian Mixed Model function)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
以下比较了使用和不使用并行优化的情况。 二维多模的高斯混合分布的模拟结果如下: 以下比较了使用和不使用并行优化的情况。 二维多模的高斯混合分布的模拟结果如下:
| | concurrency=80 | concurrency=60 | concurrency=40 | concurrency=20 | concurrency=10 | .. list-table::
| ------- | ---------------------------- | ---------------------------- | ---------------------------- | ---------------------------- | ---------------------------- | :header-rows: 1
| 未使用并行优化 | avg = 0.4841 :widths: auto
var = 0.1953 | avg = 0.5155
var = 0.2219 | avg = 0.5773 * -
var = 0.2570 | avg = 0.4680 - concurrency=80
var = 0.1994 | avg = 0.2774 - concurrency=60
var = 0.1217 | - concurrency=40
| 使用了并行优化 | avg = 0.2132 - concurrency=20
var = 0.0700 | avg = 0.2177 - concurrency=10
var = 0.0796 | avg = 0.1835 * - 未使用并行优化
var = 0.0533 | avg = 0.1671 - avg = 0.4841 :raw-html:`<br>` var = 0.1953
var = 0.0413 | avg = 0.1918 - avg = 0.5155 :raw-html:`<br>` var = 0.2219
var = 0.0697 | - avg = 0.5773 :raw-html:`<br>` var = 0.2570
- avg = 0.4680 :raw-html:`<br>` var = 0.1994
- avg = 0.2774 :raw-html:`<br>` var = 0.1217
* - 未使用并行优化
- avg = 0.2132 :raw-html:`<br>` var = 0.0700
- avg = 0.2177\ :raw-html:`<br>`\ var = 0.0796
- avg = 0.1835 :raw-html:`<br>` var = 0.0533
- avg = 0.1671 :raw-html:`<br>` var = 0.0413
- avg = 0.1918 :raw-html:`<br>` var = 0.0697
注意:每次测试的样本总数为 240(确保成本相等)。 每种形式下的 Trial 重复了 1000 次,表中值为 1000 个 Trial 中最好结果的平均值和方差。 注意:每次测试的样本总数为 240(确保成本相等)。 每种形式下的 Trial 重复了 1000 次,表中值为 1000 个 Trial 中最好结果的平均值和方差。
## 参考 参考
----------
[1] James Bergstra, Remi Bardenet, Yoshua Bengio, Balazs Kegl. "Algorithms for Hyper-Parameter Optimization". [链接](https://papers.nips.cc/paper/4443-algorithms-for-hyper-parameter-optimization.pdf) [1] James Bergstra, Remi Bardenet, Yoshua Bengio, Balazs Kegl. "Algorithms for Hyper-Parameter Optimization". `链接 <https://papers.nips.cc/paper/4443-algorithms-for-hyper-parameter-optimization.pdf>`__
[2] Meng-Hiot Lim, Yew-Soon Ong. "Computational Intelligence in Expensive Optimization Problems". [链接](https://link.springer.com/content/pdf/10.1007%2F978-3-642-10701-6.pdf) [2] Meng-Hiot Lim, Yew-Soon Ong. "Computational Intelligence in Expensive Optimization Problems". `链接 <https://link.springer.com/content/pdf/10.1007%2F978-3-642-10701-6.pdf>`__
[3] M. Jordan, J. Kleinberg, B. Scho¨lkopf. "Pattern Recognition and Machine Learning". [链接](http://users.isr.ist.utl.pt/~wurmd/Livros/school/Bishop%20-%20Pattern%20Recognition%20And%20Machine%20Learning%20-%20Springer%20%202006.pdf) [3] M. Jordan, J. Kleinberg, B. Scho¨lkopf. "Pattern Recognition and Machine Learning". `链接 <http://users.isr.ist.utl.pt/~wurmd/Livros/school/Bishop%20-%20Pattern%20Recognition%20And%20Machine%20Learning%20-%20Springer%20%202006.pdf>`__
\ No newline at end of file
# 自动调优 SVD(在推荐系统中使用 NNI)
本教程中,会首先介绍 GitHub 存储库:[Recommenders](https://github.com/Microsoft/Recommenders)。 它使用 Jupyter Notebook 提供了构建推荐系统的一些示例和实践技巧。 其中大量的模型被广泛的应用于推荐系统中。 为了提供完整的体验,每个示例都通过以下五个关键任务中展示:
- [准备数据](https://github.com/Microsoft/Recommenders/blob/master/notebooks/01_prepare_data/README.md):为每个 Recommender 算法准备并读取数据。
- [模型](https://github.com/Microsoft/Recommenders/blob/master/notebooks/02_model/README.md):使用各种经典的以及深度学习推荐算法,如交替最小二乘法([ALS](https://spark.apache.org/docs/latest/api/python/_modules/pyspark/ml/recommendation.html#ALS))或极限深度分解机([xDeepFM](https://arxiv.org/abs/1803.05170))。
- [评估](https://github.com/Microsoft/Recommenders/blob/master/notebooks/03_evaluate/README.md):使用离线指标来评估算法。
- [模型选择和优化](https://github.com/Microsoft/Recommenders/blob/master/notebooks/04_model_select_and_optimize/README.md):为推荐算法模型调优超参。
- [运营](https://github.com/Microsoft/Recommenders/blob/master/notebooks/05_operationalize/README.md):在 Azure 的生产环境上运行模型。
在第四项调优模型超参的任务上,NNI 可以发挥作用。 在 NNI 上调优推荐模型的具体示例,采用了 [SVD](https://github.com/Microsoft/Recommenders/blob/master/notebooks/02_model/surprise_svd_deep_dive.ipynb) 算法,以及数据集 Movielens100k。 此模型有超过 10 个超参需要调优。
由 Recommenders 提供的[ Jupyter notebook](https://github.com/Microsoft/Recommenders/blob/master/notebooks/04_model_select_and_optimize/nni_surprise_svd.ipynb) 中有非常详细的一步步的教程。 其中使用了不同的调优函数,包括 `Annealing``SMAC``Random Search``TPE``Hyperband``Metis` 以及 `Evolution`。 最后比较了不同调优算法的结果。 请参考此 Notebook,来学习如何使用 NNI 调优 SVD 模型,并可以继续使用 NNI 来调优 Recommenders 中的其它模型。
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment