Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
f14b3f30
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
接近 2 年 前同步成功
通知
116
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看板
未验证
提交
f14b3f30
编写于
5月 17, 2020
作者:
D
dyning
提交者:
GitHub
5月 17, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #118 from WuHaobo/master
update some api to support paddle1.8
上级
463d2905
4270c423
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
25 deletion
+27
-25
.gitignore
.gitignore
+1
-0
ppcls/modeling/architectures/efficientnet.py
ppcls/modeling/architectures/efficientnet.py
+3
-3
ppcls/modeling/loss.py
ppcls/modeling/loss.py
+10
-11
ppcls/utils/save_load.py
ppcls/utils/save_load.py
+13
-11
未找到文件。
.gitignore
浏览文件 @
f14b3f30
...
@@ -8,3 +8,4 @@ output/
...
@@ -8,3 +8,4 @@ output/
pretrained/
pretrained/
*.ipynb*
*.ipynb*
_build/
_build/
nohup.out
ppcls/modeling/architectures/efficientnet.py
浏览文件 @
f14b3f30
...
@@ -192,9 +192,9 @@ class EfficientNet():
...
@@ -192,9 +192,9 @@ class EfficientNet():
if
is_test
:
if
is_test
:
return
inputs
return
inputs
keep_prob
=
1.0
-
prob
keep_prob
=
1.0
-
prob
random_tensor
=
keep_prob
+
\
inputs_shape
=
fluid
.
layers
.
shape
(
inputs
)
fluid
.
layers
.
uniform_random_batch_size_like
(
random_tensor
=
keep_prob
+
fluid
.
layers
.
uniform_random
(
inputs
,
[
-
1
,
1
,
1
,
1
],
min
=
0.
,
max
=
1.
)
shape
=
[
inputs_shape
[
0
]
,
1
,
1
,
1
],
min
=
0.
,
max
=
1.
)
binary_tensor
=
fluid
.
layers
.
floor
(
random_tensor
)
binary_tensor
=
fluid
.
layers
.
floor
(
random_tensor
)
output
=
inputs
/
keep_prob
*
binary_tensor
output
=
inputs
/
keep_prob
*
binary_tensor
return
output
return
output
...
...
ppcls/modeling/loss.py
浏览文件 @
f14b3f30
#copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
#
copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
#
#
#Licensed under the Apache License, Version 2.0 (the "License");
#
Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#
you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
#
#Unless required by applicable law or agreed to in writing, software
#
Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#
distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#
See the License for the specific language governing permissions and
#limitations under the License.
#
limitations under the License.
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
...
@@ -34,8 +34,7 @@ class Loss(object):
...
@@ -34,8 +34,7 @@ class Loss(object):
def
_labelsmoothing
(
self
,
target
):
def
_labelsmoothing
(
self
,
target
):
if
target
.
shape
[
-
1
]
!=
self
.
_class_dim
:
if
target
.
shape
[
-
1
]
!=
self
.
_class_dim
:
one_hot_target
=
fluid
.
layers
.
one_hot
(
one_hot_target
=
fluid
.
one_hot
(
input
=
target
,
depth
=
self
.
_class_dim
)
input
=
target
,
depth
=
self
.
_class_dim
)
else
:
else
:
one_hot_target
=
target
one_hot_target
=
target
soft_target
=
fluid
.
layers
.
label_smooth
(
soft_target
=
fluid
.
layers
.
label_smooth
(
...
...
ppcls/utils/save_load.py
浏览文件 @
f14b3f30
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
#
#
#Licensed under the Apache License, Version 2.0 (the "License");
#
Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#
you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
#
#Unless required by applicable law or agreed to in writing, software
#
Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#
distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#
See the License for the specific language governing permissions and
#limitations under the License.
#
limitations under the License.
from
__future__
import
absolute_import
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
division
...
@@ -18,10 +18,10 @@ from __future__ import print_function
...
@@ -18,10 +18,10 @@ from __future__ import print_function
import
errno
import
errno
import
os
import
os
import
re
import
shutil
import
shutil
import
tempfile
import
tempfile
import
paddle
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
from
ppcls.utils
import
logger
from
ppcls.utils
import
logger
...
@@ -58,7 +58,7 @@ def _load_state(path):
...
@@ -58,7 +58,7 @@ def _load_state(path):
return
state
return
state
def
load_params
(
exe
,
prog
,
path
,
ignore_params
=
[]
):
def
load_params
(
exe
,
prog
,
path
,
ignore_params
=
None
):
"""
"""
Load model from the given path.
Load model from the given path.
Args:
Args:
...
@@ -67,7 +67,8 @@ def load_params(exe, prog, path, ignore_params=[]):
...
@@ -67,7 +67,8 @@ def load_params(exe, prog, path, ignore_params=[]):
path (string): URL string or loca model path.
path (string): URL string or loca model path.
ignore_params (list): ignore variable to load when finetuning.
ignore_params (list): ignore variable to load when finetuning.
It can be specified by finetune_exclude_pretrained_params
It can be specified by finetune_exclude_pretrained_params
and the usage can refer to docs/advanced_tutorials/TRANSFER_LEARNING.md
and the usage can refer to the document
docs/advanced_tutorials/TRANSFER_LEARNING.md
"""
"""
if
not
(
os
.
path
.
isdir
(
path
)
or
os
.
path
.
exists
(
path
+
'.pdparams'
)):
if
not
(
os
.
path
.
isdir
(
path
)
or
os
.
path
.
exists
(
path
+
'.pdparams'
)):
raise
ValueError
(
"Model pretrain path {} does not "
raise
ValueError
(
"Model pretrain path {} does not "
...
@@ -101,6 +102,7 @@ def load_params(exe, prog, path, ignore_params=[]):
...
@@ -101,6 +102,7 @@ def load_params(exe, prog, path, ignore_params=[]):
if
k
in
state
:
if
k
in
state
:
logger
.
warning
(
'variable {} is already excluded automatically'
.
format
(
k
))
logger
.
warning
(
'variable {} is already excluded automatically'
.
format
(
k
))
del
state
[
k
]
del
state
[
k
]
fluid
.
io
.
set_program_state
(
prog
,
state
)
fluid
.
io
.
set_program_state
(
prog
,
state
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录