Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
630cb60a
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看板
提交
630cb60a
编写于
9月 16, 2020
作者:
littletomatodonkey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix dropout
上级
5ce653d6
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
29 addition
and
20 deletion
+29
-20
ppcls/modeling/architectures/alexnet.py
ppcls/modeling/architectures/alexnet.py
+2
-2
ppcls/modeling/architectures/densenet.py
ppcls/modeling/architectures/densenet.py
+1
-1
ppcls/modeling/architectures/googlenet.py
ppcls/modeling/architectures/googlenet.py
+3
-3
ppcls/modeling/architectures/inception_v4.py
ppcls/modeling/architectures/inception_v4.py
+1
-1
ppcls/modeling/architectures/mobilenet_v3.py
ppcls/modeling/architectures/mobilenet_v3.py
+11
-4
ppcls/modeling/architectures/squeezenet.py
ppcls/modeling/architectures/squeezenet.py
+1
-1
ppcls/modeling/architectures/vgg.py
ppcls/modeling/architectures/vgg.py
+1
-1
ppcls/modeling/architectures/xception_deeplab.py
ppcls/modeling/architectures/xception_deeplab.py
+1
-1
tools/eval.py
tools/eval.py
+8
-6
未找到文件。
ppcls/modeling/architectures/alexnet.py
浏览文件 @
630cb60a
...
@@ -83,7 +83,7 @@ class AlexNetDY(nn.Layer):
...
@@ -83,7 +83,7 @@ class AlexNetDY(nn.Layer):
256
,
256
,
3
,
1
,
1
,
stdv
,
act
=
"relu"
,
name
=
"conv5"
)
256
,
256
,
3
,
1
,
1
,
stdv
,
act
=
"relu"
,
name
=
"conv5"
)
stdv
=
1.0
/
math
.
sqrt
(
256
*
6
*
6
)
stdv
=
1.0
/
math
.
sqrt
(
256
*
6
*
6
)
self
.
_drop1
=
Dropout
(
p
=
0.5
)
self
.
_drop1
=
Dropout
(
p
=
0.5
,
mode
=
"downscale_in_infer"
)
self
.
_fc6
=
Linear
(
self
.
_fc6
=
Linear
(
in_features
=
256
*
6
*
6
,
in_features
=
256
*
6
*
6
,
out_features
=
4096
,
out_features
=
4096
,
...
@@ -92,7 +92,7 @@ class AlexNetDY(nn.Layer):
...
@@ -92,7 +92,7 @@ class AlexNetDY(nn.Layer):
bias_attr
=
ParamAttr
(
bias_attr
=
ParamAttr
(
name
=
"fc6_offset"
,
initializer
=
Uniform
(
-
stdv
,
stdv
)))
name
=
"fc6_offset"
,
initializer
=
Uniform
(
-
stdv
,
stdv
)))
self
.
_drop2
=
Dropout
(
p
=
0.5
)
self
.
_drop2
=
Dropout
(
p
=
0.5
,
mode
=
"downscale_in_infer"
)
self
.
_fc7
=
Linear
(
self
.
_fc7
=
Linear
(
in_features
=
4096
,
in_features
=
4096
,
out_features
=
4096
,
out_features
=
4096
,
...
...
ppcls/modeling/architectures/densenet.py
浏览文件 @
630cb60a
...
@@ -89,7 +89,7 @@ class DenseLayer(nn.Layer):
...
@@ -89,7 +89,7 @@ class DenseLayer(nn.Layer):
name
=
name
+
"_x2"
)
name
=
name
+
"_x2"
)
if
dropout
:
if
dropout
:
self
.
dropout_func
=
Dropout
(
p
=
dropout
)
self
.
dropout_func
=
Dropout
(
p
=
dropout
,
mode
=
"downscale_in_infer"
)
def
forward
(
self
,
input
):
def
forward
(
self
,
input
):
conv
=
self
.
bn_ac_func1
(
input
)
conv
=
self
.
bn_ac_func1
(
input
)
...
...
ppcls/modeling/architectures/googlenet.py
浏览文件 @
630cb60a
...
@@ -126,7 +126,7 @@ class GoogleNetDY(nn.Layer):
...
@@ -126,7 +126,7 @@ class GoogleNetDY(nn.Layer):
self
.
_pool_5
=
AvgPool2d
(
kernel_size
=
7
,
stride
=
7
)
self
.
_pool_5
=
AvgPool2d
(
kernel_size
=
7
,
stride
=
7
)
self
.
_drop
=
Dropout
(
p
=
0.4
)
self
.
_drop
=
Dropout
(
p
=
0.4
,
mode
=
"downscale_in_infer"
)
self
.
_fc_out
=
Linear
(
self
.
_fc_out
=
Linear
(
1024
,
1024
,
class_dim
,
class_dim
,
...
@@ -139,7 +139,7 @@ class GoogleNetDY(nn.Layer):
...
@@ -139,7 +139,7 @@ class GoogleNetDY(nn.Layer):
1024
,
1024
,
weight_attr
=
xavier
(
2048
,
1
,
"fc_o1"
),
weight_attr
=
xavier
(
2048
,
1
,
"fc_o1"
),
bias_attr
=
ParamAttr
(
name
=
"fc_o1_offset"
))
bias_attr
=
ParamAttr
(
name
=
"fc_o1_offset"
))
self
.
_drop_o1
=
Dropout
(
p
=
0.7
)
self
.
_drop_o1
=
Dropout
(
p
=
0.7
,
mode
=
"downscale_in_infer"
)
self
.
_out1
=
Linear
(
self
.
_out1
=
Linear
(
1024
,
1024
,
class_dim
,
class_dim
,
...
@@ -152,7 +152,7 @@ class GoogleNetDY(nn.Layer):
...
@@ -152,7 +152,7 @@ class GoogleNetDY(nn.Layer):
1024
,
1024
,
weight_attr
=
xavier
(
2048
,
1
,
"fc_o2"
),
weight_attr
=
xavier
(
2048
,
1
,
"fc_o2"
),
bias_attr
=
ParamAttr
(
name
=
"fc_o2_offset"
))
bias_attr
=
ParamAttr
(
name
=
"fc_o2_offset"
))
self
.
_drop_o2
=
Dropout
(
p
=
0.7
)
self
.
_drop_o2
=
Dropout
(
p
=
0.7
,
mode
=
"downscale_in_infer"
)
self
.
_out2
=
Linear
(
self
.
_out2
=
Linear
(
1024
,
1024
,
class_dim
,
class_dim
,
...
...
ppcls/modeling/architectures/inception_v4.py
浏览文件 @
630cb60a
...
@@ -412,7 +412,7 @@ class InceptionV4DY(nn.Layer):
...
@@ -412,7 +412,7 @@ class InceptionV4DY(nn.Layer):
self
.
_inceptionC_3
=
InceptionC
(
name
=
"3"
)
self
.
_inceptionC_3
=
InceptionC
(
name
=
"3"
)
self
.
avg_pool
=
AdaptiveAvgPool2d
(
1
)
self
.
avg_pool
=
AdaptiveAvgPool2d
(
1
)
self
.
_drop
=
Dropout
(
p
=
0.2
)
self
.
_drop
=
Dropout
(
p
=
0.2
,
mode
=
"downscale_in_infer"
)
stdv
=
1.0
/
math
.
sqrt
(
1536
*
1.0
)
stdv
=
1.0
/
math
.
sqrt
(
1536
*
1.0
)
self
.
out
=
Linear
(
self
.
out
=
Linear
(
1536
,
1536
,
...
...
ppcls/modeling/architectures/mobilenet_v3.py
浏览文件 @
630cb60a
...
@@ -46,7 +46,11 @@ def make_divisible(v, divisor=8, min_value=None):
...
@@ -46,7 +46,11 @@ def make_divisible(v, divisor=8, min_value=None):
class
MobileNetV3
(
nn
.
Layer
):
class
MobileNetV3
(
nn
.
Layer
):
def
__init__
(
self
,
scale
=
1.0
,
model_name
=
"small"
,
class_dim
=
1000
):
def
__init__
(
self
,
scale
=
1.0
,
model_name
=
"small"
,
dropout_prob
=
0.2
,
class_dim
=
1000
):
super
(
MobileNetV3
,
self
).
__init__
()
super
(
MobileNetV3
,
self
).
__init__
()
inplanes
=
16
inplanes
=
16
...
@@ -144,24 +148,27 @@ class MobileNetV3(nn.Layer):
...
@@ -144,24 +148,27 @@ class MobileNetV3(nn.Layer):
weight_attr
=
ParamAttr
(
name
=
"last_1x1_conv_weights"
),
weight_attr
=
ParamAttr
(
name
=
"last_1x1_conv_weights"
),
bias_attr
=
False
)
bias_attr
=
False
)
self
.
dropout
=
Dropout
(
p
=
dropout_prob
,
mode
=
"downscale_in_infer"
)
self
.
out
=
Linear
(
self
.
out
=
Linear
(
self
.
cls_ch_expand
,
self
.
cls_ch_expand
,
class_dim
,
class_dim
,
weight_attr
=
ParamAttr
(
"fc_weights"
),
weight_attr
=
ParamAttr
(
"fc_weights"
),
bias_attr
=
ParamAttr
(
name
=
"fc_offset"
))
bias_attr
=
ParamAttr
(
name
=
"fc_offset"
))
def
forward
(
self
,
inputs
,
label
=
None
,
dropout_prob
=
0.2
):
def
forward
(
self
,
inputs
,
label
=
None
):
x
=
self
.
conv1
(
inputs
)
x
=
self
.
conv1
(
inputs
)
for
block
in
self
.
block_list
:
for
block
in
self
.
block_list
:
x
=
block
(
x
)
x
=
block
(
x
)
x
=
self
.
last_second_conv
(
x
)
x
=
self
.
last_second_conv
(
x
)
x
=
self
.
pool
(
x
)
x
=
self
.
pool
(
x
)
x
=
self
.
last_conv
(
x
)
x
=
self
.
last_conv
(
x
)
x
=
F
.
hard_swish
(
x
)
x
=
F
.
hard_swish
(
x
)
x
=
F
.
dropout
(
x
=
x
,
p
=
dropout_prob
)
x
=
self
.
dropout
(
x
)
x
=
paddle
.
reshape
(
x
,
shape
=
[
x
.
shape
[
0
],
x
.
shape
[
1
]])
x
=
paddle
.
reshape
(
x
,
shape
=
[
x
.
shape
[
0
],
x
.
shape
[
1
]])
x
=
self
.
out
(
x
)
x
=
self
.
out
(
x
)
return
x
return
x
...
...
ppcls/modeling/architectures/squeezenet.py
浏览文件 @
630cb60a
...
@@ -101,7 +101,7 @@ class SqueezeNet(nn.Layer):
...
@@ -101,7 +101,7 @@ class SqueezeNet(nn.Layer):
self
.
_conv7
=
MakeFire
(
384
,
64
,
256
,
256
,
name
=
"fire8"
)
self
.
_conv7
=
MakeFire
(
384
,
64
,
256
,
256
,
name
=
"fire8"
)
self
.
_conv8
=
MakeFire
(
512
,
64
,
256
,
256
,
name
=
"fire9"
)
self
.
_conv8
=
MakeFire
(
512
,
64
,
256
,
256
,
name
=
"fire9"
)
self
.
_drop
=
Dropout
(
p
=
0.5
)
self
.
_drop
=
Dropout
(
p
=
0.5
,
mode
=
"downscale_in_infer"
)
self
.
_conv9
=
Conv2d
(
self
.
_conv9
=
Conv2d
(
512
,
512
,
class_dim
,
class_dim
,
...
...
ppcls/modeling/architectures/vgg.py
浏览文件 @
630cb60a
...
@@ -89,7 +89,7 @@ class VGGNet(nn.Layer):
...
@@ -89,7 +89,7 @@ class VGGNet(nn.Layer):
self
.
_conv_block_4
=
ConvBlock
(
256
,
512
,
self
.
groups
[
3
],
name
=
"conv4_"
)
self
.
_conv_block_4
=
ConvBlock
(
256
,
512
,
self
.
groups
[
3
],
name
=
"conv4_"
)
self
.
_conv_block_5
=
ConvBlock
(
512
,
512
,
self
.
groups
[
4
],
name
=
"conv5_"
)
self
.
_conv_block_5
=
ConvBlock
(
512
,
512
,
self
.
groups
[
4
],
name
=
"conv5_"
)
self
.
_drop
=
Dropout
(
p
=
0.5
)
self
.
_drop
=
Dropout
(
p
=
0.5
,
mode
=
"downscale_in_infer"
)
self
.
_fc1
=
Linear
(
self
.
_fc1
=
Linear
(
7
*
7
*
512
,
7
*
7
*
512
,
4096
,
4096
,
...
...
ppcls/modeling/architectures/xception_deeplab.py
浏览文件 @
630cb60a
...
@@ -346,7 +346,7 @@ class XceptionDeeplab(nn.Layer):
...
@@ -346,7 +346,7 @@ class XceptionDeeplab(nn.Layer):
self
.
stride
=
s
self
.
stride
=
s
self
.
_drop
=
Dropout
(
p
=
0.5
)
self
.
_drop
=
Dropout
(
p
=
0.5
,
mode
=
"downscale_in_infer"
)
self
.
_pool
=
AdaptiveAvgPool2d
(
1
)
self
.
_pool
=
AdaptiveAvgPool2d
(
1
)
self
.
_fc
=
Linear
(
self
.
_fc
=
Linear
(
self
.
chns
[
1
][
-
1
],
self
.
chns
[
1
][
-
1
],
...
...
tools/eval.py
浏览文件 @
630cb60a
...
@@ -12,13 +12,9 @@
...
@@ -12,13 +12,9 @@
# 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
paddle.distributed
import
ParallelEnv
import
paddle
import
paddle
from
ppcls.utils
import
logger
from
paddle.distributed
import
ParallelEnv
from
ppcls.utils.save_load
import
init_model
from
ppcls.utils.config
import
get_config
from
ppcls.data
import
Reader
import
program
import
argparse
import
argparse
import
os
import
os
import
sys
import
sys
...
@@ -26,6 +22,12 @@ __dir__ = os.path.dirname(os.path.abspath(__file__))
...
@@ -26,6 +22,12 @@ __dir__ = os.path.dirname(os.path.abspath(__file__))
sys
.
path
.
append
(
__dir__
)
sys
.
path
.
append
(
__dir__
)
sys
.
path
.
append
(
os
.
path
.
abspath
(
os
.
path
.
join
(
__dir__
,
'..'
)))
sys
.
path
.
append
(
os
.
path
.
abspath
(
os
.
path
.
join
(
__dir__
,
'..'
)))
from
ppcls.utils
import
logger
from
ppcls.utils.save_load
import
init_model
from
ppcls.utils.config
import
get_config
from
ppcls.data
import
Reader
import
program
def
parse_args
():
def
parse_args
():
parser
=
argparse
.
ArgumentParser
(
"PaddleClas eval script"
)
parser
=
argparse
.
ArgumentParser
(
"PaddleClas eval script"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录