Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
b0fa8dce
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看板
未验证
提交
b0fa8dce
编写于
4月 01, 2021
作者:
L
littletomatodonkey
提交者:
GitHub
4月 01, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix log when running vit in static mode (#654)
* fix log when running vit in statich mode * fix comment
上级
23104797
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
25 addition
and
5 deletion
+25
-5
ppcls/modeling/architectures/vision_transformer.py
ppcls/modeling/architectures/vision_transformer.py
+3
-5
ppcls/modeling/utils.py
ppcls/modeling/utils.py
+7
-0
ppcls/utils/check.py
ppcls/utils/check.py
+14
-0
ppcls/utils/config.py
ppcls/utils/config.py
+1
-0
未找到文件。
ppcls/modeling/architectures/vision_transformer.py
浏览文件 @
b0fa8dce
...
@@ -253,11 +253,9 @@ class VisionTransformer(nn.Layer):
...
@@ -253,11 +253,9 @@ class VisionTransformer(nn.Layer):
self
.
head
=
nn
.
Linear
(
embed_dim
,
self
.
head
=
nn
.
Linear
(
embed_dim
,
class_dim
)
if
class_dim
>
0
else
Identity
()
class_dim
)
if
class_dim
>
0
else
Identity
()
# TODO(littletomatodonkey): same init in static mode
trunc_normal_
(
self
.
pos_embed
)
if
paddle
.
in_dynamic_mode
():
trunc_normal_
(
self
.
cls_token
)
trunc_normal_
(
self
.
pos_embed
)
self
.
apply
(
self
.
_init_weights
)
trunc_normal_
(
self
.
cls_token
)
self
.
apply
(
self
.
_init_weights
)
def
_init_weights
(
self
,
m
):
def
_init_weights
(
self
,
m
):
if
isinstance
(
m
,
nn
.
Linear
):
if
isinstance
(
m
,
nn
.
Linear
):
...
...
ppcls/modeling/utils.py
浏览文件 @
b0fa8dce
...
@@ -30,6 +30,13 @@ def get_architectures():
...
@@ -30,6 +30,13 @@ def get_architectures():
return
names
return
names
def
get_blacklist_model_in_static_mode
():
from
ppcls.modeling.architectures
import
distilled_vision_transformer
from
ppcls.modeling.architectures
import
vision_transformer
blacklist
=
distilled_vision_transformer
.
__all__
+
vision_transformer
.
__all__
return
blacklist
def
similar_architectures
(
name
=
''
,
names
=
[],
thresh
=
0.1
,
topk
=
10
):
def
similar_architectures
(
name
=
''
,
names
=
[],
thresh
=
0.1
,
topk
=
10
):
"""
"""
inferred similar architectures
inferred similar architectures
...
...
ppcls/utils/check.py
浏览文件 @
b0fa8dce
...
@@ -24,6 +24,7 @@ from paddle import is_compiled_with_cuda
...
@@ -24,6 +24,7 @@ from paddle import is_compiled_with_cuda
from
ppcls.modeling
import
get_architectures
from
ppcls.modeling
import
get_architectures
from
ppcls.modeling
import
similar_architectures
from
ppcls.modeling
import
similar_architectures
from
ppcls.modeling
import
get_blacklist_model_in_static_mode
from
ppcls.utils
import
logger
from
ppcls.utils
import
logger
...
@@ -79,6 +80,19 @@ def check_architecture(architecture):
...
@@ -79,6 +80,19 @@ def check_architecture(architecture):
sys
.
exit
(
1
)
sys
.
exit
(
1
)
def
check_model_with_running_mode
(
architecture
):
"""
check whether the model is consistent with the operating mode
"""
# some model are not supported in the static mode
blacklist
=
get_blacklist_model_in_static_mode
()
if
not
paddle
.
in_dynamic_mode
()
and
architecture
[
"name"
]
in
blacklist
:
logger
.
error
(
"Model: {} is not supported in the staic mode."
.
format
(
architecture
[
"name"
]))
sys
.
exit
(
1
)
return
def
check_mix
(
architecture
,
use_mix
=
False
):
def
check_mix
(
architecture
,
use_mix
=
False
):
"""
"""
check mix parameter
check mix parameter
...
...
ppcls/utils/config.py
浏览文件 @
b0fa8dce
...
@@ -104,6 +104,7 @@ def check_config(config):
...
@@ -104,6 +104,7 @@ def check_config(config):
architecture
=
config
.
get
(
'ARCHITECTURE'
)
architecture
=
config
.
get
(
'ARCHITECTURE'
)
check
.
check_architecture
(
architecture
)
check
.
check_architecture
(
architecture
)
check
.
check_model_with_running_mode
(
architecture
)
use_mix
=
config
.
get
(
'use_mix'
,
False
)
use_mix
=
config
.
get
(
'use_mix'
,
False
)
check
.
check_mix
(
architecture
,
use_mix
)
check
.
check_mix
(
architecture
,
use_mix
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录