Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
f95e8ffc
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f95e8ffc
编写于
9月 04, 2020
作者:
L
LielinJiang
提交者:
GitHub
9月 04, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix conv and summary api bug (#27023)
* fix conv output_size has no default value bug * fix summary bug
上级
0dfe26d0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
19 addition
and
6 deletion
+19
-6
python/paddle/hapi/model.py
python/paddle/hapi/model.py
+7
-2
python/paddle/hapi/model_summary.py
python/paddle/hapi/model_summary.py
+7
-3
python/paddle/nn/layer/conv.py
python/paddle/nn/layer/conv.py
+1
-1
python/paddle/tests/test_model.py
python/paddle/tests/test_model.py
+4
-0
未找到文件。
python/paddle/hapi/model.py
浏览文件 @
f95e8ffc
...
...
@@ -1868,8 +1868,13 @@ class Model(object):
print(params_info)
"""
return
summary
(
self
.
network
,
self
.
_inputs
,
batch_size
,
dtype
)
assert
(
input_size
is
not
None
or
self
.
_inputs
is
not
None
),
"'input_size' or 'self._input' must be set"
if
input_size
is
not
None
:
_input_size
=
input_size
else
:
_input_size
=
self
.
_inputs
return
summary
(
self
.
network
,
_input_size
,
batch_size
,
dtype
)
def
_verify_spec
(
self
,
specs
,
is_input
=
False
):
out_specs
=
[]
...
...
python/paddle/hapi/model_summary.py
浏览文件 @
f95e8ffc
...
...
@@ -86,8 +86,10 @@ def summary(net, input_size, batch_size=None, dtypes=None):
elif
isinstance
(
input_size
,
list
):
_input_size
=
[]
for
item
in
input_size
:
if
isinstance
(
item
,
int
):
item
=
(
item
,
)
assert
isinstance
(
item
,
(
list
,
InputSpec
)),
'When input_size is list,
\
(
tuple
,
InputSpec
)),
'When input_size is list,
\
expect item in input_size is a tuple or InputSpec, but got {}'
.
format
(
type
(
item
))
...
...
@@ -97,6 +99,8 @@ def summary(net, input_size, batch_size=None, dtypes=None):
batch_size
=
item
.
shape
[
0
]
else
:
_input_size
.
append
(
item
)
elif
isinstance
(
input_size
,
int
):
_input_size
=
(
input_size
,
)
else
:
_input_size
=
input_size
...
...
@@ -138,11 +142,11 @@ def summary_string(model, input_size, batch_size=-1, dtypes=None):
summary
[
m_key
][
"output_shape"
][
0
]
=
batch_size
params
=
0
if
hasattr
(
module
,
"weight"
):
if
hasattr
(
module
,
"weight"
)
and
hasattr
(
module
.
weight
,
"shape"
)
:
params
+=
np
.
prod
(
module
.
weight
.
shape
)
summary
[
m_key
][
"trainable"
]
=
module
.
weight
.
trainable
or
(
not
module
.
weight
.
stop_gradient
)
if
hasattr
(
module
,
"bias"
):
if
hasattr
(
module
,
"bias"
)
and
hasattr
(
module
.
bias
,
"shape"
)
:
params
+=
np
.
prod
(
module
.
bias
.
shape
)
summary
[
m_key
][
"nb_params"
]
=
params
...
...
python/paddle/nn/layer/conv.py
浏览文件 @
f95e8ffc
...
...
@@ -1084,7 +1084,7 @@ class ConvTranspose3d(_ConvNd):
bias_attr
=
bias_attr
,
data_format
=
data_format
)
def
forward
(
self
,
x
,
output_size
):
def
forward
(
self
,
x
,
output_size
=
None
):
if
output_size
is
None
:
output_padding
=
self
.
output_padding
else
:
...
...
python/paddle/tests/test_model.py
浏览文件 @
f95e8ffc
...
...
@@ -519,6 +519,10 @@ class TestModelFunction(unittest.TestCase):
np
.
testing
.
assert_allclose
(
params_info
[
'total_params'
],
gt_params
)
print
(
params_info
)
model
.
summary
(
input_size
=
(
20
))
model
.
summary
(
input_size
=
[(
20
)])
model
.
summary
(
input_size
=
(
20
),
batch_size
=
2
)
def
test_export_deploy_model
(
self
):
for
dynamic
in
[
True
,
False
]:
fluid
.
enable_dygraph
()
if
dynamic
else
None
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录