Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
溜达小灰鼠
Paddle
提交
2e1cd331
P
Paddle
项目概览
溜达小灰鼠
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2e1cd331
编写于
11月 17, 2017
作者:
R
ranqiu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update dot_prod_layer
上级
aa250718
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
66 addition
and
5 deletion
+66
-5
doc/api/v2/config/layer.rst
doc/api/v2/config/layer.rst
+10
-0
paddle/gserver/layers/DotProdLayer.cpp
paddle/gserver/layers/DotProdLayer.cpp
+4
-2
paddle/gserver/tests/test_LayerGrad.cpp
paddle/gserver/tests/test_LayerGrad.cpp
+1
-1
python/paddle/trainer/config_parser.py
python/paddle/trainer/config_parser.py
+4
-1
python/paddle/trainer_config_helpers/tests/configs/file_list.sh
.../paddle/trainer_config_helpers/tests/configs/file_list.sh
+2
-1
python/paddle/trainer_config_helpers/tests/configs/protostr/test_dot_prod_layer.protostr
...lpers/tests/configs/protostr/test_dot_prod_layer.protostr
+38
-0
python/paddle/trainer_config_helpers/tests/configs/test_dot_prod_layer.py
...ainer_config_helpers/tests/configs/test_dot_prod_layer.py
+7
-0
未找到文件。
doc/api/v2/config/layer.rst
浏览文件 @
2e1cd331
...
...
@@ -335,6 +335,16 @@ bilinear_interp
.. autoclass:: paddle.v2.layer.bilinear_interp
:noindex:
dot_prod
---------
.. autoclass:: paddle.v2.layer.dot_prod
:noindex:
out_prod
--------
.. autoclass:: paddle.v2.layer.out_prod
:noindex:
power
-----
.. autoclass:: paddle.v2.layer.power
...
...
paddle/gserver/layers/DotProdLayer.cpp
浏览文件 @
2e1cd331
...
...
@@ -20,7 +20,7 @@ limitations under the License. */
namespace
paddle
{
/**
* @brief A layer for computing the dot product of two vectors
* @brief A layer for computing the dot product of two vectors
.
* Input1: vector (batchSize * dim)
* Input2: vector (batchSize * dim)
* Output: a matrix: (batchSize * 1)
...
...
@@ -46,7 +46,8 @@ bool DotProdLayer::init(const LayerMap& layerMap,
Layer
::
init
(
layerMap
,
parameterMap
);
CHECK_EQ
(
inputLayers_
.
size
(),
2U
);
CHECK_EQ
(
1
,
getSize
())
<<
"Dimension mismatch"
;
CHECK_EQ
(
1UL
,
getSize
())
<<
"The output dimensionality of this layer should be fixed to 1."
;
return
true
;
}
...
...
@@ -59,6 +60,7 @@ void DotProdLayer::forward(PassType passType) {
size_t
batchSize
=
inV0
->
getHeight
();
CHECK_EQ
(
inV1
->
getHeight
(),
batchSize
);
CHECK_EQ
(
inV0
->
getWidth
(),
inV1
->
getWidth
());
{
REGISTER_TIMER_INFO
(
"FwResetTimer"
,
getName
().
c_str
());
...
...
paddle/gserver/tests/test_LayerGrad.cpp
浏览文件 @
2e1cd331
...
...
@@ -1092,7 +1092,7 @@ TEST(Layer, DotProdLayer) {
config
.
layerConfig
.
add_inputs
();
for
(
auto
useGpu
:
{
false
,
true
})
{
testLayerGrad
(
config
,
"dot_prod"
,
10
0
,
false
,
useGpu
);
testLayerGrad
(
config
,
"dot_prod"
,
10
,
false
,
useGpu
);
}
}
...
...
python/paddle/trainer/config_parser.py
浏览文件 @
2e1cd331
...
...
@@ -3214,7 +3214,10 @@ class DotProdLayer(LayerBase):
def
__init__
(
self
,
name
,
inputs
,
device
=
None
):
super
(
DotProdLayer
,
self
).
__init__
(
name
,
'dot_prod'
,
0
,
inputs
,
device
=
device
)
config_assert
(
len
(
inputs
)
==
2
,
'DotProdLayer must have 2 inputs'
)
config_assert
(
len
(
inputs
)
==
2
,
'DotProdLayer must have 2 inputs.'
)
config_assert
(
self
.
get_input_layer
(
0
).
size
==
self
.
get_input_layer
(
1
).
size
,
"Two inputs should have the same size."
)
self
.
set_layer_size
(
1
)
...
...
python/paddle/trainer_config_helpers/tests/configs/file_list.sh
浏览文件 @
2e1cd331
...
...
@@ -10,6 +10,7 @@ test_prelu_layer test_row_conv test_detection_output_layer test_multibox_loss_la
test_recursive_topology test_gated_unit_layer test_clip_layer test_row_l2_norm_layer
test_kmax_seq_socre_layer test_sub_nested_seq_select_layer test_scale_shift_layer
test_seq_slice_layer test_cross_entropy_over_beam test_roi_pool_layer test_pooling3D_layer
test_conv3d_layer test_deconv3d_layer test_BatchNorm3D test_resize_layer test_scale_sub_region_layer
)
test_conv3d_layer test_deconv3d_layer test_BatchNorm3D test_resize_layer test_scale_sub_region_layer
test_dot_prod_layer
)
export
whole_configs
=(
test_split_datasource
)
python/paddle/trainer_config_helpers/tests/configs/protostr/test_dot_prod_layer.protostr
0 → 100644
浏览文件 @
2e1cd331
type: "nn"
layers {
name: "vector1"
type: "data"
size: 10
active_type: ""
}
layers {
name: "vector2"
type: "data"
size: 10
active_type: ""
}
layers {
name: "__dot_prod_layer_0__"
type: "dot_prod"
size: 1
active_type: ""
inputs {
input_layer_name: "vector1"
}
inputs {
input_layer_name: "vector2"
}
}
input_layer_names: "vector1"
input_layer_names: "vector2"
output_layer_names: "__dot_prod_layer_0__"
sub_models {
name: "root"
layer_names: "vector1"
layer_names: "vector2"
layer_names: "__dot_prod_layer_0__"
input_layer_names: "vector1"
input_layer_names: "vector2"
output_layer_names: "__dot_prod_layer_0__"
is_recurrent_layer_group: false
}
python/paddle/trainer_config_helpers/tests/configs/test_dot_prod_layer.py
0 → 100644
浏览文件 @
2e1cd331
from
paddle.trainer_config_helpers
import
*
vec1
=
data_layer
(
name
=
'vector1'
,
size
=
10
)
vec2
=
data_layer
(
name
=
'vector2'
,
size
=
10
)
dot_product
=
dot_prod_layer
(
input1
=
vec1
,
input2
=
vec2
)
outputs
(
dot_product
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录