Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
dcb5a1ed
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看板
提交
dcb5a1ed
编写于
1月 23, 2018
作者:
Y
ying
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix ci.
上级
64606eaf
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
19 deletion
+30
-19
python/paddle/v2/dataset/wmt16.py
python/paddle/v2/dataset/wmt16.py
+9
-8
python/paddle/v2/fluid/layers/nn.py
python/paddle/v2/fluid/layers/nn.py
+5
-5
python/paddle/v2/fluid/layers/ops.py
python/paddle/v2/fluid/layers/ops.py
+14
-4
python/paddle/v2/fluid/tests/book/test_understand_sentiment_lstm.py
...dle/v2/fluid/tests/book/test_understand_sentiment_lstm.py
+2
-2
未找到文件。
python/paddle/v2/dataset/wmt16.py
浏览文件 @
dcb5a1ed
...
...
@@ -171,8 +171,9 @@ def train(src_dict_size, trg_dict_size, src_lang="en"):
callable: The train reader.
"""
assert
(
src_lang
in
[
"en"
,
"de"
],
(
"An error language type. Only support: "
"en (for English); de(for Germany)"
))
if
src_lang
not
in
[
"en"
,
"de"
]:
raise
ValueError
(
"An error language type. Only support: "
"en (for English); de(for Germany)."
)
src_dict_size
,
trg_dict_size
=
__get_dict_size
(
src_dict_size
,
trg_dict_size
,
src_lang
)
...
...
@@ -218,9 +219,9 @@ def test(src_dict_size, trg_dict_size, src_lang="en"):
callable: The test reader.
"""
assert
(
src_lang
in
[
"en"
,
"de"
],
(
"An error language type.
"
"Only support: en (for English); de(for Germany)"
)
)
if
src_lang
not
in
[
"en"
,
"de"
]:
raise
ValueError
(
"An error language type.
"
"Only support: en (for English); de(for Germany)."
)
src_dict_size
,
trg_dict_size
=
__get_dict_size
(
src_dict_size
,
trg_dict_size
,
src_lang
)
...
...
@@ -266,9 +267,9 @@ def validation(src_dict_size, trg_dict_size, src_lang="en"):
Returns:
callable: The validation reader.
"""
assert
(
src_lang
in
[
"en"
,
"de"
],
(
"An error language type.
"
"Only support: en (for English); de(for Germany)"
)
)
if
src_lang
not
in
[
"en"
,
"de"
]:
raise
ValueError
(
"An error language type.
"
"Only support: en (for English); de(for Germany)."
)
src_dict_size
,
trg_dict_size
=
__get_dict_size
(
src_dict_size
,
trg_dict_size
,
src_lang
)
...
...
python/paddle/v2/fluid/layers/nn.py
浏览文件 @
dcb5a1ed
...
...
@@ -2141,7 +2141,7 @@ def sequence_reshape(input, new_dim):
return
out
def
transpose
(
input
,
perm
,
name
=
None
):
def
transpose
(
x
,
perm
,
name
=
None
):
"""
**transpose Layer**
...
...
@@ -2161,19 +2161,19 @@ def transpose(input, perm, name=None):
.. code-block:: python
x = fluid.layers.data(name='x', shape=[5, 10, 15], dtype='float32')
x_transposed = layers.transpose(
input=
x, perm=[1, 0, 2])
x_transposed = layers.transpose(x, perm=[1, 0, 2])
"""
if
len
(
perm
)
!=
len
(
input
.
shape
):
if
len
(
perm
)
!=
len
(
x
.
shape
):
raise
ValueError
(
"Input(perm) is the permutation of dimensions of Input(input). "
"It's length shoud be equal to Input(input)'s rank."
)
helper
=
LayerHelper
(
'transpose'
,
**
locals
())
out
=
helper
.
create_tmp_variable
(
helper
.
input_dtype
()
)
out
=
helper
.
create_tmp_variable
(
x
.
dtype
)
helper
.
append_op
(
type
=
'transpose'
,
inputs
=
{
'X'
:
[
input
]},
inputs
=
{
'X'
:
[
x
]},
outputs
=
{
'Out'
:
[
out
]},
attrs
=
{
'axis'
:
perm
})
return
out
python/paddle/v2/fluid/layers/ops.py
浏览文件 @
dcb5a1ed
...
...
@@ -45,10 +45,20 @@ __activations__ = [
]
__all__
=
[
'mean'
,
'mul'
,
'reshape'
,
'scale'
,
'transpose'
,
'sigmoid_cross_entropy_with_logits'
,
'elementwise_add'
,
'elementwise_div'
,
'elementwise_sub'
,
'elementwise_mul'
,
'elementwise_max'
,
'elementwise_min'
,
'clip'
,
'clip_by_norm'
,
'sequence_softmax'
'mean'
,
'mul'
,
'reshape'
,
'scale'
,
'sigmoid_cross_entropy_with_logits'
,
'elementwise_add'
,
'elementwise_div'
,
'elementwise_sub'
,
'elementwise_mul'
,
'elementwise_max'
,
'elementwise_min'
,
'clip'
,
'clip_by_norm'
,
'sequence_softmax'
,
]
+
__activations__
for
_OP
in
set
(
__all__
):
...
...
python/paddle/v2/fluid/tests/book/test_understand_sentiment_lstm.py
浏览文件 @
dcb5a1ed
...
...
@@ -65,13 +65,13 @@ def lstm_net(dict_dim, class_dim=2, emb_dim=32, seq_len=80, batch_size=50):
emb
=
fluid
.
layers
.
embedding
(
input
=
data
,
size
=
[
dict_dim
,
emb_dim
])
emb
=
fluid
.
layers
.
reshape
(
x
=
emb
,
shape
=
[
batch_size
,
seq_len
,
emb_dim
])
emb
=
fluid
.
layers
.
transpose
(
x
=
emb
,
axis
=
[
1
,
0
,
2
])
emb
=
fluid
.
layers
.
transpose
(
x
=
emb
,
perm
=
[
1
,
0
,
2
])
c_pre_init
=
fluid
.
layers
.
fill_constant
(
dtype
=
emb
.
dtype
,
shape
=
[
batch_size
,
emb_dim
],
value
=
0.0
)
c_pre_init
.
stop_gradient
=
False
layer_1_out
=
lstm
(
emb
,
c_pre_init
=
c_pre_init
,
hidden_dim
=
emb_dim
)
layer_1_out
=
fluid
.
layers
.
transpose
(
x
=
layer_1_out
,
axis
=
[
1
,
0
,
2
])
layer_1_out
=
fluid
.
layers
.
transpose
(
x
=
layer_1_out
,
perm
=
[
1
,
0
,
2
])
prediction
=
fluid
.
layers
.
fc
(
input
=
layer_1_out
,
size
=
class_dim
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录