Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
42f47d49
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
1 年多 前同步成功
通知
696
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看板
提交
42f47d49
编写于
6月 02, 2017
作者:
Q
qingqing01
提交者:
GitHub
6月 02, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2267 from pkuyym/fix-2265
Add scale factor for smoothL1 and smoothL1Bp
上级
68c68ec9
7ee942bb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
10 deletion
+12
-10
paddle/gserver/layers/CostLayer.cpp
paddle/gserver/layers/CostLayer.cpp
+4
-4
paddle/math/Matrix.cpp
paddle/math/Matrix.cpp
+4
-2
paddle/math/Matrix.h
paddle/math/Matrix.h
+4
-4
未找到文件。
paddle/gserver/layers/CostLayer.cpp
浏览文件 @
42f47d49
...
...
@@ -217,10 +217,10 @@ void SmoothL1CostLayer::forwardImp(Matrix& output,
targetCpu
->
copyFrom
(
target
);
outputCpu
->
copyFrom
(
output
);
labelCpu
->
copyFrom
(
*
label
.
value
);
targetCpu
->
smoothL1
(
*
outputCpu
,
*
labelCpu
);
targetCpu
->
smoothL1
(
*
outputCpu
,
*
labelCpu
,
1.0
);
target
.
copyFrom
(
*
targetCpu
);
}
else
{
target
.
smoothL1
(
output
,
*
label
.
value
);
target
.
smoothL1
(
output
,
*
label
.
value
,
1.0
);
}
}
...
...
@@ -238,10 +238,10 @@ void SmoothL1CostLayer::backwardImp(Matrix& output,
outputGCpu
->
copyFrom
(
outputG
);
outputCpu
->
copyFrom
(
output
);
labelCpu
->
copyFrom
(
*
label
.
value
);
outputGCpu
->
smoothL1Bp
(
*
outputCpu
,
*
labelCpu
);
outputGCpu
->
smoothL1Bp
(
*
outputCpu
,
*
labelCpu
,
1.0
);
outputG
.
copyFrom
(
*
outputGCpu
);
}
else
{
outputG
.
smoothL1Bp
(
output
,
*
label
.
value
);
outputG
.
smoothL1Bp
(
output
,
*
label
.
value
,
1.0
);
}
}
...
...
paddle/math/Matrix.cpp
浏览文件 @
42f47d49
...
...
@@ -3606,7 +3606,7 @@ void CpuMatrix::sumOfSquaresBp(Matrix& output, Matrix& label) {
}
}
void
CpuMatrix
::
smoothL1
(
Matrix
&
output
,
Matrix
&
label
)
{
void
CpuMatrix
::
smoothL1
(
Matrix
&
output
,
Matrix
&
label
,
real
destScale
)
{
CHECK
(
output
.
useGpu_
==
false
&&
label
.
useGpu_
==
false
)
<<
"Matrix type are not equal"
;
...
...
@@ -3624,6 +3624,7 @@ void CpuMatrix::smoothL1(Matrix& output, Matrix& label) {
for
(
size_t
i
=
0
;
i
<
numSamples
;
++
i
,
out
+=
dim
,
lbl
+=
dim
)
{
for
(
size_t
j
=
0
;
j
<
dim
;
++
j
)
{
real
absVal
=
std
::
fabs
(
out
[
j
]
-
lbl
[
j
]);
cost
[
i
]
*=
destScale
;
if
(
absVal
<
1.0
)
cost
[
i
]
+=
0.5
*
absVal
*
absVal
;
else
...
...
@@ -3632,7 +3633,7 @@ void CpuMatrix::smoothL1(Matrix& output, Matrix& label) {
}
}
void
CpuMatrix
::
smoothL1Bp
(
Matrix
&
output
,
Matrix
&
label
)
{
void
CpuMatrix
::
smoothL1Bp
(
Matrix
&
output
,
Matrix
&
label
,
real
destScale
)
{
CHECK
(
output
.
useGpu_
==
false
&&
label
.
useGpu_
==
false
)
<<
"Matrix type are not equal"
;
...
...
@@ -3650,6 +3651,7 @@ void CpuMatrix::smoothL1Bp(Matrix& output, Matrix& label) {
for
(
size_t
i
=
0
;
i
<
numSamples
;
++
i
,
out
+=
dim
,
grad
+=
dim
,
lbl
+=
dim
)
{
for
(
size_t
j
=
0
;
j
<
dim
;
++
j
)
{
real
val
=
out
[
j
]
-
lbl
[
j
];
grad
[
j
]
*=
destScale
;
if
(
std
::
fabs
(
val
)
<
1
)
{
grad
[
j
]
+=
val
;
}
else
{
...
...
paddle/math/Matrix.h
浏览文件 @
42f47d49
...
...
@@ -789,11 +789,11 @@ public:
LOG
(
FATAL
)
<<
"Not implemented"
;
}
virtual
void
smoothL1
(
Matrix
&
output
,
Matrix
&
label
)
{
virtual
void
smoothL1
(
Matrix
&
output
,
Matrix
&
label
,
real
destScale
)
{
LOG
(
FATAL
)
<<
"Not implemented"
;
}
virtual
void
smoothL1Bp
(
Matrix
&
outputV
,
Matrix
&
label
)
{
virtual
void
smoothL1Bp
(
Matrix
&
outputV
,
Matrix
&
label
,
real
destScale
)
{
LOG
(
FATAL
)
<<
"Not implemented"
;
}
...
...
@@ -1736,8 +1736,8 @@ public:
/// gradient of sumOfSquares.
void
sumOfSquaresBp
(
Matrix
&
outputV
,
Matrix
&
label
);
void
smoothL1
(
Matrix
&
output
,
Matrix
&
label
);
void
smoothL1Bp
(
Matrix
&
output
,
Matrix
&
label
);
void
smoothL1
(
Matrix
&
output
,
Matrix
&
label
,
real
destScale
);
void
smoothL1Bp
(
Matrix
&
output
,
Matrix
&
label
,
real
destScale
);
void
tanh
(
Matrix
&
output
);
void
tanhDerivative
(
Matrix
&
output
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录