Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
6eba4b32
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看板
未验证
提交
6eba4b32
编写于
7月 12, 2018
作者:
Y
yuyang18
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix unittests after hide APIs
上级
818e0708
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
19 addition
and
20 deletion
+19
-20
python/paddle/fluid/tests/unittests/test_batch_norm_op.py
python/paddle/fluid/tests/unittests/test_batch_norm_op.py
+0
-1
python/paddle/fluid/tests/unittests/test_dynrnn_static_input.py
.../paddle/fluid/tests/unittests/test_dynrnn_static_input.py
+7
-7
python/paddle/fluid/tests/unittests/test_selected_rows.py
python/paddle/fluid/tests/unittests/test_selected_rows.py
+3
-3
python/paddle/fluid/tests/unittests/test_shrink_rnn_memory.py
...on/paddle/fluid/tests/unittests/test_shrink_rnn_memory.py
+2
-2
python/paddle/fluid/tests/unittests/test_tensor.py
python/paddle/fluid/tests/unittests/test_tensor.py
+7
-7
未找到文件。
python/paddle/fluid/tests/unittests/test_batch_norm_op.py
浏览文件 @
6eba4b32
...
...
@@ -129,7 +129,6 @@ def create_or_get_tensor(scope, var_name, var, place):
if
var
is
not
None
:
assert
isinstance
(
var
,
np
.
ndarray
)
tensor
.
set_recursive_sequence_lengths
([])
tensor
.
set_dims
(
var
.
shape
)
tensor
.
set
(
var
,
place
)
return
tensor
...
...
python/paddle/fluid/tests/unittests/test_dynrnn_static_input.py
浏览文件 @
6eba4b32
...
...
@@ -65,10 +65,10 @@ class TestDyRnnStaticInput(unittest.TestCase):
return
self
.
_lodtensor_to_ndarray
(
fetch_outs
[
0
])
def
_lodtensor_to_ndarray
(
self
,
lod_tensor
):
dims
=
lod_tensor
.
get_dims
()
dims
=
lod_tensor
.
shape
()
ndarray
=
np
.
zeros
(
shape
=
dims
).
astype
(
'float32'
)
for
i
in
xrange
(
np
.
product
(
dims
)):
ndarray
.
ravel
()[
i
]
=
lod_tensor
.
get_float_element
(
i
)
ndarray
.
ravel
()[
i
]
=
lod_tensor
.
_
get_float_element
(
i
)
return
ndarray
,
lod_tensor
.
recursive_sequence_lengths
()
def
build_graph
(
self
,
only_forward
=
False
):
...
...
@@ -185,19 +185,19 @@ class TestDyRnnStaticInput(unittest.TestCase):
actual_gradients
,
actual_lod
=
self
.
fetch_value
(
static_input_grad
)
static_input_shape
=
self
.
static_input_tensor
.
get_dims
()
static_input_shape
=
self
.
static_input_tensor
.
shape
()
numeric_gradients
=
np
.
zeros
(
shape
=
static_input_shape
).
astype
(
'float32'
)
# calculate numeric gradients
tensor_size
=
np
.
product
(
static_input_shape
)
for
i
in
xrange
(
tensor_size
):
origin
=
self
.
static_input_tensor
.
get_float_element
(
i
)
origin
=
self
.
static_input_tensor
.
_
get_float_element
(
i
)
x_pos
=
origin
+
self
.
_delta
self
.
static_input_tensor
.
set_float_element
(
i
,
x_pos
)
self
.
static_input_tensor
.
_
set_float_element
(
i
,
x_pos
)
y_pos
=
self
.
fetch_value
(
loss
)[
0
][
0
]
x_neg
=
origin
-
self
.
_delta
self
.
static_input_tensor
.
set_float_element
(
i
,
x_neg
)
self
.
static_input_tensor
.
_
set_float_element
(
i
,
x_neg
)
y_neg
=
self
.
fetch_value
(
loss
)[
0
][
0
]
self
.
static_input_tensor
.
set_float_element
(
i
,
origin
)
self
.
static_input_tensor
.
_
set_float_element
(
i
,
origin
)
numeric_gradients
.
ravel
()[
i
]
=
(
y_pos
-
y_neg
)
/
self
.
_delta
/
2
self
.
assertTrue
(
np
.
allclose
(
actual_gradients
,
numeric_gradients
,
0.001
))
self
.
assertTrue
(
...
...
python/paddle/fluid/tests/unittests/test_selected_rows.py
浏览文件 @
6eba4b32
...
...
@@ -40,12 +40,12 @@ class TestSelectedRows(unittest.TestCase):
# compare tensor
self
.
assertAlmostEqual
(
2.0
,
selected_rows
.
get_tensor
().
get_float_element
(
0
))
selected_rows
.
get_tensor
().
_
get_float_element
(
0
))
self
.
assertAlmostEqual
(
1.0
,
selected_rows
.
get_tensor
().
get_float_element
(
1
))
selected_rows
.
get_tensor
().
_
get_float_element
(
1
))
self
.
assertAlmostEqual
(
4.0
,
selected_rows
.
get_tensor
().
get_float_element
(
2
*
row_numel
+
8
))
selected_rows
.
get_tensor
().
_
get_float_element
(
2
*
row_numel
+
8
))
if
__name__
==
"__main__"
:
...
...
python/paddle/fluid/tests/unittests/test_shrink_rnn_memory.py
浏览文件 @
6eba4b32
...
...
@@ -45,8 +45,8 @@ class TestShrinkRNNMemoryBase(unittest.TestCase):
def
sum_lodtensor
(
self
,
tensor
):
sum_res
=
0.0
for
i
in
xrange
(
np
.
product
(
tensor
.
get_dims
())):
sum_res
+=
tensor
.
get_float_element
(
i
)
for
i
in
xrange
(
np
.
product
(
tensor
.
shape
())):
sum_res
+=
tensor
.
_
get_float_element
(
i
)
return
sum_res
...
...
python/paddle/fluid/tests/unittests/test_tensor.py
浏览文件 @
6eba4b32
...
...
@@ -25,7 +25,7 @@ class TestTensor(unittest.TestCase):
tensor
=
var
.
get_tensor
()
tensor
.
set_dims
([
1000
,
784
])
tensor
.
_
set_dims
([
1000
,
784
])
tensor
.
_alloc_int
(
place
)
tensor_array
=
numpy
.
array
(
tensor
)
self
.
assertEqual
((
1000
,
784
),
tensor_array
.
shape
)
...
...
@@ -44,7 +44,7 @@ class TestTensor(unittest.TestCase):
tensor
=
var
.
get_tensor
()
tensor
.
set_dims
([
1000
,
784
])
tensor
.
_
set_dims
([
1000
,
784
])
tensor
.
_alloc_float
(
place
)
tensor_array
=
numpy
.
array
(
tensor
)
...
...
@@ -63,7 +63,7 @@ class TestTensor(unittest.TestCase):
var_lod
=
scope
.
var
(
"test_lod_tensor"
)
lod_tensor
=
var_lod
.
get_tensor
()
lod_tensor
.
set_dims
([
4
,
4
,
6
])
lod_tensor
.
_
set_dims
([
4
,
4
,
6
])
lod_tensor
.
_alloc_int
(
place
)
array
=
numpy
.
array
(
lod_tensor
)
array
[
0
,
0
,
0
]
=
3
...
...
@@ -84,7 +84,7 @@ class TestTensor(unittest.TestCase):
var_lod
=
scope
.
var
(
"test_lod_tensor"
)
lod_tensor
=
var_lod
.
get_tensor
()
lod_tensor
.
set_dims
([
5
,
2
,
3
,
4
])
lod_tensor
.
_
set_dims
([
5
,
2
,
3
,
4
])
lod_tensor
.
_alloc_float
(
place
)
tensor_array
=
numpy
.
array
(
lod_tensor
)
...
...
@@ -108,7 +108,7 @@ class TestTensor(unittest.TestCase):
lod_py
=
[[
2
,
1
],
[
1
,
2
,
2
]]
lod_tensor
=
core
.
LoDTensor
()
lod_tensor
.
set_dims
([
5
,
2
,
3
,
4
])
lod_tensor
.
_
set_dims
([
5
,
2
,
3
,
4
])
lod_tensor
.
set_recursive_sequence_lengths
(
lod_py
)
lod_tensor
.
_alloc_float
(
place
)
tensor_array
=
numpy
.
array
(
lod_tensor
)
...
...
@@ -128,7 +128,7 @@ class TestTensor(unittest.TestCase):
lod_py
=
[[
2
,
1
],
[
1
,
2
,
2
]]
lod_tensor
=
core
.
LoDTensor
()
lod_tensor
.
set_dims
([
5
,
2
,
3
,
4
])
lod_tensor
.
_
set_dims
([
5
,
2
,
3
,
4
])
lod_tensor
.
set_recursive_sequence_lengths
(
lod_py
)
lod_tensor
.
_alloc_float
(
place
)
tensor_array
=
numpy
.
array
(
lod_tensor
)
...
...
@@ -148,7 +148,7 @@ class TestTensor(unittest.TestCase):
tensor
=
var
.
get_tensor
()
tensor
.
set_dims
([
0
,
1
])
tensor
.
_
set_dims
([
0
,
1
])
tensor
.
_alloc_float
(
place
)
tensor_array
=
numpy
.
array
(
tensor
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录