Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0ac72988
提交
0ac72988
authored
5月 21, 2021
作者:
Hector
提交者:
Thomas Wiecki
6月 07, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix typos in tests
上级
bbbbfcb5
隐藏空白字符变更
内嵌
并排
正在显示
31 个修改的文件
包含
47 行增加
和
47 行删除
+47
-47
test_pfunc.py
tests/compile/function/test_pfunc.py
+1
-1
test_types.py
tests/compile/function/test_types.py
+1
-1
test_abstractconv.py
tests/gpuarray/test_abstractconv.py
+2
-2
test_basic_ops.py
tests/gpuarray/test_basic_ops.py
+1
-1
test_blocksparse.py
tests/gpuarray/test_blocksparse.py
+1
-1
test_dnn.py
tests/gpuarray/test_dnn.py
+1
-1
test_misc.py
tests/gpuarray/test_misc.py
+1
-1
test_opt.py
tests/gpuarray/test_opt.py
+4
-4
test_reduction.py
tests/gpuarray/test_reduction.py
+2
-2
test_scan.py
tests/gpuarray/test_scan.py
+1
-1
test_op.py
tests/graph/test_op.py
+1
-1
test_types.py
tests/graph/test_types.py
+1
-1
test_vm.py
tests/link/test_vm.py
+1
-1
test_basic.py
tests/scan/test_basic.py
+3
-3
test_opt.py
tests/scan/test_opt.py
+2
-2
test_basic.py
tests/sparse/test_basic.py
+1
-1
test_utils.py
tests/sparse/test_utils.py
+3
-3
test_blocksparse.py
tests/tensor/nnet/test_blocksparse.py
+2
-2
test_conv.py
tests/tensor/nnet/test_conv.py
+1
-1
test_neighbours.py
tests/tensor/nnet/test_neighbours.py
+1
-1
test_basic.py
tests/tensor/test_basic.py
+1
-1
test_gc.py
tests/tensor/test_gc.py
+1
-1
test_math_scipy.py
tests/tensor/test_math_scipy.py
+1
-1
test_mlp.py
tests/tensor/test_mlp.py
+2
-2
test_nlinalg.py
tests/tensor/test_nlinalg.py
+1
-1
test_sharedvar.py
tests/tensor/test_sharedvar.py
+2
-2
test_slinalg.py
tests/tensor/test_slinalg.py
+1
-1
test_utils.py
tests/tensor/test_utils.py
+3
-3
test_gradient.py
tests/test_gradient.py
+2
-2
test_rop.py
tests/test_rop.py
+1
-1
test_type.py
tests/typed_list/test_type.py
+1
-1
没有找到文件。
tests/compile/function/test_pfunc.py
浏览文件 @
0ac72988
...
@@ -710,7 +710,7 @@ class TestAliasingRules:
...
@@ -710,7 +710,7 @@ class TestAliasingRules:
# with the memory of normal python variables that the user uses.
# with the memory of normal python variables that the user uses.
#
#
# 2. shared variables are allocated in this memory space, as are the
# 2. shared variables are allocated in this memory space, as are the
# temporaries used for Function evalution.
# temporaries used for Function evalu
a
tion.
#
#
# 3. Physically, this managed memory space may be spread across the host,
# 3. Physically, this managed memory space may be spread across the host,
# on a GPU device(s), or even on a remote machine.
# on a GPU device(s), or even on a remote machine.
...
...
tests/compile/function/test_types.py
浏览文件 @
0ac72988
...
@@ -387,7 +387,7 @@ class TestFunction:
...
@@ -387,7 +387,7 @@ class TestFunction:
)
)
cpy
=
ori
.
copy
(
swap
=
swap
)
cpy
=
ori
.
copy
(
swap
=
swap
)
# run fu
ction several time
# run fu
nction several times
ori
(
1
),
cpy
(
1
),
cpy
(
2
)
ori
(
1
),
cpy
(
1
),
cpy
(
2
)
# assert same SharedVariable are update in different function
# assert same SharedVariable are update in different function
...
...
tests/gpuarray/test_abstractconv.py
浏览文件 @
0ac72988
...
@@ -37,7 +37,7 @@ class TestDnnConv2d(BaseTestConv2d):
...
@@ -37,7 +37,7 @@ class TestDnnConv2d(BaseTestConv2d):
def
setup_class
(
cls
):
def
setup_class
(
cls
):
super
()
.
setup_class
()
super
()
.
setup_class
()
cls
.
shared
=
staticmethod
(
gpuarray_shared_constructor
)
cls
.
shared
=
staticmethod
(
gpuarray_shared_constructor
)
# provide_shape is not used by the cuDNN impementation
# provide_shape is not used by the cuDNN imp
l
ementation
cls
.
provide_shape
=
[
False
]
cls
.
provide_shape
=
[
False
]
@pytest.mark.skipif
(
dnn_available
(
test_ctx_name
),
reason
=
dnn_available
.
msg
)
@pytest.mark.skipif
(
dnn_available
(
test_ctx_name
),
reason
=
dnn_available
.
msg
)
...
@@ -131,7 +131,7 @@ class TestDnnConv3d(BaseTestConv3d):
...
@@ -131,7 +131,7 @@ class TestDnnConv3d(BaseTestConv3d):
def
setup_class
(
cls
):
def
setup_class
(
cls
):
super
()
.
setup_class
()
super
()
.
setup_class
()
cls
.
shared
=
staticmethod
(
gpuarray_shared_constructor
)
cls
.
shared
=
staticmethod
(
gpuarray_shared_constructor
)
# provide_shape is not used by the cuDNN impementation
# provide_shape is not used by the cuDNN imp
l
ementation
cls
.
provide_shape
=
[
False
]
cls
.
provide_shape
=
[
False
]
@pytest.mark.skipif
(
dnn_available
(
test_ctx_name
),
reason
=
dnn_available
.
msg
)
@pytest.mark.skipif
(
dnn_available
(
test_ctx_name
),
reason
=
dnn_available
.
msg
)
...
...
tests/gpuarray/test_basic_ops.py
浏览文件 @
0ac72988
...
@@ -206,7 +206,7 @@ def makeTester(
...
@@ -206,7 +206,7 @@ def makeTester(
for
description
,
check
in
self
.
checks
.
items
():
for
description
,
check
in
self
.
checks
.
items
():
assert
check
(
inputs
,
variables
),
(
assert
check
(
inputs
,
variables
),
(
"Test
%
s::
%
s: Failed check:
%
s "
"(inputs were
%
s, ouputs were
%
s)"
"Test
%
s::
%
s: Failed check:
%
s "
"(inputs were
%
s, ou
t
puts were
%
s)"
)
%
(
self
.
op
,
testname
,
description
,
inputs
,
variables
)
)
%
(
self
.
op
,
testname
,
description
,
inputs
,
variables
)
Checker
.
__name__
=
name
Checker
.
__name__
=
name
...
...
tests/gpuarray/test_blocksparse.py
浏览文件 @
0ac72988
...
@@ -28,7 +28,7 @@ class TestBlockSparseGemvAndOuterGPUarray(TestBlockSparseGemvAndOuter):
...
@@ -28,7 +28,7 @@ class TestBlockSparseGemvAndOuterGPUarray(TestBlockSparseGemvAndOuter):
@pytest.mark.skip
(
@pytest.mark.skip
(
reason
=
"""
reason
=
"""
This test is temporarily disabled since we disabled the output_merge
This test is temporarily disabled since we disabled the output_merge
and alpha_merge optimizations for blocksparse due to brokeness.
and alpha_merge optimizations for blocksparse due to broken
n
ess.
Re-enable when those are re-added.
Re-enable when those are re-added.
"""
"""
)
)
...
...
tests/gpuarray/test_dnn.py
浏览文件 @
0ac72988
...
@@ -1284,7 +1284,7 @@ def run_conv_small_batched_vs_multicall(inputs_shape, filters_shape, batch_sub):
...
@@ -1284,7 +1284,7 @@ def run_conv_small_batched_vs_multicall(inputs_shape, filters_shape, batch_sub):
f
=
aesara
.
function
([],
[
conv
,
sub_conv_top
,
sub_conv_bottom
],
mode
=
mode_with_gpu
)
f
=
aesara
.
function
([],
[
conv
,
sub_conv_top
,
sub_conv_bottom
],
mode
=
mode_with_gpu
)
res_all
,
res_batch_top
,
res_batch_bottom
=
f
()
res_all
,
res_batch_top
,
res_batch_bottom
=
f
()
for
i
in
range
(
batch_sub
):
for
i
in
range
(
batch_sub
):
# Check first ouputs.
# Check first ou
t
puts.
utt
.
assert_allclose
(
res_batch_top
[
i
],
res_all
[
i
])
utt
.
assert_allclose
(
res_batch_top
[
i
],
res_all
[
i
])
# Then check last outputs.
# Then check last outputs.
p
=
batch_size
-
batch_sub
+
i
p
=
batch_size
-
batch_sub
+
i
...
...
tests/gpuarray/test_misc.py
浏览文件 @
0ac72988
# Test that normaly could be outside gpuarray, to have all gpuarray
# Test that normal
l
y could be outside gpuarray, to have all gpuarray
# tests in the same directory, we put them here.
# tests in the same directory, we put them here.
import
numpy
as
np
import
numpy
as
np
...
...
tests/gpuarray/test_opt.py
浏览文件 @
0ac72988
...
@@ -291,7 +291,7 @@ def test_local_gpualloc_empty():
...
@@ -291,7 +291,7 @@ def test_local_gpualloc_empty():
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
len
(
topo
)
==
1
assert
len
(
topo
)
==
1
assert
isinstance
(
topo
[
0
]
.
op
,
AllocEmpty
)
assert
isinstance
(
topo
[
0
]
.
op
,
AllocEmpty
)
# This return not initilized data, so we can only check the shape
# This return not initi
a
lized data, so we can only check the shape
assert
f
(
3
)
.
shape
==
(
3
,)
assert
f
(
3
)
.
shape
==
(
3
,)
assert
_check_stack_trace
(
f
)
assert
_check_stack_trace
(
f
)
...
@@ -302,7 +302,7 @@ def test_local_gpualloc_empty():
...
@@ -302,7 +302,7 @@ def test_local_gpualloc_empty():
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
len
(
topo
)
==
3
assert
len
(
topo
)
==
3
assert
isinstance
(
topo
[
0
]
.
op
,
GpuAllocEmpty
)
assert
isinstance
(
topo
[
0
]
.
op
,
GpuAllocEmpty
)
# This return not initilized data, so we can only check the shape
# This return not initi
a
lized data, so we can only check the shape
assert
f
(
3
)
.
shape
==
(
3
,)
assert
f
(
3
)
.
shape
==
(
3
,)
assert
_check_stack_trace
(
f
)
assert
_check_stack_trace
(
f
)
...
@@ -312,7 +312,7 @@ def test_local_gpualloc_empty():
...
@@ -312,7 +312,7 @@ def test_local_gpualloc_empty():
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
len
(
topo
)
==
3
assert
len
(
topo
)
==
3
assert
isinstance
(
topo
[
0
]
.
op
,
GpuAllocEmpty
)
assert
isinstance
(
topo
[
0
]
.
op
,
GpuAllocEmpty
)
# This return not initilized data, so we can only check the shape
# This return not initi
a
lized data, so we can only check the shape
assert
f
(
3
,
4
)
.
shape
==
(
3
,
4
)
assert
f
(
3
,
4
)
.
shape
==
(
3
,
4
)
assert
_check_stack_trace
(
f
)
assert
_check_stack_trace
(
f
)
...
@@ -550,7 +550,7 @@ def test_local_gpu_elemwise():
...
@@ -550,7 +550,7 @@ def test_local_gpu_elemwise():
utt
.
assert_allclose
(
f
(
a_v
,
b_v
,
c_v
),
a_v
+
b_v
+
c_v
)
utt
.
assert_allclose
(
f
(
a_v
,
b_v
,
c_v
),
a_v
+
b_v
+
c_v
)
assert
_check_stack_trace
(
f
)
assert
_check_stack_trace
(
f
)
return
# Not yet implemeted
return
# Not yet impleme
n
ted
# Test multiple output
# Test multiple output
a_s
=
aesara
.
scalar
.
float32
()
a_s
=
aesara
.
scalar
.
float32
()
a
=
fmatrix
()
a
=
fmatrix
()
...
...
tests/gpuarray/test_reduction.py
浏览文件 @
0ac72988
...
@@ -19,7 +19,7 @@ from tests.gpuarray.test_basic_ops import rand_gpuarray
...
@@ -19,7 +19,7 @@ from tests.gpuarray.test_basic_ops import rand_gpuarray
test_size
=
10000
test_size
=
10000
# NB: This order of "unsorted axes" is arbitrary and is here
# NB: This order of "unsorted axes" is arbitrary and is here
# just to have the same information
s
on profile output
# just to have the same information on profile output
# from one test to another.
# from one test to another.
unsorted_axes
=
(
2
,
4
,
0
,
3
,
1
)
unsorted_axes
=
(
2
,
4
,
0
,
3
,
1
)
...
@@ -88,7 +88,7 @@ class BaseTest:
...
@@ -88,7 +88,7 @@ class BaseTest:
pytest
.
skip
(
"No tensor ndim defined."
)
pytest
.
skip
(
"No tensor ndim defined."
)
if
self
.
tensor_size
<
0
or
self
.
tensor_size
>
5
:
if
self
.
tensor_size
<
0
or
self
.
tensor_size
>
5
:
pytest
.
skip
(
pytest
.
skip
(
"We allow from 0 (included) to 5 (inclued) dimensons for these tests."
"We allow from 0 (included) to 5 (inclu
d
ed) dimensons for these tests."
)
)
if
self
.
shape
is
None
:
if
self
.
shape
is
None
:
self
.
shape
=
self
.
get_shape
()
self
.
shape
=
self
.
get_shape
()
...
...
tests/gpuarray/test_scan.py
浏览文件 @
0ac72988
...
@@ -549,7 +549,7 @@ class ScanGpuTests:
...
@@ -549,7 +549,7 @@ class ScanGpuTests:
def
test_gpu_memory_usage
(
self
):
def
test_gpu_memory_usage
(
self
):
# This test validates that the memory usage of the defined aesara
# This test validates that the memory usage of the defined aesara
# function is reason
n
able when executed on the GPU. It checks for
# function is reasonable when executed on the GPU. It checks for
# a bug in which one of scan's optimization was not applied which
# a bug in which one of scan's optimization was not applied which
# made the scan node compute large and unnecessary outputs which
# made the scan node compute large and unnecessary outputs which
# brought memory usage on the GPU to ~12G.
# brought memory usage on the GPU to ~12G.
...
...
tests/graph/test_op.py
浏览文件 @
0ac72988
...
@@ -46,7 +46,7 @@ class MyType(Type):
...
@@ -46,7 +46,7 @@ class MyType(Type):
@staticmethod
@staticmethod
def
may_share_memory
(
a
,
b
):
def
may_share_memory
(
a
,
b
):
# As this represent a string and string are immutable, they
# As this represent a string and string are immutable, they
# never share memory in the DebugMode sen
c
e. This is needed as
# never share memory in the DebugMode sen
s
e. This is needed as
# Python reuse string internally.
# Python reuse string internally.
return
False
return
False
...
...
tests/graph/test_types.py
浏览文件 @
0ac72988
...
@@ -219,7 +219,7 @@ class TestEnumTypes:
...
@@ -219,7 +219,7 @@ class TestEnumTypes:
except
AttributeError
:
except
AttributeError
:
pass
pass
else
:
else
:
raise
Exception
(
"EnumList with invalid name should fail
d
."
)
raise
Exception
(
"EnumList with invalid name should fail."
)
try
:
try
:
EnumType
(
**
{
invalid_name
:
0
})
EnumType
(
**
{
invalid_name
:
0
})
...
...
tests/link/test_vm.py
浏览文件 @
0ac72988
...
@@ -411,7 +411,7 @@ def test_reallocation():
...
@@ -411,7 +411,7 @@ def test_reallocation():
x
=
scalar
(
"x"
)
x
=
scalar
(
"x"
)
y
=
scalar
(
"y"
)
y
=
scalar
(
"y"
)
z
=
tanh
(
3
*
x
+
y
)
+
cosh
(
x
+
5
*
y
)
z
=
tanh
(
3
*
x
+
y
)
+
cosh
(
x
+
5
*
y
)
# The functinality is currently implement for non lazy and non c VM only.
# The functi
o
nality is currently implement for non lazy and non c VM only.
for
linker
in
[
for
linker
in
[
VMLinker
(
allow_gc
=
False
,
lazy
=
False
,
use_cloop
=
False
),
VMLinker
(
allow_gc
=
False
,
lazy
=
False
,
use_cloop
=
False
),
VMLinker
(
allow_gc
=
True
,
lazy
=
False
,
use_cloop
=
False
),
VMLinker
(
allow_gc
=
True
,
lazy
=
False
,
use_cloop
=
False
),
...
...
tests/scan/test_basic.py
浏览文件 @
0ac72988
...
@@ -872,7 +872,7 @@ class TestScan:
...
@@ -872,7 +872,7 @@ class TestScan:
# a bit of explaining:
# a bit of explaining:
# due to the definition of sequences taps in scan, v_0[0] is
# due to the definition of sequences taps in scan, v_0[0] is
# actually v_0[-2], and v_0[1] is v_0[-1]. The values v_0[2]
# actually v_0[-2], and v_0[1] is v_0[-1]. The values v_0[2]
# and v_0[3] do not get u
es
d ( because you do not use v_0[t]
# and v_0[3] do not get u
se
d ( because you do not use v_0[t]
# in scan) which might seem strange, but then again why not use
# in scan) which might seem strange, but then again why not use
# v_0[t] instead of v_0[t-2] in a real application ??
# v_0[t] instead of v_0[t-2] in a real application ??
# also vx0[0] corresponds to vx0[-2], vx0[1] to vx0[-1]
# also vx0[0] corresponds to vx0[-2], vx0[1] to vx0[-1]
...
@@ -3267,7 +3267,7 @@ class TestScan:
...
@@ -3267,7 +3267,7 @@ class TestScan:
@pytest.mark.skip
(
@pytest.mark.skip
(
reason
=
"This test fails because not typed outputs_info "
reason
=
"This test fails because not typed outputs_info "
"are always give
d
the smallest dtype. There is "
"are always give
n
the smallest dtype. There is "
"no upcast of outputs_info in scan for now."
,
"no upcast of outputs_info in scan for now."
,
)
)
def
test_outputs_info_not_typed
(
self
):
def
test_outputs_info_not_typed
(
self
):
...
@@ -3639,7 +3639,7 @@ class TestScan:
...
@@ -3639,7 +3639,7 @@ class TestScan:
grad
(
scan_outputs
[
0
]
.
sum
(),
out_init
[
1
])
grad
(
scan_outputs
[
0
]
.
sum
(),
out_init
[
1
])
# Validate the conn
n
ection pattern is as it should be
# Validate the connection pattern is as it should be
node
=
scan_outputs
[
0
]
.
owner
node
=
scan_outputs
[
0
]
.
owner
connection_pattern
=
node
.
op
.
connection_pattern
(
node
)
connection_pattern
=
node
.
op
.
connection_pattern
(
node
)
expected_connection_pattern
=
[
expected_connection_pattern
=
[
...
...
tests/scan/test_opt.py
浏览文件 @
0ac72988
...
@@ -207,7 +207,7 @@ class TestPushOutScanOutputDot:
...
@@ -207,7 +207,7 @@ class TestPushOutScanOutputDot:
scan_node
=
[
scan_node
=
[
node
for
node
in
f_opt
.
maker
.
fgraph
.
toposort
()
if
isinstance
(
node
.
op
,
Scan
)
node
for
node
in
f_opt
.
maker
.
fgraph
.
toposort
()
if
isinstance
(
node
.
op
,
Scan
)
][
0
]
][
0
]
# NOTE: WHEN INFER_SHAPE IS REENABLED, BELOW THE SCAN MUST
# NOTE: WHEN INFER_SHAPE IS RE
-
ENABLED, BELOW THE SCAN MUST
# HAVE ONLY 1 OUTPUT.
# HAVE ONLY 1 OUTPUT.
assert
len
(
scan_node
.
op
.
outputs
)
==
2
assert
len
(
scan_node
.
op
.
outputs
)
==
2
assert
not
isinstance
(
scan_node
.
op
.
outputs
[
0
],
Dot
)
assert
not
isinstance
(
scan_node
.
op
.
outputs
[
0
],
Dot
)
...
@@ -282,7 +282,7 @@ class TestPushOutSumOfDot:
...
@@ -282,7 +282,7 @@ class TestPushOutSumOfDot:
#
#
# 'dim' has been reduced from 1000 to 5 to make the test run faster
# 'dim' has been reduced from 1000 to 5 to make the test run faster
# Parameters from an actual machine tranlation run
# Parameters from an actual machine tran
s
lation run
batch_size
=
80
batch_size
=
80
seq_len
=
50
seq_len
=
50
dim
=
5
dim
=
5
...
...
tests/sparse/test_basic.py
浏览文件 @
0ac72988
...
@@ -2728,7 +2728,7 @@ def _hv_switch(op, expected_function):
...
@@ -2728,7 +2728,7 @@ def _hv_switch(op, expected_function):
:Parameters:
:Parameters:
- `op`: HStack or VStack class.
- `op`: HStack or VStack class.
- `expected_function`: function from scipy for compar
a
ison.
- `expected_function`: function from scipy for comparison.
"""
"""
class
TestXStack
(
_TestHVStack
):
class
TestXStack
(
_TestHVStack
):
...
...
tests/sparse/test_utils.py
浏览文件 @
0ac72988
...
@@ -9,7 +9,7 @@ from tests.sparse.test_basic import as_sparse_format
...
@@ -9,7 +9,7 @@ from tests.sparse.test_basic import as_sparse_format
def
test_hash_from_sparse
():
def
test_hash_from_sparse
():
hashs
=
[]
hash
e
s
=
[]
rng
=
np
.
random
.
rand
(
5
,
5
)
rng
=
np
.
random
.
rand
(
5
,
5
)
for
format
in
[
"csc"
,
"csr"
]:
for
format
in
[
"csc"
,
"csr"
]:
...
@@ -41,11 +41,11 @@ def test_hash_from_sparse():
...
@@ -41,11 +41,11 @@ def test_hash_from_sparse():
]:
]:
data
=
as_sparse_format
(
data
,
format
)
data
=
as_sparse_format
(
data
,
format
)
hashs
.
append
(
hash_from_sparse
(
data
))
hash
e
s
.
append
(
hash_from_sparse
(
data
))
# test that different type of views and their copy give the same hash
# test that different type of views and their copy give the same hash
assert
hash_from_sparse
(
rng
[
1
:])
==
hash_from_sparse
(
rng
[
1
:]
.
copy
())
assert
hash_from_sparse
(
rng
[
1
:])
==
hash_from_sparse
(
rng
[
1
:]
.
copy
())
assert
hash_from_sparse
(
rng
[
1
:
3
])
==
hash_from_sparse
(
rng
[
1
:
3
]
.
copy
())
assert
hash_from_sparse
(
rng
[
1
:
3
])
==
hash_from_sparse
(
rng
[
1
:
3
]
.
copy
())
assert
hash_from_sparse
(
rng
[:
4
])
==
hash_from_sparse
(
rng
[:
4
]
.
copy
())
assert
hash_from_sparse
(
rng
[:
4
])
==
hash_from_sparse
(
rng
[:
4
]
.
copy
())
assert
len
(
set
(
hash
s
))
==
len
(
hash
s
)
assert
len
(
set
(
hash
es
))
==
len
(
hashe
s
)
tests/tensor/nnet/test_blocksparse.py
浏览文件 @
0ac72988
...
@@ -174,7 +174,7 @@ class TestBlockSparseGemvAndOuter(utt.InferShapeTester):
...
@@ -174,7 +174,7 @@ class TestBlockSparseGemvAndOuter(utt.InferShapeTester):
utt
.
assert_allclose
(
ref_out
,
th_out
)
utt
.
assert_allclose
(
ref_out
,
th_out
)
def
test_sparseblockgemvF
(
self
):
def
test_sparseblockgemvF
(
self
):
# Test the fortan order for W (which can happen in the grad for some
# Test the fort
r
an order for W (which can happen in the grad for some
# graphs).
# graphs).
b
=
fmatrix
()
b
=
fmatrix
()
...
@@ -255,7 +255,7 @@ class TestBlockSparseGemvAndOuter(utt.InferShapeTester):
...
@@ -255,7 +255,7 @@ class TestBlockSparseGemvAndOuter(utt.InferShapeTester):
W_val
,
h_val
,
iIdx_val
,
b_val
,
oIdx_val
=
self
.
gemv_data
()
W_val
,
h_val
,
iIdx_val
,
b_val
,
oIdx_val
=
self
.
gemv_data
()
# just make sure that it runs correcly and all the shapes are ok.
# just make sure that it runs correc
t
ly and all the shapes are ok.
b_g
,
W_g
,
h_g
=
f
(
W_val
,
h_val
,
iIdx_val
,
b_val
,
oIdx_val
)
b_g
,
W_g
,
h_g
=
f
(
W_val
,
h_val
,
iIdx_val
,
b_val
,
oIdx_val
)
assert
b_g
.
shape
==
b_val
.
shape
assert
b_g
.
shape
==
b_val
.
shape
...
...
tests/tensor/nnet/test_conv.py
浏览文件 @
0ac72988
...
@@ -408,7 +408,7 @@ class TestConv2D(utt.InferShapeTester):
...
@@ -408,7 +408,7 @@ class TestConv2D(utt.InferShapeTester):
@pytest.mark.slow
@pytest.mark.slow
def
test_invalid_input_shape
(
self
):
def
test_invalid_input_shape
(
self
):
# Tests that when the shape give
d
at build time is not the same as
# Tests that when the shape give
n
at build time is not the same as
# run time we raise an error
# run time we raise an error
for
unroll_batch
in
[
None
,
1
,
3
]:
for
unroll_batch
in
[
None
,
1
,
3
]:
...
...
tests/tensor/nnet/test_neighbours.py
浏览文件 @
0ac72988
...
@@ -233,7 +233,7 @@ class TestImages2Neibs(unittest_tools.InferShapeTester):
...
@@ -233,7 +233,7 @@ class TestImages2Neibs(unittest_tools.InferShapeTester):
[
13
,
14
,
10
,
18
,
19
,
15
,
23
,
24
,
20
],
[
13
,
14
,
10
,
18
,
19
,
15
,
23
,
24
,
20
],
]
]
# TODO test discontinous image
# TODO test discontin
u
ous image
for
shp_idx
,
(
shape
,
neib_shape
,
neib_step
,
expected
)
in
enumerate
(
for
shp_idx
,
(
shape
,
neib_shape
,
neib_step
,
expected
)
in
enumerate
(
[
[
...
...
tests/tensor/test_basic.py
浏览文件 @
0ac72988
...
@@ -2136,7 +2136,7 @@ def test_tile():
...
@@ -2136,7 +2136,7 @@ def test_tile():
# error raising test:
# error raising test:
# reps is vector and len(reps_value) > ndim,
# reps is vector and len(reps_value) > ndim,
# reps_value is the real value when excuting the function.
# reps_value is the real value when ex
e
cuting the function.
reps
=
ivector
()
reps
=
ivector
()
r
=
[
2
,
3
,
4
,
5
,
6
,
7
]
r
=
[
2
,
3
,
4
,
5
,
6
,
7
]
reps_
=
r
[:
k
+
2
]
reps_
=
r
[:
k
+
2
]
...
...
tests/tensor/test_gc.py
浏览文件 @
0ac72988
...
@@ -53,7 +53,7 @@ def test_gc_never_pickles_temporaries():
...
@@ -53,7 +53,7 @@ def test_gc_never_pickles_temporaries():
# len_pre_g = len(pre_g)
# len_pre_g = len(pre_g)
# We can't compare the content or the length of the string
# We can't compare the content or the length of the string
# between f and g. 2 reason, we store some tim
m
ing information
# between f and g. 2 reason, we store some timing information
# in float. They won't be the same each time. Different float
# in float. They won't be the same each time. Different float
# can have different length when printed.
# can have different length when printed.
...
...
tests/tensor/test_math_scipy.py
浏览文件 @
0ac72988
...
@@ -640,7 +640,7 @@ class TestSoftplus:
...
@@ -640,7 +640,7 @@ class TestSoftplus:
utt
.
verify_grad
(
aet
.
softplus
,
[
np
.
random
.
rand
(
3
,
4
)])
utt
.
verify_grad
(
aet
.
softplus
,
[
np
.
random
.
rand
(
3
,
4
)])
def
test_accuracy
(
self
):
def
test_accuracy
(
self
):
# Test all aproximations are working (cutoff points are -37, 18, 33.3)
# Test all ap
p
roximations are working (cutoff points are -37, 18, 33.3)
x_test
=
np
.
array
([
-
40.0
,
-
17.5
,
17.5
,
18.5
,
40.0
])
x_test
=
np
.
array
([
-
40.0
,
-
17.5
,
17.5
,
18.5
,
40.0
])
y_th
=
aet
.
softplus
(
x_test
)
.
eval
()
y_th
=
aet
.
softplus
(
x_test
)
.
eval
()
y_np
=
np
.
log1p
(
np
.
exp
(
x_test
))
y_np
=
np
.
log1p
(
np
.
exp
(
x_test
))
...
...
tests/tensor/test_mlp.py
浏览文件 @
0ac72988
...
@@ -164,7 +164,7 @@ class HiddenLayer:
...
@@ -164,7 +164,7 @@ class HiddenLayer:
"""
"""
self
.
input
=
input
self
.
input
=
input
# `W` is initialized with `W_values` which is uniform
e
ly sampled
# `W` is initialized with `W_values` which is uniformly sampled
# from -6./sqrt(n_in+n_hidden) and 6./sqrt(n_in+n_hidden)
# from -6./sqrt(n_in+n_hidden) and 6./sqrt(n_in+n_hidden)
# the output of uniform if converted using asarray to dtype
# the output of uniform if converted using asarray to dtype
# aesara.config.floatX so that the code is runable on GPU
# aesara.config.floatX so that the code is runable on GPU
...
@@ -188,7 +188,7 @@ class MLP:
...
@@ -188,7 +188,7 @@ class MLP:
A multilayer perceptron is a feedforward artificial neural network model
A multilayer perceptron is a feedforward artificial neural network model
that has one layer or more of hidden units and nonlinear activations.
that has one layer or more of hidden units and nonlinear activations.
Interm
i
diate layers usually have as activation function thanh or the
Interm
e
diate layers usually have as activation function thanh or the
sigmoid function (defined here by a ``SigmoidalLayer`` class) while the
sigmoid function (defined here by a ``SigmoidalLayer`` class) while the
top layer is a softamx layer (defined here by a ``LogisticRegression``
top layer is a softamx layer (defined here by a ``LogisticRegression``
class).
class).
...
...
tests/tensor/test_nlinalg.py
浏览文件 @
0ac72988
...
@@ -52,7 +52,7 @@ def test_pseudoinverse_correctness():
...
@@ -52,7 +52,7 @@ def test_pseudoinverse_correctness():
assert
ri
.
shape
[
0
]
==
r
.
shape
[
1
]
assert
ri
.
shape
[
0
]
==
r
.
shape
[
1
]
assert
ri
.
shape
[
1
]
==
r
.
shape
[
0
]
assert
ri
.
shape
[
1
]
==
r
.
shape
[
0
]
assert
ri
.
dtype
==
r
.
dtype
assert
ri
.
dtype
==
r
.
dtype
# Note that pseudoinverse can be quite
un
precise so I prefer to compare
# Note that pseudoinverse can be quite
im
precise so I prefer to compare
# the result with what np.linalg returns
# the result with what np.linalg returns
assert
_allclose
(
ri
,
np
.
linalg
.
pinv
(
r
))
assert
_allclose
(
ri
,
np
.
linalg
.
pinv
(
r
))
...
...
tests/tensor/test_sharedvar.py
浏览文件 @
0ac72988
...
@@ -327,7 +327,7 @@ def makeSharedTester(
...
@@ -327,7 +327,7 @@ def makeSharedTester(
if
x
.
__class__
.
__name__
!=
"csr_matrix"
:
if
x
.
__class__
.
__name__
!=
"csr_matrix"
:
# sparse matrix don't support inplace affectation
# sparse matrix don't support inplace affectation
nd
+=
1
nd
+=
1
# THIS DOE
NS
'T DO WHAT WE EXPECT the content of a is
# THIS DOE
SN
'T DO WHAT WE EXPECT the content of a is
# not updated for GpuArray, but it is for ndarray
# not updated for GpuArray, but it is for ndarray
x_shared
.
get_value
(
borrow
=
True
)[:]
=
nd
x_shared
.
get_value
(
borrow
=
True
)[:]
=
nd
assert
may_share_memory
(
old_data
,
x_shared
.
container
.
storage
[
0
])
assert
may_share_memory
(
old_data
,
x_shared
.
container
.
storage
[
0
])
...
@@ -347,7 +347,7 @@ def makeSharedTester(
...
@@ -347,7 +347,7 @@ def makeSharedTester(
)
)
# Test by set_value with borrow=False when new data cast.
# Test by set_value with borrow=False when new data cast.
# specificaly useful for gpu data
# specifical
l
y useful for gpu data
nd
+=
1
nd
+=
1
old_data
=
x_shared
.
container
.
storage
[
0
]
old_data
=
x_shared
.
container
.
storage
[
0
]
x_shared
.
set_value
(
self
.
cast_value
(
nd
),
borrow
=
False
)
x_shared
.
set_value
(
self
.
cast_value
(
nd
),
borrow
=
False
)
...
...
tests/tensor/test_slinalg.py
浏览文件 @
0ac72988
...
@@ -142,7 +142,7 @@ def test_eigvalsh():
...
@@ -142,7 +142,7 @@ def test_eigvalsh():
refw
=
scipy
.
linalg
.
eigvalsh
(
a
,
b
)
refw
=
scipy
.
linalg
.
eigvalsh
(
a
,
b
)
np
.
testing
.
assert_array_almost_equal
(
w
,
refw
)
np
.
testing
.
assert_array_almost_equal
(
w
,
refw
)
# We need to test None separatly, as otherwise DebugMode will
# We need to test None separat
e
ly, as otherwise DebugMode will
# complain, as this isn't a valid ndarray.
# complain, as this isn't a valid ndarray.
b
=
None
b
=
None
B
=
aet
.
NoneConst
B
=
aet
.
NoneConst
...
...
tests/tensor/test_utils.py
浏览文件 @
0ac72988
...
@@ -8,7 +8,7 @@ from aesara.tensor.utils import hash_from_ndarray, shape_of_variables
...
@@ -8,7 +8,7 @@ from aesara.tensor.utils import hash_from_ndarray, shape_of_variables
def
test_hash_from_ndarray
():
def
test_hash_from_ndarray
():
hashs
=
[]
hash
e
s
=
[]
rng
=
np
.
random
.
rand
(
5
,
5
)
rng
=
np
.
random
.
rand
(
5
,
5
)
for
data
in
[
for
data
in
[
...
@@ -37,9 +37,9 @@ def test_hash_from_ndarray():
...
@@ -37,9 +37,9 @@ def test_hash_from_ndarray():
rng
[::
-
1
],
rng
[::
-
1
],
]:
]:
data
=
np
.
asarray
(
data
)
data
=
np
.
asarray
(
data
)
hashs
.
append
(
hash_from_ndarray
(
data
))
hash
e
s
.
append
(
hash_from_ndarray
(
data
))
assert
len
(
set
(
hash
s
))
==
len
(
hash
s
)
assert
len
(
set
(
hash
es
))
==
len
(
hashe
s
)
# test that different type of views and their copy give the same hash
# test that different type of views and their copy give the same hash
assert
hash_from_ndarray
(
rng
[
1
:])
==
hash_from_ndarray
(
rng
[
1
:]
.
copy
())
assert
hash_from_ndarray
(
rng
[
1
:])
==
hash_from_ndarray
(
rng
[
1
:]
.
copy
())
...
...
tests/test_gradient.py
浏览文件 @
0ac72988
...
@@ -901,7 +901,7 @@ class TestDisconnectedGrad:
...
@@ -901,7 +901,7 @@ class TestDisconnectedGrad:
x
=
matrix
(
"x"
)
x
=
matrix
(
"x"
)
# This MUST raise a DisconnectedInputError error.
# This MUST raise a DisconnectedInputError error.
# This also ra
si
es an additional warning from gradients.py.
# This also ra
is
es an additional warning from gradients.py.
with
pytest
.
raises
(
DisconnectedInputError
):
with
pytest
.
raises
(
DisconnectedInputError
):
grad
(
disconnected_grad
(
x
)
.
sum
(),
x
)
grad
(
disconnected_grad
(
x
)
.
sum
(),
x
)
...
@@ -912,7 +912,7 @@ class TestDisconnectedGrad:
...
@@ -912,7 +912,7 @@ class TestDisconnectedGrad:
b
=
matrix
(
"b"
)
b
=
matrix
(
"b"
)
y
=
a
+
disconnected_grad
(
b
)
y
=
a
+
disconnected_grad
(
b
)
# This MUST raise a DisconnectedInputError error.
# This MUST raise a DisconnectedInputError error.
# This also ra
si
es an additional warning from gradients.py.
# This also ra
is
es an additional warning from gradients.py.
with
pytest
.
raises
(
DisconnectedInputError
):
with
pytest
.
raises
(
DisconnectedInputError
):
grad
(
y
.
sum
(),
b
)
grad
(
y
.
sum
(),
b
)
...
...
tests/test_rop.py
浏览文件 @
0ac72988
...
@@ -61,7 +61,7 @@ break_op = BreakRop()
...
@@ -61,7 +61,7 @@ break_op = BreakRop()
class
RopLopChecker
:
class
RopLopChecker
:
"""
"""
Don't peform any test, but provide the function to test the
Don't pe
r
form any test, but provide the function to test the
Rop to class that inherit from it.
Rop to class that inherit from it.
"""
"""
...
...
tests/typed_list/test_type.py
浏览文件 @
0ac72988
...
@@ -111,7 +111,7 @@ class TestTypedListType:
...
@@ -111,7 +111,7 @@ class TestTypedListType:
assert
myNestedType2
!=
myNestedType3
assert
myNestedType2
!=
myNestedType3
def
test_nested_list_arg
(
self
):
def
test_nested_list_arg
(
self
):
# test for the 'depth' option
n
al argument
# test for the 'depth' optional argument
myNestedType
=
TypedListType
(
myNestedType
=
TypedListType
(
TensorType
(
aesara
.
config
.
floatX
,
(
False
,
False
)),
3
TensorType
(
aesara
.
config
.
floatX
,
(
False
,
False
)),
3
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论