Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
a6ad9a16
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a6ad9a16
编写于
11月 10, 2016
作者:
X
xuwei06
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix unittest
Change-Id: Ic80845c892c96c37a0df0ddc433fe1aeaa5a9d1c
上级
bf6f690f
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
72 addition
and
15 deletion
+72
-15
paddle/gserver/layers/CostLayer.cpp
paddle/gserver/layers/CostLayer.cpp
+1
-1
paddle/math/BaseMatrix.cu
paddle/math/BaseMatrix.cu
+49
-4
paddle/math/BaseMatrix.h
paddle/math/BaseMatrix.h
+13
-0
python/paddle/trainer_config_helpers/layers.py
python/paddle/trainer_config_helpers/layers.py
+9
-10
未找到文件。
paddle/gserver/layers/CostLayer.cpp
浏览文件 @
a6ad9a16
...
...
@@ -605,7 +605,7 @@ public:
int
batchSize
=
input
->
getHeight
();
int
size
=
1
;
resizeOutput
(
batchSize
,
size
);
output_
.
value
->
sumRows
(
*
input
);
output_
.
value
->
sumRows
(
*
input
,
/* scaleSum= */
1
,
/* scaleDest= */
0
);
}
virtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
{
...
...
paddle/math/BaseMatrix.cu
浏览文件 @
a6ad9a16
...
...
@@ -1473,6 +1473,21 @@ int BaseMatrixT<real>::applyRow(Agg agg, Saver sv, BaseMatrixT& b) {
return
0
;
}
template
<
>
template
<
class
Agg
>
int
BaseMatrixT
<
real
>::
applyRow
(
Agg
agg
,
real
scaleDest
,
real
scaleAgg
,
BaseMatrixT
&
b
)
{
if
(
scaleDest
!=
0
)
{
applyRow
(
agg
,
base
::
binary
::
add2
(
scaleDest
,
scaleAgg
),
b
);
}
else
{
applyRow
(
agg
,
base
::
binary
::
second
(),
b
);
if
(
scaleAgg
!=
1
)
{
mulScalar
(
scaleAgg
);
}
}
return
0
;
}
template
<
>
template
<
class
Agg
,
class
Op
,
class
Saver
>
int
BaseMatrixT
<
real
>::
applyRow
(
Agg
agg
,
Op
op
,
Saver
sv
,
...
...
@@ -1490,6 +1505,21 @@ int BaseMatrixT<real>::applyRow(Agg agg, Op op, Saver sv,
return
0
;
}
template
<
>
template
<
class
Agg
,
class
Op
>
int
BaseMatrixT
<
real
>::
applyRow
(
Agg
agg
,
Op
op
,
real
scaleDest
,
real
scaleAgg
,
BaseMatrixT
&
b
,
BaseMatrixT
&
c
)
{
if
(
scaleDest
!=
0
)
{
applyRow
(
agg
,
op
,
base
::
binary
::
add2
(
scaleDest
,
scaleAgg
),
b
,
c
);
}
else
{
applyRow
(
agg
,
op
,
base
::
binary
::
second
(),
b
,
c
);
if
(
scaleAgg
!=
1
)
{
mulScalar
(
scaleAgg
);
}
}
return
0
;
}
template
<
>
template
<
class
Agg
>
int
BaseMatrixT
<
real
>::
applyCol
(
Agg
agg
,
BaseMatrixT
&
b
)
{
...
...
@@ -1518,9 +1548,24 @@ int BaseMatrixT<real>::applyCol(Agg agg, Saver sv, BaseMatrixT& b) {
return
0
;
}
template
<
>
template
<
class
Agg
>
int
BaseMatrixT
<
real
>::
applyCol
(
Agg
agg
,
real
scaleDest
,
real
scaleAgg
,
BaseMatrixT
&
b
)
{
if
(
scaleDest
!=
0
)
{
applyCol
(
agg
,
base
::
binary
::
add2
(
scaleDest
,
scaleAgg
),
b
);
}
else
{
applyCol
(
agg
,
base
::
binary
::
second
(),
b
);
if
(
scaleAgg
!=
1
)
{
mulScalar
(
scaleAgg
);
}
}
return
0
;
}
template
<
>
void
BaseMatrixT
<
real
>::
sumRows
(
BaseMatrixT
&
b
,
real
scaleSum
,
real
scaleDest
)
{
applyRow
(
aggregate
::
sum
(),
base
::
binary
::
add2
(
scaleDest
,
scaleSum
)
,
b
);
applyRow
(
aggregate
::
sum
(),
scaleDest
,
scaleSum
,
b
);
}
template
<
>
...
...
@@ -1550,21 +1595,21 @@ void BaseMatrixT<real>::minCols(BaseMatrixT& b) {
template
<
>
void
BaseMatrixT
<
real
>::
sumCols
(
BaseMatrixT
&
b
,
real
scaleSum
,
real
scaleDest
)
{
applyCol
(
aggregate
::
sum
(),
base
::
binary
::
add2
(
scaleDest
,
scaleSum
)
,
b
);
applyCol
(
aggregate
::
sum
(),
scaleDest
,
scaleSum
,
b
);
}
template
<
>
void
BaseMatrixT
<
real
>::
sumOfSquaredDiffs
(
BaseMatrixT
&
b
,
BaseMatrixT
&
c
,
real
scaleSum
,
real
scaleDest
)
{
applyRow
(
aggregate
::
sum
(),
base
::
binary
::
squaredDiff
(),
base
::
binary
::
add2
(
scaleDest
,
scaleSum
)
,
b
,
c
);
scaleDest
,
scaleSum
,
b
,
c
);
}
template
<
>
void
BaseMatrixT
<
real
>::
sumOfProducts
(
BaseMatrixT
&
b
,
BaseMatrixT
&
c
,
real
scaleSum
,
real
scaleDest
)
{
applyRow
(
aggregate
::
sum
(),
base
::
binary
::
mul
(),
base
::
binary
::
add2
(
scaleDest
,
scaleSum
)
,
b
,
c
);
scaleDest
,
scaleSum
,
b
,
c
);
}
template
class
BaseMatrixT
<
real
>;
...
...
paddle/math/BaseMatrix.h
浏览文件 @
a6ad9a16
...
...
@@ -317,6 +317,11 @@ public:
template
<
class
Agg
,
class
Op
,
class
Saver
>
int
applyRow
(
Agg
agg
,
Op
op
,
Saver
sv
,
BaseMatrixT
&
b
,
BaseMatrixT
&
c
);
// Same as the above with the special handing of sv=add2(scaleDest, scaleAgg)
template
<
class
Agg
,
class
Op
>
int
applyRow
(
Agg
agg
,
Op
op
,
real
scaleDest
,
real
scaleAgg
,
BaseMatrixT
&
b
,
BaseMatrixT
&
c
);
/**
* a aggregate expression that apply each row of matrix b.
*
...
...
@@ -329,6 +334,10 @@ public:
template
<
class
Agg
,
class
Saver
>
int
applyRow
(
Agg
agg
,
Saver
sv
,
BaseMatrixT
&
b
);
// Same as the above with the special handing of sv=add2(scaleDest, scaleAgg)
template
<
class
Agg
>
int
applyRow
(
Agg
agg
,
real
scaleDest
,
real
scaleAgg
,
BaseMatrixT
&
b
);
/**
* a aggregate expression that apply each column of matrix b.
*
...
...
@@ -352,6 +361,10 @@ public:
template
<
class
Agg
,
class
Saver
>
int
applyCol
(
Agg
agg
,
Saver
sv
,
BaseMatrixT
&
b
);
// Same as the above with the special handing of sv=add2(scaleDest, scaleAgg)
template
<
class
Agg
>
int
applyCol
(
Agg
agg
,
real
scaleDest
,
real
scaleAgg
,
BaseMatrixT
&
b
);
bool
useGpu
()
const
{
return
useGpu_
;
}
const
T
*
rowBuf
(
size_t
row
)
const
{
return
data_
+
width_
*
row
;
}
...
...
python/paddle/trainer_config_helpers/layers.py
浏览文件 @
a6ad9a16
...
...
@@ -29,7 +29,6 @@ except ImportError:
import
pickle
import
copy
<<<<<<<
0
ba0f02c685e52b14632f6b9bfca4321494505c7
__all__
=
[
"full_matrix_projection"
,
"AggregateLevel"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录