Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
bb5daabe
Commit
bb5daabe
authored
Jun 04, 2019
by
Xiaohui Xue
Browse files
Merge remote-tracking branch 'upstream/master' into v0.8
parents
e9b80c88
4afe1670
Changes
31
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
54 additions
and
66 deletions
+54
-66
docs/zh_CN/Installation.md
docs/zh_CN/Installation.md
+6
-5
docs/zh_CN/NniOnWindows.md
docs/zh_CN/NniOnWindows.md
+3
-27
docs/zh_CN/QuickStart.md
docs/zh_CN/QuickStart.md
+1
-1
docs/zh_CN/SearchSpaceSpec.md
docs/zh_CN/SearchSpaceSpec.md
+17
-7
examples/trials/NAS/README_zh_CN.md
examples/trials/NAS/README_zh_CN.md
+8
-0
examples/trials/ga_squad/README_zh_CN.md
examples/trials/ga_squad/README_zh_CN.md
+1
-1
examples/trials/ga_squad/trial.py
examples/trials/ga_squad/trial.py
+1
-3
examples/trials/network_morphism/README_zh_CN.md
examples/trials/network_morphism/README_zh_CN.md
+2
-2
examples/trials/weight_sharing/ga_squad/data.py
examples/trials/weight_sharing/ga_squad/data.py
+1
-3
tools/nni_cmd/launcher.py
tools/nni_cmd/launcher.py
+11
-12
tools/nni_cmd/tensorboard_utils.py
tools/nni_cmd/tensorboard_utils.py
+3
-5
No files found.
docs/zh_CN/Installation.md
View file @
bb5daabe
...
...
@@ -17,7 +17,7 @@
先决条件:
`python >=3.5`
,
`git`
,
`wget`
```
bash
git clone
-b
v0.
7
https://github.com/Microsoft/nni.git
git clone
-b
v0.
8
https://github.com/Microsoft/nni.git
cd
nni
./install.sh
```
...
...
@@ -30,8 +30,9 @@
在第一次使用 PowerShell 运行脚本时,需要用
**使用管理员权限**
运行如下命令:
bash
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
```
powershell
Set-ExecutionPolicy
-ExecutionPolicy
Unrestricted
```
推荐使用 Anaconda 或 Miniconda。
...
...
@@ -50,9 +51,9 @@
然后可以使用管理员或当前用户安装 NNI:
```
bash
git clone
-b
v0.
7
https://github.com/Microsoft/nni.git
git clone
-b
v0.
8
https://github.com/Microsoft/nni.git
cd
nni
powershell .
/
install.ps1
powershell .
\
i
nstall.ps1
```
## **系统需求**
...
...
docs/zh_CN/NniOnWindows.md
View file @
bb5daabe
...
...
@@ -4,33 +4,9 @@
## **在 Windows 上安装**
**强烈推荐使用 Anaconda 或 Miniconda Python(64位)。**
详细信息参考
[
安装
](
Installation.md#installation-on-windows
)
。
在第一次使用 PowerShell 运行脚本时,需要用
**使用管理员权限**
运行如下命令:
```
bash
Set-ExecutionPolicy
-ExecutionPolicy
Unrestricted
```
*
**通过 pip 命令安装 NNI**
先决条件:
`python(64-bit) >= 3.5`
```
bash
python
-m
pip
install
--upgrade
nni
```
*
__通过代码安装 NNI__
先决条件:
`python >=3.5`
,
`git`
,
`PowerShell`
```
bash
git clone
-b
v0.8 https://github.com/Microsoft/nni.git
cd
nni
powershell
-file
install.ps1
```
运行完以上脚本后,从命令行使用
**config_windows.yml**
来启动 Experiment,完成安装验证。
完成操作后,使用
**config_windows.yml**
配置来开始 Experiment 进行验证。
```
bash
nnictl create
--config
nni
\e
xamples
\t
rials
\m
nist
\c
onfig_windows.yml
...
...
@@ -85,4 +61,4 @@ Set-ExecutionPolicy -ExecutionPolicy Unrestricted
注意:
*
如果遇到
`Segmentation fault`
这样的错误,参考
[
常见问答
](
FAQ.md
)
。
\ No newline at end of file
*
如果遇到如
`Segmentation fault`
这样的任何错误,参考
[
常见问题
](
FAQ.md
)
。
\ No newline at end of file
docs/zh_CN/QuickStart.md
View file @
bb5daabe
...
...
@@ -164,7 +164,7 @@ trial:
**注意**
:如果使用 Windows,则需要在 config.yml 文件中,将
`python3`
改为
`python`
,或者使用 config_windows.yml 来开始 Experiment。
```
bash
nnictl create
--config
nni
/
examples
/
trials
/
mnist
/
config_windows.yml
nnictl create
--config
nni
\
e
xamples
\
t
rials
\
m
nist
\
c
onfig_windows.yml
```
注意:
**nnictl**
是一个命令行工具,用来控制 NNI Experiment,如启动、停止、继续 Experiment,启动、停止 NNIBoard 等等。 查看
[
这里
](
Nnictl.md
)
,了解
`nnictl`
更多用法。
...
...
docs/zh_CN/SearchSpaceSpec.md
View file @
bb5daabe
...
...
@@ -29,16 +29,16 @@
*
表示变量的值是选项之一。 这里的 'options' 是一个数组。 选项的每个元素都是字符串。 也可以是嵌套的子搜索空间。此子搜索空间仅在相应的元素选中后才起作用。 该子搜索空间中的变量可看作是条件变量。
*
这是个简单的
[
nested] 搜索空间定义的[示例
](
https://github.com/microsoft/nni/tree/master/examples/trials/mnist-nested-search-space/search_space.json
)
。 如果选项列表中的元素是 dict,则它是一个子搜索空间,对于内置的 Tuner,必须在此 dict 中添加键 “_name”,这有助于标识选中的元素。 相应的,这是从 NNI
中
获得的嵌套搜索空间
定义
的
[
示例
](
https://github.com/microsoft/nni/tree/master/examples/trials/mnist-nested-search-space/sample.json
)
。 以下 Tuner 支持嵌套搜索空间:
*
[
nested] 搜索空间定义的
简单
[示例
](
https://github.com/microsoft/nni/tree/master/examples/trials/mnist-nested-search-space/search_space.json
)
。 如果选项列表中的元素是 dict,则它是一个子搜索空间,对于内置的 Tuner,必须在此 dict 中添加键 “_name”,这有助于标识选中的元素。 相应的,这是
使用
从 NNI 获得的嵌套搜索空间的
[
示例
](
https://github.com/microsoft/nni/tree/master/examples/trials/mnist-nested-search-space/sample.json
)
。 以下 Tuner 支持嵌套搜索空间:
*
Random Search(随机搜索)
*
TPE
*
Anneal(退火算法)
*
Evolution
*
{"_type":"randint","_value":[upper]}
*
{"_type":"randint","_value":[
lower,
upper]}
*
此变量为范围 [0, upper) 之间的随机整数。 这种分布的语义,在较远整数与附近整数之间的损失函数无太大关系, 这是用来描述随机种子的较好分布。 如果损失函数与较近的整数更相关,则应该使用某个"quantized"的连续分布,如quniform, qloguniform, qnormal 或 qlognormal。 注意,如果需要改动数字下限,可以使用
`quniform`
。
*
当前实现的是 "quniform" 的 "randint" 分布,随机变量的分布函数是 round(uniform(lower, upper))。 所选择值的类型是 float。 如果要使用整数,需要显式转换
。
*
{"_type":"uniform","_value":[low, high]}
...
...
@@ -92,9 +92,19 @@
| Hyperband Advisor |
✓
|
✓
|
✓
|
✓
|
✓
|
✓
|
✓
|
✓
|
✓
|
✓
|
| Metis Tuner |
✓
|
✓
|
✓
|
✓
| | | | | | |
注意,在 Grid Search Tuner 中,为了使用方便
`quniform`
和
`qloguniform`
的定义也有所改变,其中的 q 表示采样值的数量。 详情如下
:
已知的局限
:
*
类型 'quniform' 接收三个值 [low, high, q], 其中 [low, high] 指定了范围,而 'q' 指定了会被均匀采样的值的数量。 注意 q 至少为 2。 它的第一个采样值为 'low',每个采样值都会比前一个大 (high-low)/q 。
*
类型 'qloguniform' 的行为与 'quniform' 类似,不同处在于首先将范围改为 [log(low), log(high)] 采样后,再将数值还原。
*
注意,在 Grid Search Tuner 中,为了使用方便
`quniform`
和
`qloguniform`
的定义也有所改变,其中的 q 表示采样值的数量。 详情如下:
*
类型 'quniform' 接收三个值 [low, high, q], 其中 [low, high] 指定了范围,而 'q' 指定了会被均匀采样的值的数量。 注意 q 至少为 2。 它的第一个采样值为 'low',每个采样值都会比前一个大 (high-low)/q 。
*
类型 'qloguniform' 的行为与 'quniform' 类似,不同处在于首先将范围改为 [log(low), log(high)] 采样后,再将数值还原。
*
注意 Metis Tuner 当前仅支持在
`choice`
中使用数值。
注意 Metis Tuner 当前仅支持在
`choice`
中使用数值。
\ No newline at end of file
*
请注意,对于嵌套搜索空间:
*
只有 随机搜索/TPE/Anneal/Evolution Tuner 支持嵌套搜索空间
*
不支持嵌套搜索空间 "超参" 并行图,对其的改进通过 #1110(https://github.com/microsoft/nni/issues/1110) 来跟踪 。欢迎任何建议和贡献。
\ No newline at end of file
examples/trials/NAS/README_zh_CN.md
0 → 100644
View file @
bb5daabe
**在 NNI 中运行神经网络架构搜索**
===
参考
[
NNI-NAS-Example
](
https://github.com/Crysple/NNI-NAS-Example
)
,来使用贡献者提供的 NAS 接口。
谢谢可爱的贡献者!
欢迎越来越多的人加入我们!
\ No newline at end of file
examples/trials/ga_squad/README_zh_CN.md
View file @
bb5daabe
...
...
@@ -14,7 +14,7 @@
6.
ADD-SKIP (在随机层之间一致).
7.
REMOVE-SKIP (移除随机跳过).


## 新版本
...
...
examples/trials/ga_squad/trial.py
View file @
bb5daabe
...
...
@@ -79,9 +79,7 @@ def get_id(word_dict, word):
'''
Return word id.
'''
if
word
in
word_dict
.
keys
():
return
word_dict
[
word
]
return
word_dict
[
'<unk>'
]
return
word_dict
.
get
(
word
,
word_dict
[
'<unk>'
])
def
load_embedding
(
path
):
...
...
examples/trials/network_morphism/README_zh_CN.md
View file @
bb5daabe
...
...
@@ -99,10 +99,10 @@ nnictl create --config config.yml
`Fashion-MNIST`
是来自
[
Zalando
](
https://jobs.zalando.com/tech/
)
文章的图片 — 有 60,000 个样例的训练集和 10,000 个样例的测试集。 每个样例是 28x28 的灰度图,分为 10 个类别。 由于 MNIST 数据集过于简单,该数据集现在开始被广泛使用,用来替换 MNIST 作为基准数据集。
这里有两个样例,
[
FashionMNIST-keras.py
](
.
./../../../examples/trials/network_morphism
/FashionMNIST/FashionMNIST_keras.py
)
和
[
FashionMNIST-pytorch.py
](
.
./../../../examples/trials/network_morphism
/FashionMNIST/FashionMNIST_pytorch.py
)
。 注意,在
`config.yml`
中,需要为此数据集修改
`input_width`
为 28,以及
`input_channel`
为 1。
这里有两个样例,
[
FashionMNIST-keras.py
](
./FashionMNIST/FashionMNIST_keras.py
)
和
[
FashionMNIST-pytorch.py
](
./FashionMNIST/FashionMNIST_pytorch.py
)
。 注意,在
`config.yml`
中,需要为此数据集修改
`input_width`
为 28,以及
`input_channel`
为 1。
### Cifar10
`CIFAR-10`
数据集
[
Canadian Institute For Advanced Research
](
https://www.cifar.ca/
)
是广泛用于机器学习和视觉算法训练的数据集。 它是机器学习领域最广泛使用的数据集之一。 CIFAR-10 数据集包含了 60,000 张 32x32 的彩色图片,分为 10 类。
这里有两个样例,
[
cifar10-keras.py
](
../../../../examples/trials/network_morphism/cifar10/cifar10_keras.py
)
和
[
cifar10-pytorch.py
](
../../../../examples/trials/network_morphism/cifar10/cifar10_pytorch.py
)
。 在
`config.yml`
中,该数据集
`input_width`
的值是 32,并且
`input_channel`
是 3。
\ No newline at end of file
这里有两个样例,
[
cifar10-keras.py
](
./cifar10/cifar10_keras.py
)
和
[
cifar10-pytorch.py
](
./cifar10/cifar10_pytorch.py
)
。 在
`config.yml`
中,该数据集
`input_width`
的值是 32,并且
`input_channel`
是 3。
\ No newline at end of file
examples/trials/weight_sharing/ga_squad/data.py
View file @
bb5daabe
...
...
@@ -241,9 +241,7 @@ def get_id(word_dict, word):
'''
Given word, return word id.
'''
if
word
in
word_dict
.
keys
():
return
word_dict
[
word
]
return
word_dict
[
'<unk>'
]
return
word_dict
.
get
(
word
,
word_dict
[
'<unk>'
])
def
get_buckets
(
min_length
,
max_length
,
bucket_count
):
...
...
tools/nni_cmd/launcher.py
View file @
bb5daabe
...
...
@@ -125,18 +125,17 @@ def start_rest_server(port, platform, mode, config_file_name, experiment_id=None
if
mode
==
'resume'
:
cmds
+=
[
'--experiment_id'
,
experiment_id
]
stdout_full_path
,
stderr_full_path
=
get_log_path
(
config_file_name
)
stdout_file
=
open
(
stdout_full_path
,
'a+'
)
stderr_file
=
open
(
stderr_full_path
,
'a+'
)
time_now
=
time
.
strftime
(
'%Y-%m-%d %H:%M:%S'
,
time
.
localtime
(
time
.
time
()))
#add time information in the header of log files
log_header
=
LOG_HEADER
%
str
(
time_now
)
stdout_file
.
write
(
log_header
)
stderr_file
.
write
(
log_header
)
if
sys
.
platform
==
'win32'
:
from
subprocess
import
CREATE_NEW_PROCESS_GROUP
process
=
Popen
(
cmds
,
cwd
=
entry_dir
,
stdout
=
stdout_file
,
stderr
=
stderr_file
,
creationflags
=
CREATE_NEW_PROCESS_GROUP
)
else
:
process
=
Popen
(
cmds
,
cwd
=
entry_dir
,
stdout
=
stdout_file
,
stderr
=
stderr_file
)
with
open
(
stdout_full_path
,
'a+'
)
as
stdout_file
,
open
(
stderr_full_path
,
'a+'
)
as
stderr_file
:
time_now
=
time
.
strftime
(
'%Y-%m-%d %H:%M:%S'
,
time
.
localtime
(
time
.
time
()))
#add time information in the header of log files
log_header
=
LOG_HEADER
%
str
(
time_now
)
stdout_file
.
write
(
log_header
)
stderr_file
.
write
(
log_header
)
if
sys
.
platform
==
'win32'
:
from
subprocess
import
CREATE_NEW_PROCESS_GROUP
process
=
Popen
(
cmds
,
cwd
=
entry_dir
,
stdout
=
stdout_file
,
stderr
=
stderr_file
,
creationflags
=
CREATE_NEW_PROCESS_GROUP
)
else
:
process
=
Popen
(
cmds
,
cwd
=
entry_dir
,
stdout
=
stdout_file
,
stderr
=
stderr_file
)
return
process
,
str
(
time_now
)
def
set_trial_config
(
experiment_config
,
port
,
config_file_name
):
...
...
tools/nni_cmd/tensorboard_utils.py
View file @
bb5daabe
...
...
@@ -94,11 +94,9 @@ def start_tensorboard_process(args, nni_config, path_list, temp_nni_path):
if
detect_port
(
args
.
port
):
print_error
(
'Port %s is used by another process, please reset port!'
%
str
(
args
.
port
))
exit
(
1
)
stdout_file
=
open
(
os
.
path
.
join
(
temp_nni_path
,
'tensorboard_stdout'
),
'a+'
)
stderr_file
=
open
(
os
.
path
.
join
(
temp_nni_path
,
'tensorboard_stderr'
),
'a+'
)
cmds
=
[
'tensorboard'
,
'--logdir'
,
format_tensorboard_log_path
(
path_list
),
'--port'
,
str
(
args
.
port
)]
tensorboard_process
=
Popen
(
cmds
,
stdout
=
stdout_file
,
stderr
=
stderr_file
)
with
open
(
os
.
path
.
join
(
temp_nni_path
,
'tensorboard_stdout'
),
'a+'
)
as
stdout_file
,
open
(
os
.
path
.
join
(
temp_nni_path
,
'tensorboard_stderr'
),
'a+'
)
as
stderr_file
:
cmds
=
[
'tensorboard'
,
'--logdir'
,
format_tensorboard_log_path
(
path_list
),
'--port'
,
str
(
args
.
port
)]
tensorboard_process
=
Popen
(
cmds
,
stdout
=
stdout_file
,
stderr
=
stderr_file
)
url_list
=
get_local_urls
(
args
.
port
)
print_normal
(
COLOR_GREEN_FORMAT
%
'Start tensorboard success!
\n
'
+
'Tensorboard urls: '
+
' '
.
join
(
url_list
))
tensorboard_process_pid_list
=
nni_config
.
get_config
(
'tensorboardPidList'
)
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment