Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
4e3b5e72
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看板
提交
4e3b5e72
编写于
3月 21, 2019
作者:
P
phlrain
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of
https://github.com/PaddlePaddle/Paddle
into fix_concat_check
上级
b3d03366
5670530c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
39 addition
and
21 deletion
+39
-21
paddle/fluid/API.spec
paddle/fluid/API.spec
+1
-1
paddle/fluid/operators/affine_channel_op.cc
paddle/fluid/operators/affine_channel_op.cc
+22
-2
paddle/fluid/operators/batch_norm_op.cu
paddle/fluid/operators/batch_norm_op.cu
+8
-16
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+8
-2
未找到文件。
paddle/fluid/API.spec
浏览文件 @
4e3b5e72
...
...
@@ -205,7 +205,7 @@ paddle.fluid.layers.maxout (ArgSpec(args=['x', 'groups', 'name'], varargs=None,
paddle.fluid.layers.space_to_depth (ArgSpec(args=['x', 'blocksize', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '5f207ae10589ebe38a63575ef6ff8e1e'))
paddle.fluid.layers.affine_grid (ArgSpec(args=['theta', 'out_shape', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '51def402b8910e163cbace9d0c0526ed'))
paddle.fluid.layers.sequence_reverse (ArgSpec(args=['x', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '77a6d80aa5551ca70324fc975c44507f'))
paddle.fluid.layers.affine_channel (ArgSpec(args=['x', 'scale', 'bias', 'data_layout', 'name'
], varargs=None, keywords=None, defaults=(None, None, 'NCHW', None)), ('document', '2f46f1ff39a13ab00857e7b9f44b2fa7
'))
paddle.fluid.layers.affine_channel (ArgSpec(args=['x', 'scale', 'bias', 'data_layout', 'name'
, 'act'], varargs=None, keywords=None, defaults=(None, None, 'NCHW', None, None)), ('document', 'ab84fdc6dc60f3ad9aa397e6007e3bf9
'))
paddle.fluid.layers.similarity_focus (ArgSpec(args=['input', 'axis', 'indexes', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '70e3b5182a18b40b47ecabd7c8490a35'))
paddle.fluid.layers.hash (ArgSpec(args=['input', 'hash_size', 'num_hash', 'name'], varargs=None, keywords=None, defaults=(1, None)), ('document', '9bb77f8dc002dd2ce75d4769eaaf5007'))
paddle.fluid.layers.grid_sampler (ArgSpec(args=['x', 'grid', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', 'd256cba1c41a5ed92ce3f31e24a2ca6d'))
...
...
paddle/fluid/operators/affine_channel_op.cc
浏览文件 @
4e3b5e72
...
...
@@ -113,6 +113,27 @@ class AffineChannelOpGrad : public framework::OperatorWithKernel {
}
};
class
AffineChannelGradMaker
:
public
framework
::
SingleGradOpDescMaker
{
public:
using
framework
::
SingleGradOpDescMaker
::
SingleGradOpDescMaker
;
std
::
unique_ptr
<
framework
::
OpDesc
>
Apply
()
const
override
{
auto
*
op
=
new
framework
::
OpDesc
();
op
->
SetType
(
"affine_channel_grad"
);
op
->
SetInput
(
"X"
,
Input
(
"X"
));
op
->
SetInput
(
framework
::
GradVarName
(
"Out"
),
OutputGrad
(
"Out"
));
op
->
SetInput
(
"Scale"
,
Input
(
"Scale"
));
op
->
SetAttrMap
(
Attrs
());
op
->
SetOutput
(
framework
::
GradVarName
(
"X"
),
InputGrad
(
"X"
));
op
->
SetOutput
(
framework
::
GradVarName
(
"Scale"
),
InputGrad
(
"Scale"
));
op
->
SetOutput
(
framework
::
GradVarName
(
"Bias"
),
InputGrad
(
"Bias"
));
return
std
::
unique_ptr
<
framework
::
OpDesc
>
(
op
);
}
};
template
<
typename
T
>
using
EigenArrayMap
=
Eigen
::
Map
<
Eigen
::
Array
<
T
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>>
;
...
...
@@ -260,8 +281,7 @@ namespace ops = paddle::operators;
using
CPU
=
paddle
::
platform
::
CPUDeviceContext
;
REGISTER_OPERATOR
(
affine_channel
,
ops
::
AffineChannelOp
,
ops
::
AffineChannelOpMaker
,
paddle
::
framework
::
DefaultGradOpDescMaker
<
true
>
);
ops
::
AffineChannelOpMaker
,
ops
::
AffineChannelGradMaker
);
REGISTER_OPERATOR
(
affine_channel_grad
,
ops
::
AffineChannelOpGrad
);
REGISTER_OP_CPU_KERNEL
(
affine_channel
,
ops
::
AffineChannelKernel
<
CPU
,
float
>
,
...
...
paddle/fluid/operators/batch_norm_op.cu
浏览文件 @
4e3b5e72
...
...
@@ -75,15 +75,11 @@ class BatchNormKernel<platform::CUDADeviceContext, T>
<<
"CUDNN_BN_MIN_EPSILON instead."
;
}
epsilon
=
std
::
max
(
epsilon
,
CUDNN_BN_MIN_EPSILON
);
// TODO(dengkaipeng): use PERSISTENT mode in training may incur errors
// in inference period, cuDNN fixed issues on PERSISTENT mode in version
// 7.0.2, 7.0.4 and 7.3.0, we disable this mode currently.
// #if CUDNN_VERSION_MIN(7, 0, 0)
// mode_ = CUDNN_BATCHNORM_SPATIAL_PERSISTENT;
// #else
#if CUDNN_VERSION_MIN(7, 0, 0)
mode_
=
CUDNN_BATCHNORM_SPATIAL_PERSISTENT
;
#else
mode_
=
CUDNN_BATCHNORM_SPATIAL
;
//
#endif
#endif
VLOG
(
3
)
<<
"Setting descriptors."
;
std
::
vector
<
int
>
dims
;
...
...
@@ -305,15 +301,11 @@ class BatchNormGradKernel<platform::CUDADeviceContext, T>
<<
"CUDNN_BN_MIN_EPSILON instead."
;
}
epsilon
=
std
::
max
(
epsilon
,
CUDNN_BN_MIN_EPSILON
);
// TODO(dengkaipeng): use PERSISTENT mode in training may incur errors
// in inference period, cuDNN fixed issues on PERSISTENT mode in version
// 7.0.2, 7.0.4 and 7.3.0, we disable this mode currently.
// #if CUDNN_VERSION_MIN(7, 0, 0)
// mode_ = CUDNN_BATCHNORM_SPATIAL_PERSISTENT;
// #else
#if CUDNN_VERSION_MIN(7, 0, 0)
mode_
=
CUDNN_BATCHNORM_SPATIAL_PERSISTENT
;
#else
mode_
=
CUDNN_BATCHNORM_SPATIAL
;
//
#endif
#endif
CUDNN_ENFORCE
(
platform
::
dynload
::
cudnnSetTensorNdDescriptor
(
data_desc_
,
CudnnDataType
<
T
>::
type
,
...
...
python/paddle/fluid/layers/nn.py
浏览文件 @
4e3b5e72
...
...
@@ -9706,7 +9706,12 @@ def sequence_reverse(x, name=None):
return
out
def
affine_channel
(
x
,
scale
=
None
,
bias
=
None
,
data_layout
=
'NCHW'
,
name
=
None
):
def
affine_channel
(
x
,
scale
=
None
,
bias
=
None
,
data_layout
=
'NCHW'
,
name
=
None
,
act
=
None
):
"""
Applies a separate affine transformation to each channel of the input.
Useful for replacing spatial batch norm with its equivalent fixed
...
...
@@ -9725,6 +9730,7 @@ def affine_channel(x, scale=None, bias=None, data_layout='NCHW', name=None):
data_layout (string, default NCHW): NCHW or NHWC. If input is 2D
tensor, you can ignore data_layout.
name (str, default None): The name of this layer.
act (str, default None): Activation to be applied to the output of this layer.
Returns:
out (Variable): A tensor of the same shape and data layout with x.
...
...
@@ -9744,7 +9750,7 @@ def affine_channel(x, scale=None, bias=None, data_layout='NCHW', name=None):
'Bias'
:
bias
},
attrs
=
{
"data_layout"
:
data_layout
},
outputs
=
{
"Out"
:
out
})
return
out
return
helper
.
append_activation
(
pre_activation
)
def
similarity_focus
(
input
,
axis
,
indexes
,
name
=
None
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录