Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
f13f1f1c
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f13f1f1c
编写于
2月 24, 2017
作者:
Q
qiaolongfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use test_layer instead of layer_test
上级
61f56fc0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
51 addition
and
6 deletion
+51
-6
python/paddle/v2/tests/test_layer.py
python/paddle/v2/tests/test_layer.py
+51
-6
未找到文件。
python/paddle/v2/tests/test_layer.py
浏览文件 @
f13f1f1c
...
@@ -51,12 +51,57 @@ class CostLayerTest(unittest.TestCase):
...
@@ -51,12 +51,57 @@ class CostLayerTest(unittest.TestCase):
cost10
=
layer
.
sum_cost
(
input
=
inference
)
cost10
=
layer
.
sum_cost
(
input
=
inference
)
cost11
=
layer
.
huber_cost
(
input
=
score
,
label
=
label
)
cost11
=
layer
.
huber_cost
(
input
=
score
,
label
=
label
)
print
dir
(
layer
)
print
layer
.
parse_network
(
cost1
,
cost2
)
layer
.
parse_network
(
cost1
,
cost2
)
print
layer
.
parse_network
(
cost3
,
cost4
)
print
dir
(
layer
)
print
layer
.
parse_network
(
cost5
,
cost6
)
#print layer.parse_network(cost3, cost4)
print
layer
.
parse_network
(
cost7
,
cost8
,
cost9
,
cost10
,
cost11
)
#print layer.parse_network(cost5, cost6)
#print layer.parse_network(cost7, cost8, cost9, cost10, cost11)
class
RNNTest
(
unittest
.
TestCase
):
def
test_simple_rnn
(
self
):
dict_dim
=
10
word_dim
=
8
hidden_dim
=
8
def
test_old_rnn
():
def
step
(
y
):
mem
=
conf_helps
.
memory
(
name
=
"rnn_state"
,
size
=
hidden_dim
)
out
=
conf_helps
.
fc_layer
(
input
=
[
y
,
mem
],
size
=
hidden_dim
,
act
=
activation
.
Tanh
(),
bias_attr
=
True
,
name
=
"rnn_state"
)
return
out
def
test
():
data1
=
conf_helps
.
data_layer
(
name
=
"word"
,
size
=
dict_dim
)
embd
=
conf_helps
.
embedding_layer
(
input
=
data1
,
size
=
word_dim
)
conf_helps
.
recurrent_group
(
name
=
"rnn"
,
step
=
step
,
input
=
embd
)
return
str
(
parse_network
(
test
))
def
test_new_rnn
():
def
new_step
(
y
):
mem
=
layer
.
memory
(
name
=
"rnn_state"
,
size
=
hidden_dim
)
out
=
layer
.
fc
(
input
=
[
mem
],
step_input
=
y
,
size
=
hidden_dim
,
act
=
activation
.
Tanh
(),
bias_attr
=
True
,
name
=
"rnn_state"
)
return
out
.
to_proto
(
dict
())
data1
=
layer
.
data
(
name
=
"word"
,
type
=
data_type
.
integer_value
(
dict_dim
))
embd
=
layer
.
embedding
(
input
=
data1
,
size
=
word_dim
)
rnn_layer
=
layer
.
recurrent_group
(
name
=
"rnn"
,
step
=
new_step
,
input
=
embd
)
return
str
(
layer
.
parse_network
(
rnn_layer
))
diff
=
difflib
.
unified_diff
(
test_old_rnn
().
splitlines
(
1
),
test_new_rnn
().
splitlines
(
1
))
print
''
.
join
(
diff
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录