Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
62c6c1ea
提交
62c6c1ea
authored
10月 19, 2020
作者:
Brandon T. Willard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replace theano.tensor alias T with tt in tests.typed_list
上级
6a09a928
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
34 行增加
和
31 行删除
+34
-31
test_basic.py
tests/typed_list/test_basic.py
+0
-0
test_opt.py
tests/typed_list/test_opt.py
+12
-12
test_type.py
tests/typed_list/test_type.py
+22
-19
没有找到文件。
tests/typed_list/test_basic.py
浏览文件 @
62c6c1ea
差异被折叠。
点击展开。
tests/typed_list/test_opt.py
浏览文件 @
62c6c1ea
import
numpy
as
np
import
numpy
as
np
import
theano
import
theano
import
theano.tensor
as
tt
import
theano.typed_list
import
theano.typed_list
from
theano
import
In
from
theano
import
In
from
theano
import
tensor
as
T
from
theano.typed_list.type
import
TypedListType
from
theano.typed_list.type
import
TypedListType
from
theano.typed_list.basic
import
Insert
,
Append
,
Extend
,
Remove
,
Reverse
from
theano.typed_list.basic
import
Insert
,
Append
,
Extend
,
Remove
,
Reverse
...
@@ -20,7 +20,7 @@ def rand_ranged_matrix(minimum, maximum, shape):
...
@@ -20,7 +20,7 @@ def rand_ranged_matrix(minimum, maximum, shape):
class
TestInplace
:
class
TestInplace
:
def
test_reverse_inplace
(
self
):
def
test_reverse_inplace
(
self
):
mySymbolicMatricesList
=
TypedListType
(
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
))
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
))
)()
)()
z
=
Reverse
()(
mySymbolicMatricesList
)
z
=
Reverse
()(
mySymbolicMatricesList
)
...
@@ -41,9 +41,9 @@ class TestInplace:
...
@@ -41,9 +41,9 @@ class TestInplace:
def
test_append_inplace
(
self
):
def
test_append_inplace
(
self
):
mySymbolicMatricesList
=
TypedListType
(
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
))
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
))
)()
)()
mySymbolicMatrix
=
T
.
matrix
()
mySymbolicMatrix
=
tt
.
matrix
()
z
=
Append
()(
mySymbolicMatricesList
,
mySymbolicMatrix
)
z
=
Append
()(
mySymbolicMatricesList
,
mySymbolicMatrix
)
m
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
"typed_list_inplace_opt"
)
m
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
"typed_list_inplace_opt"
)
f
=
theano
.
function
(
f
=
theano
.
function
(
...
@@ -65,11 +65,11 @@ class TestInplace:
...
@@ -65,11 +65,11 @@ class TestInplace:
def
test_extend_inplace
(
self
):
def
test_extend_inplace
(
self
):
mySymbolicMatricesList1
=
TypedListType
(
mySymbolicMatricesList1
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
))
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
))
)()
)()
mySymbolicMatricesList2
=
TypedListType
(
mySymbolicMatricesList2
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
))
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
))
)()
)()
z
=
Extend
()(
mySymbolicMatricesList1
,
mySymbolicMatricesList2
)
z
=
Extend
()(
mySymbolicMatricesList1
,
mySymbolicMatricesList2
)
...
@@ -92,10 +92,10 @@ class TestInplace:
...
@@ -92,10 +92,10 @@ class TestInplace:
def
test_insert_inplace
(
self
):
def
test_insert_inplace
(
self
):
mySymbolicMatricesList
=
TypedListType
(
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
))
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
))
)()
)()
mySymbolicIndex
=
T
.
scalar
(
dtype
=
"int64"
)
mySymbolicIndex
=
tt
.
scalar
(
dtype
=
"int64"
)
mySymbolicMatrix
=
T
.
matrix
()
mySymbolicMatrix
=
tt
.
matrix
()
z
=
Insert
()(
mySymbolicMatricesList
,
mySymbolicIndex
,
mySymbolicMatrix
)
z
=
Insert
()(
mySymbolicMatricesList
,
mySymbolicIndex
,
mySymbolicMatrix
)
m
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
"typed_list_inplace_opt"
)
m
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
"typed_list_inplace_opt"
)
...
@@ -120,9 +120,9 @@ class TestInplace:
...
@@ -120,9 +120,9 @@ class TestInplace:
def
test_remove_inplace
(
self
):
def
test_remove_inplace
(
self
):
mySymbolicMatricesList
=
TypedListType
(
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
))
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
))
)()
)()
mySymbolicMatrix
=
T
.
matrix
()
mySymbolicMatrix
=
tt
.
matrix
()
z
=
Remove
()(
mySymbolicMatricesList
,
mySymbolicMatrix
)
z
=
Remove
()(
mySymbolicMatricesList
,
mySymbolicMatrix
)
m
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
"typed_list_inplace_opt"
)
m
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
"typed_list_inplace_opt"
)
f
=
theano
.
function
(
f
=
theano
.
function
(
...
@@ -144,7 +144,7 @@ class TestInplace:
...
@@ -144,7 +144,7 @@ class TestInplace:
def
test_constant_folding
():
def
test_constant_folding
():
m
=
t
heano
.
tensor
.
ones
((
1
,),
dtype
=
"int8"
)
m
=
t
t
.
ones
((
1
,),
dtype
=
"int8"
)
l
=
theano
.
typed_list
.
make_list
([
m
,
m
])
l
=
theano
.
typed_list
.
make_list
([
m
,
m
])
f
=
theano
.
function
([],
l
)
f
=
theano
.
function
([],
l
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
...
...
tests/typed_list/test_type.py
浏览文件 @
62c6c1ea
...
@@ -2,8 +2,8 @@ import pytest
...
@@ -2,8 +2,8 @@ import pytest
import
numpy
as
np
import
numpy
as
np
import
theano
import
theano
import
theano.typed_list
import
theano.typed_list
import
theano.tensor
as
tt
from
theano
import
tensor
as
T
from
theano.typed_list.type
import
TypedListType
from
theano.typed_list.type
import
TypedListType
from
tests
import
unittest_tools
as
utt
from
tests
import
unittest_tools
as
utt
...
@@ -35,7 +35,7 @@ class TestTypedListType:
...
@@ -35,7 +35,7 @@ class TestTypedListType:
# specified on creation
# specified on creation
# list of matrices
# list of matrices
myType
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
myType
=
TypedListType
(
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
with
pytest
.
raises
(
TypeError
):
with
pytest
.
raises
(
TypeError
):
myType
.
filter
([
4
])
myType
.
filter
([
4
])
...
@@ -45,7 +45,7 @@ class TestTypedListType:
...
@@ -45,7 +45,7 @@ class TestTypedListType:
# if no iterable variable is given on input
# if no iterable variable is given on input
# list of matrices
# list of matrices
myType
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
myType
=
TypedListType
(
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
with
pytest
.
raises
(
TypeError
):
with
pytest
.
raises
(
TypeError
):
myType
.
filter
(
4
)
myType
.
filter
(
4
)
...
@@ -56,11 +56,11 @@ class TestTypedListType:
...
@@ -56,11 +56,11 @@ class TestTypedListType:
# variables
# variables
# list of matrices
# list of matrices
myType1
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
myType1
=
TypedListType
(
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
# list of matrices
# list of matrices
myType2
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
myType2
=
TypedListType
(
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
# list of scalars
# list of scalars
myType3
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
()))
myType3
=
TypedListType
(
tt
.
TensorType
(
theano
.
config
.
floatX
,
()))
assert
myType2
==
myType1
assert
myType2
==
myType1
assert
myType3
!=
myType1
assert
myType3
!=
myType1
...
@@ -68,7 +68,7 @@ class TestTypedListType:
...
@@ -68,7 +68,7 @@ class TestTypedListType:
def
test_filter_sanity_check
(
self
):
def
test_filter_sanity_check
(
self
):
# Simple test on typed list type filter
# Simple test on typed list type filter
myType
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
myType
=
TypedListType
(
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
x
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
100
])
x
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
100
])
...
@@ -79,17 +79,16 @@ class TestTypedListType:
...
@@ -79,17 +79,16 @@ class TestTypedListType:
# filtered. If they weren't this code would raise
# filtered. If they weren't this code would raise
# an exception.
# an exception.
myType
=
TypedListType
(
T
.
TensorType
(
"float64"
,
(
False
,
False
)))
myType
=
TypedListType
(
tt
.
TensorType
(
"float64"
,
(
False
,
False
)))
x
=
np
.
asarray
([[
4
,
5
],
[
4
,
5
]],
dtype
=
"float32"
)
x
=
np
.
asarray
([[
4
,
5
],
[
4
,
5
]],
dtype
=
"float32"
)
assert
np
.
array_equal
(
myType
.
filter
([
x
]),
[
x
])
assert
np
.
array_equal
(
myType
.
filter
([
x
]),
[
x
])
@pytest.mark.skip
(
reason
=
"This fails for unknown reasons?"
)
def
test_load_alot
(
self
):
def
test_load
(
self
):
myType
=
TypedListType
(
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
myType
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
x
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
10
0
,
10
0
])
x
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
10
,
1
0
])
testList
=
[]
testList
=
[]
for
i
in
range
(
10000
):
for
i
in
range
(
10000
):
testList
.
append
(
x
)
testList
.
append
(
x
)
...
@@ -99,7 +98,9 @@ class TestTypedListType:
...
@@ -99,7 +98,9 @@ class TestTypedListType:
def
test_basic_nested_list
(
self
):
def
test_basic_nested_list
(
self
):
# Testing nested list with one level of depth
# Testing nested list with one level of depth
myNestedType
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
myNestedType
=
TypedListType
(
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
))
)
myType
=
TypedListType
(
myNestedType
)
myType
=
TypedListType
(
myNestedType
)
...
@@ -110,7 +111,9 @@ class TestTypedListType:
...
@@ -110,7 +111,9 @@ class TestTypedListType:
def
test_comparison_different_depth
(
self
):
def
test_comparison_different_depth
(
self
):
# Nested list with different depth aren't the same
# Nested list with different depth aren't the same
myNestedType
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
myNestedType
=
TypedListType
(
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
))
)
myNestedType2
=
TypedListType
(
myNestedType
)
myNestedType2
=
TypedListType
(
myNestedType
)
...
@@ -122,10 +125,10 @@ class TestTypedListType:
...
@@ -122,10 +125,10 @@ class TestTypedListType:
# test for the 'depth' optionnal argument
# test for the 'depth' optionnal argument
myNestedType
=
TypedListType
(
myNestedType
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)),
3
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)),
3
)
)
myType
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
myType
=
TypedListType
(
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
myManualNestedType
=
TypedListType
(
TypedListType
(
TypedListType
(
myType
)))
myManualNestedType
=
TypedListType
(
TypedListType
(
TypedListType
(
myType
)))
...
@@ -134,7 +137,7 @@ class TestTypedListType:
...
@@ -134,7 +137,7 @@ class TestTypedListType:
def
test_get_depth
(
self
):
def
test_get_depth
(
self
):
# test case for get_depth utilitary function
# test case for get_depth utilitary function
myType
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
myType
=
TypedListType
(
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
myManualNestedType
=
TypedListType
(
TypedListType
(
TypedListType
(
myType
)))
myManualNestedType
=
TypedListType
(
TypedListType
(
TypedListType
(
myType
)))
...
@@ -143,7 +146,7 @@ class TestTypedListType:
...
@@ -143,7 +146,7 @@ class TestTypedListType:
def
test_comparison_uneven_nested
(
self
):
def
test_comparison_uneven_nested
(
self
):
# test for comparison between uneven nested list
# test for comparison between uneven nested list
myType
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
myType
=
TypedListType
(
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))
myManualNestedType1
=
TypedListType
(
TypedListType
(
TypedListType
(
myType
)))
myManualNestedType1
=
TypedListType
(
TypedListType
(
TypedListType
(
myType
)))
...
@@ -154,7 +157,7 @@ class TestTypedListType:
...
@@ -154,7 +157,7 @@ class TestTypedListType:
def
test_variable_is_Typed_List_variable
(
self
):
def
test_variable_is_Typed_List_variable
(
self
):
mySymbolicVariable
=
TypedListType
(
mySymbolicVariable
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
))
tt
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
))
)()
)()
assert
isinstance
(
mySymbolicVariable
,
theano
.
typed_list
.
TypedListVariable
)
assert
isinstance
(
mySymbolicVariable
,
theano
.
typed_list
.
TypedListVariable
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论