Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
076dcb9b
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看板
提交
076dcb9b
编写于
9月 08, 2017
作者:
Y
yangyaming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simpify the initialization for weights.
上级
53ab7e78
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
4 addition
and
11 deletion
+4
-11
paddle/operators/smooth_l1_loss_op.h
paddle/operators/smooth_l1_loss_op.h
+4
-11
未找到文件。
paddle/operators/smooth_l1_loss_op.h
浏览文件 @
076dcb9b
...
@@ -141,22 +141,12 @@ class SmoothL1LossGradKernel : public framework::OpKernel {
...
@@ -141,22 +141,12 @@ class SmoothL1LossGradKernel : public framework::OpKernel {
diff
.
device
(
place
)
=
EigenVector
<
T
>::
Flatten
(
*
in2
).
unaryExpr
(
diff
.
device
(
place
)
=
EigenVector
<
T
>::
Flatten
(
*
in2
).
unaryExpr
(
SmoothL1LossBackward
<
T
>
(
sigma2
));
SmoothL1LossBackward
<
T
>
(
sigma2
));
auto
*
out0
=
context
.
Output
<
Tensor
>
(
framework
::
GradVarName
(
"X"
));
auto
*
out1
=
context
.
Output
<
Tensor
>
(
framework
::
GradVarName
(
"Y"
));
// compute weights
// compute weights
Tensor
paddle_weights
;
Tensor
paddle_weights
;
paddle_weights
.
mutable_data
<
T
>
(
mat_dims
,
context
.
GetPlace
());
paddle_weights
.
mutable_data
<
T
>
(
mat_dims
,
context
.
GetPlace
());
auto
weights
=
EigenMatrix
<
T
>::
From
(
paddle_weights
);
auto
weights
=
EigenMatrix
<
T
>::
From
(
paddle_weights
);
// initialize to 1.0
// initialize to 1.0
if
(
platform
::
is_cpu_place
(
context
.
GetPlace
()))
{
weights
.
device
(
place
)
=
weights
.
constant
(
static_cast
<
T
>
(
1.0
));
weights
.
setConstant
(
static_cast
<
T
>
(
1.0
));
}
else
{
Tensor
paddle_cpu_weights
;
paddle_cpu_weights
.
mutable_data
<
T
>
(
mat_dims
,
platform
::
CPUPlace
());
EigenMatrix
<
T
>::
From
(
paddle_cpu_weights
).
setConstant
(
static_cast
<
T
>
(
1.0
));
paddle_weights
.
CopyFrom
<
T
>
(
paddle_cpu_weights
,
context
.
GetPlace
());
}
if
(
has_weight
)
{
if
(
has_weight
)
{
auto
inside_weight
=
EigenMatrix
<
T
>::
From
(
*
in0
,
mat_dims
);
auto
inside_weight
=
EigenMatrix
<
T
>::
From
(
*
in0
,
mat_dims
);
auto
outside_weight
=
EigenMatrix
<
T
>::
From
(
*
in1
,
mat_dims
);
auto
outside_weight
=
EigenMatrix
<
T
>::
From
(
*
in1
,
mat_dims
);
...
@@ -170,6 +160,9 @@ class SmoothL1LossGradKernel : public framework::OpKernel {
...
@@ -170,6 +160,9 @@ class SmoothL1LossGradKernel : public framework::OpKernel {
Eigen
::
array
<
int
,
2
>
({{
1
,
static_cast
<
int
>
(
cols
)}}))
*
Eigen
::
array
<
int
,
2
>
({{
1
,
static_cast
<
int
>
(
cols
)}}))
*
weights
*
diff_mat_view
;
weights
*
diff_mat_view
;
auto
*
out0
=
context
.
Output
<
Tensor
>
(
framework
::
GradVarName
(
"X"
));
auto
*
out1
=
context
.
Output
<
Tensor
>
(
framework
::
GradVarName
(
"Y"
));
if
(
out0
)
{
if
(
out0
)
{
out0
->
mutable_data
<
T
>
(
context
.
GetPlace
());
out0
->
mutable_data
<
T
>
(
context
.
GetPlace
());
auto
x_grad
=
EigenMatrix
<
T
>::
From
(
*
out0
,
mat_dims
);
auto
x_grad
=
EigenMatrix
<
T
>::
From
(
*
out0
,
mat_dims
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录