未验证 提交 4f1701b2 编写于 作者: W whs 提交者: GitHub

[cherry-pick-1.5]cherry-pick some commits to release/1.5 (#2869)

* Fix doc and train.py of icnet.

* Add usage for distribute Light-NAS searching.

* Refine usage doc of PaddleSlim.

* Use print instead of logger.

* Move light-nas-block.png to tutorial.

* Add Copyright for icnet.
上级 f605beed
...@@ -66,7 +66,7 @@ Iter[0]; train loss: 2.338; sub4_loss: 3.367; sub24_loss: 4.120; sub124_loss: 0. ...@@ -66,7 +66,7 @@ Iter[0]; train loss: 2.338; sub4_loss: 3.367; sub24_loss: 4.120; sub124_loss: 0.
### 测试 ### 测试
执行以下命令在`Cityscape`测试数据集上进行测试: 执行以下命令在`Cityscape`测试数据集上进行测试:
``` ```
python eval.py --model_path="./cnkpnt/100" --use_gpu=True python eval.py --model_path="./chkpnt/100" --use_gpu=True
``` ```
需要通过选项`--model_path`指定模型文件。 需要通过选项`--model_path`指定模型文件。
测试脚本的输出的评估指标为[mean IoU]()。 测试脚本的输出的评估指标为[mean IoU]()。
...@@ -75,7 +75,7 @@ python eval.py --model_path="./cnkpnt/100" --use_gpu=True ...@@ -75,7 +75,7 @@ python eval.py --model_path="./cnkpnt/100" --use_gpu=True
执行以下命令对指定的数据进行预测: 执行以下命令对指定的数据进行预测:
``` ```
python infer.py \ python infer.py \
--model_path="./cnkpnt/100" \ --model_path="./chkpnt/100" \
--images_path="./data/cityscape/" \ --images_path="./data/cityscape/" \
--images_list="./data/cityscape/infer.list" --images_list="./data/cityscape/infer.list"
``` ```
......
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve.
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
#################################################################
#
# Based on
#---------------------------------------------------------------
# https://github.com/hszhao/ICNet
# Written by hszhao@cse.cuhk.edu.hk
#---------------------------------------------------------------
from __future__ import absolute_import from __future__ import absolute_import
from __future__ import division from __future__ import division
from __future__ import print_function from __future__ import print_function
......
...@@ -35,9 +35,11 @@ LAMBDA2 = 0.4 ...@@ -35,9 +35,11 @@ LAMBDA2 = 0.4
LAMBDA3 = 1.0 LAMBDA3 = 1.0
LEARNING_RATE = 0.003 LEARNING_RATE = 0.003
POWER = 0.9 POWER = 0.9
LOG_PERIOD = 100 LOG_PERIOD = 1
CHECKPOINT_PERIOD = 100 CHECKPOINT_PERIOD = 1000
TOTAL_STEP = 100 TOTAL_STEP = 60000
if 'ce_mode' in os.environ:
TOTAL_STEP = 100
no_grad_set = [] no_grad_set = []
......
...@@ -155,7 +155,7 @@ def check_gpu(use_gpu): ...@@ -155,7 +155,7 @@ def check_gpu(use_gpu):
try: try:
if use_gpu and not fluid.is_compiled_with_cuda(): if use_gpu and not fluid.is_compiled_with_cuda():
logger.error(err) print(err)
sys.exit(1) sys.exit(1)
except Exception as e: except Exception as e:
pass pass
...@@ -205,6 +205,13 @@ compress_pass: ...@@ -205,6 +205,13 @@ compress_pass:
- pruning_strategy_1 - pruning_strategy_1
``` ```
compress_pass下可配置的参数有:
- **epoch**: 整个压缩任务执行的epoch数量。
- **init_model**: 初始化模型路径。在裁剪策略中,会根据`init_model``parameter``shape`对当前网络进行裁剪。
- **checkpoint_path**: 保存`checkpoint`的路径, checkpoint中包含了模型训练信息和策略执行信息。在重启任务时,会自动从`checkpoint`路径下加载最新的`checkpoint`,所以用户需要根据自己的需求决定是否修改`checkpoint`
- **strategies**: 在当前压缩任务中依次生效的策略。
## 2. 模型压缩策略使用介绍 ## 2. 模型压缩策略使用介绍
...@@ -598,3 +605,21 @@ controllers: ...@@ -598,3 +605,21 @@ controllers:
- **reduce_rate:** float类型;温度的衰减率。 - **reduce_rate:** float类型;温度的衰减率。
- **init_temperature:** float类型;初始化温度。 - **init_temperature:** float类型;初始化温度。
- **max_iter_number:** int类型;在得到一个满足FLOPS限制的tokens之前,最多尝试的次数。 - **max_iter_number:** int类型;在得到一个满足FLOPS限制的tokens之前,最多尝试的次数。
#### 2.4.3 分布式搜索
单机多任务:
单机多任务是指在一个机器上启动一个controller server和多个client, client从controller获取tokens, 根据tokens组建网络并训练评估,最后返回reward给controller server.
在Compressor::run()执行时,会首先判断配置文件中的`is_server`是否为`True`, 然后做如下操作:
- True: 判断当前路径下是否存在`slim_LightNASStrategy_controller_server.socket`文件,如果存在,则仅启动一个client,如果不存在,则启动一个controller server和一个client.
- False: 仅启动一个client
多机搜索:
多机搜索是指在一个机器上启动一个controller server,在多台机器上启动若干client。在启动controller server的机器上的配置文件里的is_server要设置为True。其它机器上的配置文件中的`is_server`要手动设置为False, 同时`server_ip``server_port`要设置为controller server对应的`ip``port`.
>注意: 在重启controller server时,lim_LightNASStrategy_controller_server.socke文件可能不会被及时清除,所以需要用户手动删除该文件。在后续版本中,会修复完善该问题。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册