Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
夏有凉风,冬有雪
Paddle
提交
d7a9bb6e
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,发现更多精彩内容 >>
提交
d7a9bb6e
编写于
12月 21, 2017
作者:
L
Luo Tao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add python wrap for sequence_first/last_step
上级
22022017
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
5 deletion
+12
-5
python/paddle/v2/fluid/layers/nn.py
python/paddle/v2/fluid/layers/nn.py
+9
-1
python/paddle/v2/fluid/tests/book/test_machine_translation.py
...on/paddle/v2/fluid/tests/book/test_machine_translation.py
+1
-1
python/paddle/v2/fluid/tests/test_dyn_rnn.py
python/paddle/v2/fluid/tests/test_dyn_rnn.py
+2
-3
未找到文件。
python/paddle/v2/fluid/layers/nn.py
浏览文件 @
d7a9bb6e
...
...
@@ -13,7 +13,7 @@ __all__ = [
'crf_decoding'
,
'cos_sim'
,
'cross_entropy'
,
'square_error_cost'
,
'accuracy'
,
'chunk_eval'
,
'sequence_conv'
,
'conv2d'
,
'sequence_pool'
,
'pool2d'
,
'batch_norm'
,
'beam_search_decode'
,
'conv2d_transpose'
,
'sequence_expand'
,
'lstm_unit'
,
'reduce_sum'
'lstm_unit'
,
'reduce_sum'
,
'sequence_first_step'
,
'sequence_last_step'
]
...
...
@@ -583,6 +583,14 @@ def sequence_pool(input, pool_type, **kwargs):
return
pool_out
def
sequence_first_step
(
input
,
**
kwargs
):
return
sequence_pool
(
input
=
input
,
pool_type
=
"first"
)
def
sequence_last_step
(
input
,
**
kwargs
):
return
sequence_pool
(
input
=
input
,
pool_type
=
"last"
)
def
pool2d
(
input
,
pool_size
,
pool_type
,
...
...
python/paddle/v2/fluid/tests/book/test_machine_translation.py
浏览文件 @
d7a9bb6e
...
...
@@ -33,7 +33,7 @@ def encoder_decoder():
fc1
=
fluid
.
layers
.
fc
(
input
=
src_embedding
,
size
=
hidden_dim
*
4
,
act
=
'tanh'
)
lstm_hidden0
,
lstm_0
=
layers
.
dynamic_lstm
(
input
=
fc1
,
size
=
hidden_dim
*
4
)
encoder_out
=
layers
.
sequence_
pool
(
input
=
lstm_hidden0
,
pool_type
=
"last"
)
encoder_out
=
layers
.
sequence_
last_step
(
input
=
lstm_hidden0
)
# decoder
trg_language_word
=
layers
.
data
(
...
...
python/paddle/v2/fluid/tests/test_dyn_rnn.py
浏览文件 @
d7a9bb6e
...
...
@@ -63,8 +63,7 @@ class TestDynRNN(unittest.TestCase):
all_timesteps
=
fluid
.
layers
.
array_to_lod_tensor
(
x
=
out
,
table
=
rank_table
)
last
=
fluid
.
layers
.
sequence_pool
(
input
=
all_timesteps
,
pool_type
=
'last'
)
last
=
fluid
.
layers
.
sequence_last_step
(
input
=
all_timesteps
)
logits
=
fluid
.
layers
.
fc
(
input
=
last
,
size
=
1
,
act
=
None
)
loss
=
fluid
.
layers
.
sigmoid_cross_entropy_with_logits
(
x
=
logits
,
label
=
label
)
...
...
@@ -101,7 +100,7 @@ class TestDynRNN(unittest.TestCase):
rnn
.
update_memory
(
mem
,
out_
)
rnn
.
output
(
out_
)
last
=
fluid
.
layers
.
sequence_
pool
(
input
=
rnn
(),
pool_type
=
'last'
)
last
=
fluid
.
layers
.
sequence_
last_step
(
input
=
rnn
()
)
logits
=
fluid
.
layers
.
fc
(
input
=
last
,
size
=
1
,
act
=
None
)
label
=
fluid
.
layers
.
data
(
name
=
'label'
,
shape
=
[
1
],
dtype
=
'float32'
)
loss
=
fluid
.
layers
.
sigmoid_cross_entropy_with_logits
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录