Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
2e40660e
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2e40660e
编写于
4月 04, 2018
作者:
W
wanghaoshuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix some issues.
上级
19db989e
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
18 addition
and
16 deletion
+18
-16
python/paddle/fluid/framework.py
python/paddle/fluid/framework.py
+2
-2
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+11
-9
python/paddle/fluid/optimizer.py
python/paddle/fluid/optimizer.py
+2
-2
python/paddle/fluid/param_attr.py
python/paddle/fluid/param_attr.py
+3
-3
未找到文件。
python/paddle/fluid/framework.py
浏览文件 @
2e40660e
...
@@ -1155,7 +1155,7 @@ class Parameter(Variable):
...
@@ -1155,7 +1155,7 @@ class Parameter(Variable):
self
.
gradient_clip_attr
=
kwargs
.
get
(
'gradient_clip_attr'
,
None
)
self
.
gradient_clip_attr
=
kwargs
.
get
(
'gradient_clip_attr'
,
None
)
self
.
average
=
kwargs
.
get
(
'average'
,
Tru
e
)
self
.
do_model_average
=
kwargs
.
get
(
'do_model_average'
,
Non
e
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
to_string
(
True
)
return
self
.
to_string
(
True
)
...
@@ -1177,7 +1177,7 @@ class Parameter(Variable):
...
@@ -1177,7 +1177,7 @@ class Parameter(Variable):
if
with_details
:
if
with_details
:
res_str
=
Variable
.
to_string
(
self
,
throw_on_error
,
True
)
res_str
=
Variable
.
to_string
(
self
,
throw_on_error
,
True
)
additional_attr
=
(
"trainable"
,
"optimize_attr"
,
"regularizer"
,
additional_attr
=
(
"trainable"
,
"optimize_attr"
,
"regularizer"
,
"gradient_clip_attr"
,
"average"
)
"gradient_clip_attr"
,
"
do_model_
average"
)
for
attr_name
in
additional_attr
:
for
attr_name
in
additional_attr
:
res_str
+=
"%s: %s
\n
"
%
(
attr_name
,
res_str
+=
"%s: %s
\n
"
%
(
attr_name
,
str
(
getattr
(
self
,
attr_name
)))
str
(
getattr
(
self
,
attr_name
)))
...
...
python/paddle/fluid/layers/nn.py
浏览文件 @
2e40660e
...
@@ -1489,8 +1489,7 @@ def batch_norm(input,
...
@@ -1489,8 +1489,7 @@ def batch_norm(input,
name
=
None
,
name
=
None
,
moving_mean_name
=
None
,
moving_mean_name
=
None
,
moving_variance_name
=
None
,
moving_variance_name
=
None
,
average_mean
=
True
,
do_model_average_for_mean_and_var
=
False
):
average_variance
=
True
):
"""
"""
This function helps create an operator to implement
This function helps create an operator to implement
the BatchNorm layer using the configurations from the input parameters.
the BatchNorm layer using the configurations from the input parameters.
...
@@ -1519,12 +1518,15 @@ def batch_norm(input,
...
@@ -1519,12 +1518,15 @@ def batch_norm(input,
bias
=
helper
.
create_parameter
(
bias
=
helper
.
create_parameter
(
attr
=
helper
.
bias_attr
,
shape
=
param_shape
,
dtype
=
dtype
,
is_bias
=
True
)
attr
=
helper
.
bias_attr
,
shape
=
param_shape
,
dtype
=
dtype
,
is_bias
=
True
)
if
do_model_average_for_mean_and_var
:
do_model_average_for_mean_and_var
=
None
mean
=
helper
.
create_parameter
(
mean
=
helper
.
create_parameter
(
attr
=
ParamAttr
(
attr
=
ParamAttr
(
name
=
moving_mean_name
,
name
=
moving_mean_name
,
initializer
=
Constant
(
0.0
),
initializer
=
Constant
(
0.0
),
trainable
=
False
,
trainable
=
False
,
average
=
average_variance
),
do_model_average
=
do_model_average_for_mean_and_var
),
shape
=
param_shape
,
shape
=
param_shape
,
dtype
=
input
.
dtype
)
dtype
=
input
.
dtype
)
mean
.
stop_gradient
=
True
mean
.
stop_gradient
=
True
...
@@ -1534,7 +1536,7 @@ def batch_norm(input,
...
@@ -1534,7 +1536,7 @@ def batch_norm(input,
name
=
moving_variance_name
,
name
=
moving_variance_name
,
initializer
=
Constant
(
1.0
),
initializer
=
Constant
(
1.0
),
trainable
=
False
,
trainable
=
False
,
average
=
average_mean
),
do_model_average
=
do_model_average_for_mean_and_var
),
shape
=
param_shape
,
shape
=
param_shape
,
dtype
=
input
.
dtype
)
dtype
=
input
.
dtype
)
variance
.
stop_gradient
=
True
variance
.
stop_gradient
=
True
...
...
python/paddle/fluid/optimizer.py
浏览文件 @
2e40660e
...
@@ -840,7 +840,7 @@ class ModelAverage(Optimizer):
...
@@ -840,7 +840,7 @@ class ModelAverage(Optimizer):
"""
"""
def
__init__
(
self
,
def
__init__
(
self
,
average_window_rate
=
0.15
,
average_window_rate
,
params_grads
=
None
,
params_grads
=
None
,
min_average_window
=
10000
,
min_average_window
=
10000
,
max_average_window
=
10000
,
max_average_window
=
10000
,
...
@@ -856,7 +856,7 @@ class ModelAverage(Optimizer):
...
@@ -856,7 +856,7 @@ class ModelAverage(Optimizer):
params
[
param
.
name
]
=
(
param
,
grad
)
params
[
param
.
name
]
=
(
param
,
grad
)
for
param
in
framework
.
default_main_program
().
global_block
(
for
param
in
framework
.
default_main_program
().
global_block
(
).
all_parameters
():
).
all_parameters
():
if
param
.
name
not
in
params
and
param
.
averag
e
:
if
param
.
name
not
in
params
and
param
.
do_model_average
!=
Fals
e
:
grad
=
param
.
block
.
create_var
(
grad
=
param
.
block
.
create_var
(
name
=
unique_name
.
generate
(
"."
.
join
([
param
.
name
,
'tmp'
])),
name
=
unique_name
.
generate
(
"."
.
join
([
param
.
name
,
'tmp'
])),
dtype
=
param
.
dtype
,
dtype
=
param
.
dtype
,
...
...
python/paddle/fluid/param_attr.py
浏览文件 @
2e40660e
...
@@ -29,14 +29,14 @@ class ParamAttr(object):
...
@@ -29,14 +29,14 @@ class ParamAttr(object):
regularizer
=
None
,
regularizer
=
None
,
trainable
=
True
,
trainable
=
True
,
gradient_clip
=
None
,
gradient_clip
=
None
,
average
=
Tru
e
):
do_model_average
=
Non
e
):
self
.
name
=
name
self
.
name
=
name
self
.
initializer
=
initializer
self
.
initializer
=
initializer
self
.
learning_rate
=
learning_rate
self
.
learning_rate
=
learning_rate
self
.
regularizer
=
regularizer
self
.
regularizer
=
regularizer
self
.
trainable
=
trainable
self
.
trainable
=
trainable
self
.
gradient_clip
=
gradient_clip
self
.
gradient_clip
=
gradient_clip
self
.
average
=
average
self
.
model_average
=
do_model_
average
def
set_default_initializer
(
self
,
initializer
):
def
set_default_initializer
(
self
,
initializer
):
if
initializer
is
None
:
if
initializer
is
None
:
...
@@ -83,7 +83,7 @@ class ParamAttr(object):
...
@@ -83,7 +83,7 @@ class ParamAttr(object):
'regularizer'
:
self
.
regularizer
,
'regularizer'
:
self
.
regularizer
,
'trainable'
:
self
.
trainable
,
'trainable'
:
self
.
trainable
,
'gradient_clip_attr'
:
self
.
gradient_clip
,
'gradient_clip_attr'
:
self
.
gradient_clip
,
'
average'
:
self
.
average
'
model_average'
:
self
.
model_
average
}
}
if
with_initializer
:
if
with_initializer
:
kwargs
[
'initializer'
]
=
self
.
initializer
kwargs
[
'initializer'
]
=
self
.
initializer
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录