Skip to content

Commit

Permalink
Merge pull request #109 from microsoft/master
Browse files Browse the repository at this point in the history
pull
  • Loading branch information
chicm-ms authored Aug 12, 2020
2 parents 13c6623 + f6991e8 commit b50b41e
Show file tree
Hide file tree
Showing 91 changed files with 7,121 additions and 894 deletions.
10 changes: 7 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
set -e
sudo apt-get install -y pandoc
python3 -m pip install torch==1.5.0+cpu torchvision==0.6.0+cpu -f https://download.pytorch.org/whl/torch_stable.html --user
python3 -m pip install tensorboardX==1.9
python3 -m pip install tensorflow==2.2.0 --user
python3 -m pip install keras==2.4.2 --user
python3 -m pip install gym onnx peewee thop --user
Expand All @@ -49,9 +50,9 @@ jobs:
sphinx-build -M html . _build -W
displayName: 'Sphinx Documentation Build check'
- job: 'ubuntu_1604_python35_legacy_torch_tf'
- job: 'ubuntu_1804_python36_legacy_torch_tf'
pool:
vmImage: 'Ubuntu 16.04'
vmImage: 'Ubuntu 18.04'

steps:
- script: |
Expand All @@ -68,6 +69,7 @@ jobs:
- script: |
set -e
python3 -m pip install torch==1.3.1+cpu torchvision==0.4.2+cpu -f https://download.pytorch.org/whl/torch_stable.html --user
python3 -m pip install tensorboardX==1.9
python3 -m pip install tensorflow==1.15.2 --user
python3 -m pip install keras==2.1.6 --user
python3 -m pip install gym onnx peewee --user
Expand Down Expand Up @@ -117,6 +119,7 @@ jobs:
set -e
# pytorch Mac binary does not support CUDA, default is cpu version
python3 -m pip install torchvision==0.6.0 torch==1.5.0 --user
python3 -m pip install tensorboardX==1.9
python3 -m pip install tensorflow==1.15.2 --user
brew install swig@3
rm -f /usr/local/bin/swig
Expand All @@ -141,9 +144,10 @@ jobs:
powershell.exe -file install.ps1
displayName: 'Install nni toolkit via source code'
- script: |
python -m pip install scikit-learn==0.20.0 --user
python -m pip install scikit-learn==0.23.2 --user
python -m pip install keras==2.1.6 --user
python -m pip install torch==1.5.0+cpu torchvision==0.6.0+cpu -f https://download.pytorch.org/whl/torch_stable.html --user
python -m pip install tensorboardX==1.9
python -m pip install tensorflow==1.15.2 --user
displayName: 'Install dependencies'
- script: |
Expand Down
17 changes: 9 additions & 8 deletions deployment/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

FROM nvidia/cuda:9.0-cudnn7-runtime-ubuntu16.04
FROM nvidia/cuda:9.2-cudnn7-runtime-ubuntu18.04

LABEL maintainer='Microsoft NNI Team<nni@microsoft.com>'

RUN DEBIAN_FRONTEND=noninteractive && \
apt-get -y update && \
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get -y update && \
apt-get -y install sudo \
apt-utils \
git \
Expand All @@ -21,7 +22,7 @@ RUN DEBIAN_FRONTEND=noninteractive && \
openssh-client \
openssh-server \
lsof \
python3.5 \
python3.6 \
python3-dev \
python3-pip \
python3-tk \
Expand All @@ -37,7 +38,7 @@ RUN cp /usr/bin/python3 /usr/bin/python
#
# update pip
#
RUN python3 -m pip install --upgrade pip setuptools==39.1.0
RUN python3 -m pip install --upgrade pip==20.0.2 setuptools==39.1.0

# numpy 1.14.3 scipy 1.1.0
RUN python3 -m pip --no-cache-dir install \
Expand All @@ -46,7 +47,7 @@ RUN python3 -m pip --no-cache-dir install \
#
# Tensorflow 1.15
#
RUN python3 -m pip --no-cache-dir install tensorflow-gpu==1.15
RUN python3 -m pip --no-cache-dir install tensorflow-gpu==1.15.0

#
# Keras 2.1.6
Expand All @@ -60,9 +61,9 @@ RUN python3 -m pip --no-cache-dir install torch==1.4.0
RUN python3 -m pip install torchvision==0.5.0

#
# sklearn 0.20.0
# sklearn 0.23.2
#
RUN python3 -m pip --no-cache-dir install scikit-learn==0.20.0
RUN python3 -m pip --no-cache-dir install scikit-learn==0.23.2

#
# pandas==0.23.4 lightgbm==2.2.2
Expand Down
2 changes: 1 addition & 1 deletion deployment/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ scipy 1.1.0
tensorflow-gpu 1.15.0
keras 2.1.6
torch 1.4.0
scikit-learn 0.20.0
scikit-learn 0.23.2
pandas 0.23.4
lightgbm 2.2.2
nni
Expand Down
2 changes: 1 addition & 1 deletion deployment/docker/README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@

使用下列命令从 docker Hub 中拉取 NNI docker 映像。

docker pull msranni/nni:latest
docker pull msranni/nni:latest
2 changes: 1 addition & 1 deletion deployment/pypi/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
'scipy',
'coverage',
'colorama',
'scikit-learn>=0.20,<0.22',
'scikit-learn>=0.23.2',
'pkginfo',
'websockets'
],
Expand Down
60 changes: 36 additions & 24 deletions docs/en_US/Compressor/Pruner.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ We provide several pruning algorithms that support fine-grained weight pruning a
* [NetAdapt Pruner](#netadapt-pruner)
* [SimulatedAnnealing Pruner](#simulatedannealing-pruner)
* [AutoCompress Pruner](#autocompress-pruner)
* [AutoML for Model Compression Pruner](#automl-for-model-compression-pruner)
* [Sensitivity Pruner](#sensitivity-pruner)

**Others**
Expand All @@ -38,7 +39,7 @@ Tensorflow code
```python
from nni.compression.tensorflow import LevelPruner
config_list = [{ 'sparsity': 0.8, 'op_types': ['default'] }]
pruner = LevelPruner(model_graph, config_list)
pruner = LevelPruner(model, config_list)
pruner.compress()
```

Expand Down Expand Up @@ -117,17 +118,6 @@ FPGMPruner prune filters with the smallest geometric median.
### Usage

Tensorflow code
```python
from nni.compression.tensorflow import FPGMPruner
config_list = [{
'sparsity': 0.5,
'op_types': ['Conv2D']
}]
pruner = FPGMPruner(model, config_list)
pruner.compress()
```

PyTorch code
```python
from nni.compression.torch import FPGMPruner
Expand All @@ -146,11 +136,6 @@ pruner.compress()
.. autoclass:: nni.compression.torch.FPGMPruner
```

##### Tensorflow
```eval_rst
.. autoclass:: nni.compression.tensorflow.FPGMPruner
```

## L1Filter Pruner

This is an one-shot pruner, In ['PRUNING FILTERS FOR EFFICIENT CONVNETS'](https://arxiv.org/abs/1608.08710), authors Hao Li, Asim Kadav, Igor Durdanovic, Hanan Samet and Hans Peter Graf.
Expand Down Expand Up @@ -383,12 +368,6 @@ You can view [example](https://github.com/microsoft/nni/blob/master/examples/mod
.. autoclass:: nni.compression.torch.AGPPruner
```

##### Tensorflow

```eval_rst
.. autoclass:: nni.compression.tensorflow.AGPPruner
```

***

## NetAdapt Pruner
Expand Down Expand Up @@ -498,6 +477,39 @@ You can view [example](https://github.com/microsoft/nni/blob/master/examples/mod
.. autoclass:: nni.compression.torch.AutoCompressPruner
```

## AutoML for Model Compression Pruner

AutoML for Model Compression Pruner (AMCPruner) leverages reinforcement learning to provide the model compression policy.
This learning-based compression policy outperforms conventional rule-based compression policy by having higher compression ratio,
better preserving the accuracy and freeing human labor.

![](../../img/amc_pruner.jpg)

For more details, please refer to [AMC: AutoML for Model Compression and Acceleration on Mobile Devices](https://arxiv.org/pdf/1802.03494.pdf).


#### Usage

PyTorch code

```python
from nni.compression.torch import AMCPruner
config_list = [{
'op_types': ['Conv2d', 'Linear']
}]
pruner = AMCPruner(model, config_list, evaluator, val_loader, flops_ratio=0.5)
pruner.compress()
```

You can view [example](https://github.com/microsoft/nni/blob/master/examples/model_compress/amc/) for more information.

#### User configuration for AutoCompress Pruner

##### PyTorch

```eval_rst
.. autoclass:: nni.compression.torch.AMCPruner
```

## ADMM Pruner
Alternating Direction Method of Multipliers (ADMM) is a mathematical optimization technique,
Expand Down Expand Up @@ -620,4 +632,4 @@ pruner.compress(eval_args=[model], finetune_args=[model])

```eval_rst
.. autoclass:: nni.compression.torch.SensitivityPruner
```
```
71 changes: 64 additions & 7 deletions docs/en_US/Tutorial/Nnictl.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ Debug mode will disable version check function in Trialkeeper.
|Name, shorthand|Required|Default|Description|
|------|------|------ |------|
|id| False| |ID of the experiment you want to set|
|--value, -v| True| |the experiment duration will be NUMBER seconds. SUFFIX may be 's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd' for days.|
|--value, -v| True| | Strings like '1m' for one minute or '2h' for two hours. SUFFIX may be 's' for seconds, 'm' for minutes, 'h' for hours or 'd' for days.|
* Example
Expand Down Expand Up @@ -305,19 +305,23 @@ Debug mode will disable version check function in Trialkeeper.

* Description

You can use this command to show trial's information.
You can use this command to show trial's information. Note that if `head` or `tail` is set, only complete trials will be listed.
* Usage
```bash
nnictl trial ls
nnictl trial ls --head 10
nnictl trial ls --tail 10
```
* Options
|Name, shorthand|Required|Default|Description|
|------|------|------ |------|
|id| False| |ID of the experiment you want to set|
|--head|False||the number of items to be listed with the highest default metric|
|--tail|False||the number of items to be listed with the lowest default metric|
* __nnictl trial kill__
Expand Down Expand Up @@ -444,9 +448,6 @@ Debug mode will disable version check function in Trialkeeper.
|--all| False| |delete all of experiments|
<a name="export"></a>
* __nnictl experiment export__
* Description
Expand All @@ -465,13 +466,14 @@ Debug mode will disable version check function in Trialkeeper.
|id| False| |ID of the experiment |
|--filename, -f| True| |File path of the output file |
|--type| True| |Type of output file, only support "csv" and "json"|
|--intermediate, -i|False||Are intermediate results included|
* Examples
> export all trial data in an experiment as json format
```bash
nnictl experiment export [experiment_id] --filename [file_path] --type json
nnictl experiment export [experiment_id] --filename [file_path] --type json --intermediate
```
* __nnictl experiment import__
Expand Down Expand Up @@ -531,6 +533,62 @@ Debug mode will disable version check function in Trialkeeper.
nnictl experiment import [experiment_id] -f experiment_data.json
```

* __nnictl experiment save__
* Description

Save nni experiment metadata and code data.

* Usage

```bash
nnictl experiment save [OPTIONS]
```

* Options

|Name, shorthand|Required|Default|Description|
|------|------|------ |------|
|id| True| |The id of the experiment you want to save|
|--path, -p| False| |the folder path to store nni experiment data, default current working directory|
|--saveCodeDir, -s| False| |save codeDir data of the experiment, default False|

* Examples

> save an expeirment

```bash
nnictl experiment save [experiment_id] --saveCodeDir
```

* __nnictl experiment load__
* Description

Load an nni experiment.

* Usage

```bash
nnictl experiment load [OPTIONS]
```

* Options

|Name, shorthand|Required|Default|Description|
|------|------|------ |------|
|--path, -p| True| |the file path of nni package|
|--codeDir, -c| True| |the path of codeDir for loaded experiment, this path will also put the code in the loaded experiment package|
|--logDir, -l| False| |the path of logDir for loaded experiment|

* Examples

> load an expeirment

```bash
nnictl experiment load --path [path] --codeDir [codeDir]
```



<a name="platform"></a>
### Manage platform information

Expand Down Expand Up @@ -850,4 +908,3 @@ Debug mode will disable version check function in Trialkeeper.
```bash
nnictl --version
```
1 change: 1 addition & 0 deletions docs/en_US/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import os
import sys
sys.path.insert(0, os.path.abspath('../../src/sdk/pynni'))
sys.path.insert(1, os.path.abspath('../../src/sdk/pycli'))


# -- Project information ---------------------------------------------------
Expand Down
Loading

0 comments on commit b50b41e

Please sign in to comment.