Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
9cb833cb
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看板
提交
9cb833cb
编写于
9月 01, 2017
作者:
C
caoying03
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename sequence into seq to keep a constant style.
上级
92c293ac
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
26 addition
and
26 deletion
+26
-26
python/paddle/trainer_config_helpers/layers.py
python/paddle/trainer_config_helpers/layers.py
+6
-6
python/paddle/trainer_config_helpers/tests/configs/file_list.sh
.../paddle/trainer_config_helpers/tests/configs/file_list.sh
+1
-1
python/paddle/trainer_config_helpers/tests/configs/protostr/test_cross_entropy_over_beam.protostr
...ts/configs/protostr/test_cross_entropy_over_beam.protostr
+11
-11
python/paddle/trainer_config_helpers/tests/configs/protostr/test_kmax_seq_socre_layer.protostr
...tests/configs/protostr/test_kmax_seq_socre_layer.protostr
+4
-4
python/paddle/trainer_config_helpers/tests/configs/test_cross_entropy_over_beam.py
...fig_helpers/tests/configs/test_cross_entropy_over_beam.py
+3
-3
python/paddle/trainer_config_helpers/tests/configs/test_kmax_seq_socre_layer.py
...config_helpers/tests/configs/test_kmax_seq_socre_layer.py
+1
-1
python/paddle/trainer_config_helpers/tests/configs/test_sub_nested_seq_select_layer.py
...helpers/tests/configs/test_sub_nested_seq_select_layer.py
+0
-0
未找到文件。
python/paddle/trainer_config_helpers/layers.py
浏览文件 @
9cb833cb
...
...
@@ -137,7 +137,7 @@ __all__ = [
'clip_layer'
,
'slice_projection'
,
'seq_slice_layer'
,
'kmax_seq
uence
_score_layer'
,
'kmax_seq_score_layer'
,
'img_pool3d_layer'
,
'scale_shift_layer'
,
'img_conv3d_layer'
,
...
...
@@ -5994,7 +5994,7 @@ def cross_entropy_over_beam(input, name=None):
Note that, if gold falls off the beam at search step t, then the cost is
calculated over the beam at step t.
This cost layer always works together with kmax_seq
uence
_score_layer,
This cost layer always works together with kmax_seq_score_layer,
sub_nested_seq_layer, and sequence_slice_layer to trim the input to form a
sub-search space.
...
...
@@ -6597,14 +6597,14 @@ def seq_slice_layer(input, starts, ends, name=None):
@
wrap_name_default
()
@
layer_support
()
def
kmax_seq
uence
_score_layer
(
input
,
name
=
None
,
beam_size
=
1
):
def
kmax_seq_score_layer
(
input
,
name
=
None
,
beam_size
=
1
):
"""
This layer accepts one input which are scores over a sequence or a nested
sequence, and returns indices of beam_size sequences with highest scores.
.. code-block:: python
kmax_indices = kmax_seq
uence
_score_layer(input=input_layer, beam_size)
kmax_indices = kmax_seq_score_layer(input=input_layer, beam_size)
:param name: The Layer Name.
...
...
@@ -6617,10 +6617,10 @@ def kmax_sequence_score_layer(input, name=None, beam_size=1):
:return: LayerOutput object.
:rtype: LayerOutput
"""
assert
isinstance
(
input
,
LayerOutput
),
(
"kmax_seq
uence
_score_layer "
assert
isinstance
(
input
,
LayerOutput
),
(
"kmax_seq_score_layer "
"accepts only one input."
)
assert
input
.
size
==
1
,
(
"input of kmax_seq
uence_score_layer is a score
"
"input of kmax_seq
_score_layer is a score
"
"over a sequence or a nested sequence, so its width must be 1."
)
Layer
(
...
...
python/paddle/trainer_config_helpers/tests/configs/file_list.sh
浏览文件 @
9cb833cb
...
...
@@ -8,7 +8,7 @@ test_spp_layer test_bilinear_interp test_maxout test_bi_grumemory math_ops
test_seq_concat_reshape test_pad test_smooth_l1 test_multiplex_layer
test_prelu_layer test_row_conv test_detection_output_layer test_multibox_loss_layer
test_recursive_topology test_gated_unit_layer test_clip_layer test_row_l2_norm_layer
test_kmax_seq_socre_layer test_s
eq_select_layers
test_scale_shift_layer
test_kmax_seq_socre_layer test_s
ub_nested_seq_select_layer
test_scale_shift_layer
test_seq_slice_layer test_cross_entropy_over_beam test_pooling3D_layer
test_conv3d_layer test_deconv3d_layer
)
...
...
python/paddle/trainer_config_helpers/tests/configs/protostr/test_cross_entropy_over_beam.protostr
浏览文件 @
9cb833cb
...
...
@@ -12,7 +12,7 @@ layers {
active_type: ""
}
layers {
name: "__kmax_seq
uence
_score_layer_0__"
name: "__kmax_seq_score_layer_0__"
type: "kmax_seq_score"
active_type: ""
inputs {
...
...
@@ -29,7 +29,7 @@ layers {
input_layer_name: "sentence_states"
}
inputs {
input_layer_name: "__kmax_seq
uence
_score_layer_0__"
input_layer_name: "__kmax_seq_score_layer_0__"
}
}
layers {
...
...
@@ -44,7 +44,7 @@ layers {
bias_parameter_name: "___fc_layer_0__.wbias"
}
layers {
name: "__kmax_seq
uence
_score_layer_1__"
name: "__kmax_seq_score_layer_1__"
type: "kmax_seq_score"
active_type: ""
inputs {
...
...
@@ -61,7 +61,7 @@ layers {
input_layer_name: "__sub_nested_seq_layer_0__"
}
inputs {
input_layer_name: "__kmax_seq
uence
_score_layer_1__"
input_layer_name: "__kmax_seq_score_layer_1__"
}
select_first: true
}
...
...
@@ -77,7 +77,7 @@ layers {
bias_parameter_name: "___fc_layer_1__.wbias"
}
layers {
name: "__kmax_seq
uence
_score_layer_2__"
name: "__kmax_seq_score_layer_2__"
type: "kmax_seq_score"
active_type: ""
inputs {
...
...
@@ -111,7 +111,7 @@ layers {
input_layer_name: "sentence_scores"
}
inputs {
input_layer_name: "__kmax_seq
uence
_score_layer_0__"
input_layer_name: "__kmax_seq_score_layer_0__"
}
inputs {
input_layer_name: "sentences_ids"
...
...
@@ -120,7 +120,7 @@ layers {
input_layer_name: "__fc_layer_0__"
}
inputs {
input_layer_name: "__kmax_seq
uence
_score_layer_1__"
input_layer_name: "__kmax_seq_score_layer_1__"
}
inputs {
input_layer_name: "start_ids"
...
...
@@ -129,7 +129,7 @@ layers {
input_layer_name: "__fc_layer_1__"
}
inputs {
input_layer_name: "__kmax_seq
uence
_score_layer_2__"
input_layer_name: "__kmax_seq_score_layer_2__"
}
inputs {
input_layer_name: "end_ids"
...
...
@@ -185,13 +185,13 @@ sub_models {
name: "root"
layer_names: "sentence_states"
layer_names: "sentence_scores"
layer_names: "__kmax_seq
uence
_score_layer_0__"
layer_names: "__kmax_seq_score_layer_0__"
layer_names: "__sub_nested_seq_layer_0__"
layer_names: "__fc_layer_0__"
layer_names: "__kmax_seq
uence
_score_layer_1__"
layer_names: "__kmax_seq_score_layer_1__"
layer_names: "__seq_slice_layer_0__"
layer_names: "__fc_layer_1__"
layer_names: "__kmax_seq
uence
_score_layer_2__"
layer_names: "__kmax_seq_score_layer_2__"
layer_names: "sentences_ids"
layer_names: "start_ids"
layer_names: "end_ids"
...
...
python/paddle/trainer_config_helpers/tests/configs/protostr/test_kmax_seq_socre_layer.protostr
浏览文件 @
9cb833cb
...
...
@@ -17,7 +17,7 @@ layers {
bias_parameter_name: "___fc_layer_0__.wbias"
}
layers {
name: "__kmax_seq
uence
_score_layer_0__"
name: "__kmax_seq_score_layer_0__"
type: "kmax_seq_score"
active_type: ""
inputs {
...
...
@@ -46,14 +46,14 @@ parameters {
initial_smart: false
}
input_layer_names: "input_seq"
output_layer_names: "__kmax_seq
uence
_score_layer_0__"
output_layer_names: "__kmax_seq_score_layer_0__"
sub_models {
name: "root"
layer_names: "input_seq"
layer_names: "__fc_layer_0__"
layer_names: "__kmax_seq
uence
_score_layer_0__"
layer_names: "__kmax_seq_score_layer_0__"
input_layer_names: "input_seq"
output_layer_names: "__kmax_seq
uence
_score_layer_0__"
output_layer_names: "__kmax_seq_score_layer_0__"
is_recurrent_layer_group: false
}
python/paddle/trainer_config_helpers/tests/configs/test_cross_entropy_over_beam.py
浏览文件 @
9cb833cb
...
...
@@ -7,14 +7,14 @@ beam_size = 5
# the first beam expansion.
sentence_states
=
data_layer
(
name
=
"sentence_states"
,
size
=
32
)
sentence_scores
=
data_layer
(
name
=
"sentence_scores"
,
size
=
1
)
topk_sentence_ids
=
kmax_seq
uence
_score_layer
(
topk_sentence_ids
=
kmax_seq_score_layer
(
input
=
sentence_scores
,
beam_size
=
beam_size
)
# the second beam expansion.
topk_sen
=
sub_nested_seq_layer
(
input
=
sentence_states
,
selected_indices
=
topk_sentence_ids
)
start_pos_scores
=
fc_layer
(
input
=
topk_sen
,
size
=
1
,
act
=
LinearActivation
())
topk_start_pos_ids
=
kmax_seq
uence
_score_layer
(
topk_start_pos_ids
=
kmax_seq_score_layer
(
input
=
sentence_scores
,
beam_size
=
beam_size
)
# the final beam expansion.
...
...
@@ -22,7 +22,7 @@ topk_start_spans = seq_slice_layer(
input
=
topk_sen
,
starts
=
topk_start_pos_ids
,
ends
=
None
)
end_pos_scores
=
fc_layer
(
input
=
topk_start_spans
,
size
=
1
,
act
=
LinearActivation
())
topk_end_pos_ids
=
kmax_seq
uence
_score_layer
(
topk_end_pos_ids
=
kmax_seq_score_layer
(
input
=
end_pos_scores
,
beam_size
=
beam_size
)
# define the cost
...
...
python/paddle/trainer_config_helpers/tests/configs/test_kmax_seq_socre_layer.py
浏览文件 @
9cb833cb
...
...
@@ -4,6 +4,6 @@ from paddle.trainer_config_helpers import *
data
=
data_layer
(
name
=
"input_seq"
,
size
=
128
)
scores
=
fc_layer
(
input
=
data
,
size
=
1
,
act
=
ExpActivation
())
kmax_seq_id
=
kmax_seq
uence
_score_layer
(
input
=
scores
,
beam_size
=
5
)
kmax_seq_id
=
kmax_seq_score_layer
(
input
=
scores
,
beam_size
=
5
)
outputs
(
kmax_seq_id
)
python/paddle/trainer_config_helpers/tests/configs/test_s
eq_select_layers
.py
→
python/paddle/trainer_config_helpers/tests/configs/test_s
ub_nested_seq_select_layer
.py
浏览文件 @
9cb833cb
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录