Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
5502abb9
P
Paddle
项目概览
PaddlePaddle
/
Paddle
11 个月 前同步成功
通知
2289
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5502abb9
编写于
11月 22, 2017
作者:
P
peterzhang2029
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine docstrings
上级
9580c450
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
10 addition
and
27 deletion
+10
-27
paddle/gserver/layers/CudnnBatchNormLayer.cpp
paddle/gserver/layers/CudnnBatchNormLayer.cpp
+4
-18
paddle/gserver/layers/CudnnBatchNormLayer.h
paddle/gserver/layers/CudnnBatchNormLayer.h
+1
-3
proto/ModelConfig.proto
proto/ModelConfig.proto
+1
-1
python/paddle/trainer/config_parser.py
python/paddle/trainer/config_parser.py
+3
-2
python/paddle/trainer_config_helpers/layers.py
python/paddle/trainer_config_helpers/layers.py
+1
-3
未找到文件。
paddle/gserver/layers/CudnnBatchNormLayer.cpp
浏览文件 @
5502abb9
...
...
@@ -21,8 +21,6 @@ namespace paddle {
REGISTER_LAYER
(
cudnn_batch_norm
,
CudnnBatchNormLayer
);
const
double
CudnnBatchNormLayer
::
MIN_EPS
=
1E-5
;
bool
CudnnBatchNormLayer
::
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
{
/* Initialize the basic parent class */
...
...
@@ -61,14 +59,8 @@ void CudnnBatchNormLayer::forward(PassType passType) {
real
*
movingMean
=
movingMean_
->
getW
()
->
getData
();
real
*
movingVar
=
movingVar_
->
getW
()
->
getData
();
/**
* If epsilon_ equals to 1e-5 and eps_ is assigned the value of
* static_cast<double>(epsilon_), The CUDNN_STATUS_BAD_PARAM error
* will occur due to eps_ value is less than
* CUDNN_BN_MIN_EPSILON.
* The following code is to ensure that the eps_ meets requirement.
*/
eps_
=
std
::
max
(
MIN_EPS
,
static_cast
<
double
>
(
epsilon_
));
// cuDNN does not allow an epsilon value less than CUDNN_BN_MIN_EPSILON.
eps_
=
std
::
max
(
CUDNN_BN_MIN_EPSILON
,
static_cast
<
double
>
(
epsilon_
));
if
(
!
useGlobalStats_
)
{
REGISTER_TIMER_INFO
(
"CudnnBatchFwTimer"
,
getName
().
c_str
());
...
...
@@ -137,14 +129,8 @@ void CudnnBatchNormLayer::backward(const UpdateCallback& callback) {
real
*
savedMean
=
savedMean_
->
getData
();
real
*
savedInvVar
=
savedInvVar_
->
getData
();
/**
* If epsilon_ equals to 1e-5 and eps_ is assigned the value of
* static_cast<double>(epsilon_), The CUDNN_STATUS_BAD_PARAM error
* will occur due to eps_ value is less than
* CUDNN_BN_MIN_EPSILON.
* The following code is to ensure that the eps_ meets requirement.
*/
eps_
=
std
::
max
(
MIN_EPS
,
static_cast
<
double
>
(
epsilon_
));
// cuDNN does not allow an epsilon value less than CUDNN_BN_MIN_EPSILON.
eps_
=
std
::
max
(
CUDNN_BN_MIN_EPSILON
,
static_cast
<
double
>
(
epsilon_
));
auto
create
=
[](
MatrixPtr
&
m
,
size_t
h
,
size_t
w
,
real
**
p
)
{
Matrix
::
resizeOrCreate
(
m
,
h
,
w
,
false
,
true
);
...
...
paddle/gserver/layers/CudnnBatchNormLayer.h
浏览文件 @
5502abb9
...
...
@@ -14,6 +14,7 @@ limitations under the License. */
#pragma once
#include <cudnn.h>
#include "BatchNormBaseLayer.h"
#include "Layer.h"
#include "paddle/utils/Stat.h"
...
...
@@ -46,9 +47,6 @@ public:
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
protected:
/// Minimum allowed value is CUDNN_BN_MIN_EPSILON defined in cudnn.h.
static
const
double
MIN_EPS
;
/// Epsilon value used in the batch normalization formula.
/// Same epsilon value should be used in forward and backward functions.
double
eps_
;
...
...
proto/ModelConfig.proto
浏览文件 @
5502abb9
...
...
@@ -542,7 +542,7 @@ message LayerConfig {
optional
ReshapeConfig
reshape_conf
=
59
;
// for batch normalization layer
//
small constant added to the variance to avoid numerical problems
.
//
The small constant added to the variance to improve numeric stability
.
optional
double
epsilon
=
60
[
default
=
0.00001
];
}
...
...
python/paddle/trainer/config_parser.py
浏览文件 @
5502abb9
...
...
@@ -2483,8 +2483,9 @@ class BatchNormLayer(LayerBase):
self
.
config
.
use_global_stats
=
use_global_stats
if
moving_average_fraction
is
not
None
:
self
.
config
.
moving_average_fraction
=
moving_average_fraction
self
.
config
.
epsilon
=
epsilon
if
epsilon
is
not
None
:
assert
epsilon
>=
1e-5
,
"epsilon must be no less than 1e-5."
self
.
config
.
epsilon
=
epsilon
input_layer
=
self
.
get_input_layer
(
0
)
image_conf
=
self
.
config
.
inputs
[
0
].
image_conf
...
...
python/paddle/trainer_config_helpers/layers.py
浏览文件 @
5502abb9
...
...
@@ -3107,7 +3107,7 @@ def batch_norm_layer(input,
will use the mean and variance of the current batch
of test data.
:type use_global_stats: bool | None.
:param epsilon:
Small constant added to the variance to avoid numerical problems
.
:param epsilon:
The small constant added to the variance to improve numeric stability
.
:type epsilon: float.
:param moving_average_fraction: Factor used in the moving average computation.
:math:`runningMean = newMean*(1-factor) + runningMean*factor`
...
...
@@ -3127,8 +3127,6 @@ def batch_norm_layer(input,
(
batch_norm_type
==
"mkldnn_batch_norm"
)
or
\
(
batch_norm_type
==
"cudnn_batch_norm"
)
assert
epsilon
>=
1e-5
,
"epsilon must be no less than 1e-5."
l
=
Layer
(
name
=
name
,
img3D
=
img3D
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录