Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
5e363043
P
PaddleSlim
项目概览
PaddlePaddle
/
PaddleSlim
1 年多 前同步成功
通知
51
Star
1434
Fork
344
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
16
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSlim
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
16
合并请求
16
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
5e363043
编写于
6月 22, 2021
作者:
Z
zhouzj
提交者:
GitHub
6月 22, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
adjust batch size (#812)
上级
34d44715
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
9 addition
and
16 deletion
+9
-16
demo/distillation/distill.py
demo/distillation/distill.py
+8
-15
demo/dygraph/quant/train.py
demo/dygraph/quant/train.py
+1
-1
未找到文件。
demo/distillation/distill.py
浏览文件 @
5e363043
...
...
@@ -22,7 +22,7 @@ _logger.setLevel(logging.INFO)
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
add_arg
=
functools
.
partial
(
add_arguments
,
argparser
=
parser
)
# yapf: disable
add_arg
(
'batch_size'
,
int
,
64
,
"Minibatch size."
)
add_arg
(
'batch_size'
,
int
,
256
,
"Minibatch size."
)
add_arg
(
'use_gpu'
,
bool
,
True
,
"Whether to use GPU or not."
)
add_arg
(
'save_inference'
,
bool
,
False
,
"Whether to save inference model."
)
add_arg
(
'total_images'
,
int
,
1281167
,
"Training image number."
)
...
...
@@ -45,12 +45,7 @@ model_list = [m for m in dir(models) if "__" not in m]
def
piecewise_decay
(
args
):
if
args
.
use_gpu
:
devices_num
=
paddle
.
fluid
.
core
.
get_cuda_device_count
()
else
:
devices_num
=
int
(
os
.
environ
.
get
(
'CPU_NUM'
,
1
))
step
=
int
(
math
.
ceil
(
float
(
args
.
total_images
)
/
args
.
batch_size
)
/
devices_num
)
step
=
int
(
math
.
ceil
(
float
(
args
.
total_images
)
/
args
.
batch_size
))
bd
=
[
step
*
e
for
e
in
args
.
step_epochs
]
lr
=
[
args
.
lr
*
(
0.1
**
i
)
for
i
in
range
(
len
(
bd
)
+
1
)]
learning_rate
=
paddle
.
optimizer
.
lr
.
PiecewiseDecay
(
...
...
@@ -63,12 +58,7 @@ def piecewise_decay(args):
def
cosine_decay
(
args
):
if
args
.
use_gpu
:
devices_num
=
paddle
.
fluid
.
core
.
get_cuda_device_count
()
else
:
devices_num
=
int
(
os
.
environ
.
get
(
'CPU_NUM'
,
1
))
step
=
int
(
math
.
ceil
(
float
(
args
.
total_images
)
/
args
.
batch_size
)
/
devices_num
)
step
=
int
(
math
.
ceil
(
float
(
args
.
total_images
)
/
args
.
batch_size
))
learning_rate
=
paddle
.
optimizer
.
lr
.
CosineAnnealingDecay
(
learning_rate
=
args
.
lr
,
T_max
=
step
*
args
.
num_epochs
,
verbose
=
False
)
optimizer
=
paddle
.
optimizer
.
Momentum
(
...
...
@@ -108,7 +98,10 @@ def compress(args):
places
=
paddle
.
static
.
cuda_places
(
)
if
args
.
use_gpu
else
paddle
.
static
.
cpu_places
()
place
=
places
[
0
]
if
args
.
use_gpu
:
devices_num
=
paddle
.
fluid
.
core
.
get_cuda_device_count
()
else
:
devices_num
=
int
(
os
.
environ
.
get
(
'CPU_NUM'
,
1
))
with
paddle
.
static
.
program_guard
(
student_program
,
s_startup
):
with
paddle
.
fluid
.
unique_name
.
guard
():
image
=
paddle
.
static
.
data
(
...
...
@@ -120,7 +113,7 @@ def compress(args):
places
=
places
,
feed_list
=
[
image
,
label
],
drop_last
=
True
,
batch_size
=
args
.
batch_size
,
batch_size
=
int
(
args
.
batch_size
/
devices_num
)
,
return_list
=
False
,
shuffle
=
True
,
use_shared_memory
=
True
,
...
...
demo/dygraph/quant/train.py
浏览文件 @
5e363043
...
...
@@ -44,7 +44,7 @@ _logger = get_logger(__name__, level=logging.INFO)
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
add_arg
=
functools
.
partial
(
add_arguments
,
argparser
=
parser
)
# yapf: disable
add_arg
(
'batch_size'
,
int
,
256
,
"Single Card Minibatch size."
)
add_arg
(
'batch_size'
,
int
,
64
,
"Single Card Minibatch size."
)
add_arg
(
'use_gpu'
,
bool
,
True
,
"Whether to use GPU or not."
)
add_arg
(
'model'
,
str
,
"mobilenet_v3"
,
"The target model."
)
add_arg
(
'pretrained_model'
,
str
,
"MobileNetV3_large_x1_0_ssld_pretrained"
,
"Whether to use pretrained model."
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录