Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
d5c1700f
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
大约 1 年 前同步成功
通知
115
Star
4999
Fork
1114
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
6
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleClas
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
6
合并请求
6
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d5c1700f
编写于
6月 21, 2021
作者:
A
Aurelius84
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support to_static for benchmark
上级
0703bb14
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
29 addition
and
0 deletion
+29
-0
ppcls/arch/__init__.py
ppcls/arch/__init__.py
+16
-0
ppcls/configs/ImageNet/MobileNetV1/MobileNetV1.yaml
ppcls/configs/ImageNet/MobileNetV1/MobileNetV1.yaml
+2
-0
ppcls/configs/ImageNet/MobileNetV2/MobileNetV2.yaml
ppcls/configs/ImageNet/MobileNetV2/MobileNetV2.yaml
+2
-0
ppcls/configs/ImageNet/ResNet/ResNet101.yaml
ppcls/configs/ImageNet/ResNet/ResNet101.yaml
+2
-0
ppcls/configs/ImageNet/ResNet/ResNet152.yaml
ppcls/configs/ImageNet/ResNet/ResNet152.yaml
+2
-0
ppcls/configs/ImageNet/ResNet/ResNet50.yaml
ppcls/configs/ImageNet/ResNet/ResNet50.yaml
+2
-0
ppcls/engine/trainer.py
ppcls/engine/trainer.py
+3
-0
未找到文件。
ppcls/arch/__init__.py
浏览文件 @
d5c1700f
...
...
@@ -16,11 +16,14 @@ import copy
import
importlib
import
paddle.nn
as
nn
from
paddle.jit
import
to_static
from
paddle.static
import
InputSpec
from
.
import
backbone
,
gears
from
.backbone
import
*
from
.gears
import
build_gear
from
.utils
import
*
from
ppcls.utils
import
logger
from
ppcls.utils.save_load
import
load_dygraph_pretrain
__all__
=
[
"build_model"
,
"RecModel"
,
"DistillationModel"
]
...
...
@@ -34,6 +37,19 @@ def build_model(config):
return
arch
def
apply_to_static
(
config
,
model
):
support_to_static
=
config
[
'Global'
].
get
(
'to_static'
,
False
)
if
support_to_static
:
specs
=
None
if
'image_shape'
in
config
[
'Global'
]:
specs
=
[
InputSpec
([
None
]
+
config
[
'Global'
][
'image_shape'
])]
model
=
to_static
(
model
,
input_spec
=
specs
)
logger
.
info
(
"Successfully to apply @to_static with specs: {}"
.
format
(
specs
))
return
model
class
RecModel
(
nn
.
Layer
):
def
__init__
(
self
,
**
config
):
super
().
__init__
()
...
...
ppcls/configs/ImageNet/MobileNetV1/MobileNetV1.yaml
浏览文件 @
d5c1700f
...
...
@@ -14,6 +14,8 @@ Global:
# used for static mode and model export
image_shape
:
[
3
,
224
,
224
]
save_inference_dir
:
./inference
# training model under @to_static
to_static
:
False
# model architecture
Arch
:
...
...
ppcls/configs/ImageNet/MobileNetV2/MobileNetV2.yaml
浏览文件 @
d5c1700f
...
...
@@ -14,6 +14,8 @@ Global:
# used for static mode and model export
image_shape
:
[
3
,
224
,
224
]
save_inference_dir
:
./inference
# training model under @to_static
to_static
:
False
# model architecture
Arch
:
...
...
ppcls/configs/ImageNet/ResNet/ResNet101.yaml
浏览文件 @
d5c1700f
...
...
@@ -14,6 +14,8 @@ Global:
# used for static mode and model export
image_shape
:
[
3
,
224
,
224
]
save_inference_dir
:
./inference
# training model under @to_static
to_static
:
False
# model architecture
Arch
:
...
...
ppcls/configs/ImageNet/ResNet/ResNet152.yaml
浏览文件 @
d5c1700f
...
...
@@ -14,6 +14,8 @@ Global:
# used for static mode and model export
image_shape
:
[
3
,
224
,
224
]
save_inference_dir
:
./inference
# training model under @to_static
to_static
:
False
# model architecture
Arch
:
...
...
ppcls/configs/ImageNet/ResNet/ResNet50.yaml
浏览文件 @
d5c1700f
...
...
@@ -14,6 +14,8 @@ Global:
# used for static mode and model export
image_shape
:
[
3
,
224
,
224
]
save_inference_dir
:
./inference
# training model under @to_static
to_static
:
False
# model architecture
Arch
:
...
...
ppcls/engine/trainer.py
浏览文件 @
d5c1700f
...
...
@@ -34,6 +34,7 @@ from ppcls.utils.logger import init_logger
from
ppcls.utils.config
import
print_config
from
ppcls.data
import
build_dataloader
from
ppcls.arch
import
build_model
from
ppcls.arch
import
apply_to_static
from
ppcls.loss
import
build_loss
from
ppcls.metric
import
build_metrics
from
ppcls.optimizer
import
build_optimizer
...
...
@@ -73,6 +74,8 @@ class Trainer(object):
self
.
is_rec
=
False
self
.
model
=
build_model
(
self
.
config
[
"Arch"
])
# set @to_static for benchmark, skip this by default.
apply_to_static
(
self
.
config
,
self
.
model
)
if
self
.
config
[
"Global"
][
"pretrained_model"
]
is
not
None
:
load_dygraph_pretrain
(
self
.
model
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录