Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
708568c2
提交
708568c2
authored
3月 25, 2017
作者:
amrithasuresh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated numpy as np
上级
449fc71e
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
40 行增加
和
40 行删除
+40
-40
test_basic.py
theano/typed_list/tests/test_basic.py
+40
-40
没有找到文件。
theano/typed_list/tests/test_basic.py
浏览文件 @
708568c2
...
@@ -2,7 +2,7 @@ from __future__ import absolute_import, print_function, division
...
@@ -2,7 +2,7 @@ from __future__ import absolute_import, print_function, division
import
unittest
import
unittest
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
import
numpy
import
numpy
as
np
import
theano
import
theano
import
theano.typed_list
import
theano.typed_list
...
@@ -24,8 +24,8 @@ except ImportError:
...
@@ -24,8 +24,8 @@ except ImportError:
# took from tensors/tests/test_basic.py
# took from tensors/tests/test_basic.py
def
rand_ranged_matrix
(
minimum
,
maximum
,
shape
):
def
rand_ranged_matrix
(
minimum
,
maximum
,
shape
):
return
n
umpy
.
asarray
(
numpy
.
random
.
rand
(
*
shape
)
*
(
maximum
-
minimum
)
+
return
n
p
.
asarray
(
np
.
random
.
rand
(
*
shape
)
*
(
maximum
-
minimum
)
+
minimum
,
dtype
=
theano
.
config
.
floatX
)
minimum
,
dtype
=
theano
.
config
.
floatX
)
# took from sparse/tests/test_basic.py
# took from sparse/tests/test_basic.py
...
@@ -34,8 +34,8 @@ def random_lil(shape, dtype, nnz):
...
@@ -34,8 +34,8 @@ def random_lil(shape, dtype, nnz):
huge
=
2
**
30
huge
=
2
**
30
for
k
in
range
(
nnz
):
for
k
in
range
(
nnz
):
# set non-zeros in random locations (row x, col y)
# set non-zeros in random locations (row x, col y)
idx
=
n
umpy
.
random
.
randint
(
1
,
huge
+
1
,
size
=
2
)
%
shape
idx
=
n
p
.
random
.
randint
(
1
,
huge
+
1
,
size
=
2
)
%
shape
value
=
n
umpy
.
random
.
rand
()
value
=
n
p
.
random
.
rand
()
# if dtype *int*, value will always be zeros!
# if dtype *int*, value will always be zeros!
if
dtype
in
theano
.
tensor
.
integer_dtypes
:
if
dtype
in
theano
.
tensor
.
integer_dtypes
:
value
=
int
(
value
*
100
)
value
=
int
(
value
*
100
)
...
@@ -68,7 +68,7 @@ class test_get_item(unittest.TestCase):
...
@@ -68,7 +68,7 @@ class test_get_item(unittest.TestCase):
x
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
x
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
],
slice
(
0
,
1
,
1
)),
[
x
]))
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
],
slice
(
0
,
1
,
1
)),
[
x
]))
def
test_sanity_check_single
(
self
):
def
test_sanity_check_single
(
self
):
...
@@ -84,9 +84,9 @@ class test_get_item(unittest.TestCase):
...
@@ -84,9 +84,9 @@ class test_get_item(unittest.TestCase):
x
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
x
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
],
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
],
numpy
.
asarray
(
0
,
dtype
=
'int64'
)),
np
.
asarray
(
0
,
dtype
=
'int64'
)),
x
))
x
))
def
test_interface
(
self
):
def
test_interface
(
self
):
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
...
@@ -100,16 +100,16 @@ class test_get_item(unittest.TestCase):
...
@@ -100,16 +100,16 @@ class test_get_item(unittest.TestCase):
x
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
x
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
],
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
],
numpy
.
asarray
(
0
,
dtype
=
'int64'
)),
np
.
asarray
(
0
,
dtype
=
'int64'
)),
x
))
x
))
z
=
mySymbolicMatricesList
[
0
]
z
=
mySymbolicMatricesList
[
0
]
f
=
theano
.
function
([
mySymbolicMatricesList
],
f
=
theano
.
function
([
mySymbolicMatricesList
],
z
)
z
)
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
]),
x
))
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
]),
x
))
def
test_wrong_input
(
self
):
def
test_wrong_input
(
self
):
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
...
@@ -130,14 +130,14 @@ class test_get_item(unittest.TestCase):
...
@@ -130,14 +130,14 @@ class test_get_item(unittest.TestCase):
x
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
x
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
]),
x
))
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
]),
x
))
z
=
GetItem
()(
mySymbolicMatricesList
,
slice
(
0
,
1
,
1
))
z
=
GetItem
()(
mySymbolicMatricesList
,
slice
(
0
,
1
,
1
))
f
=
theano
.
function
([
mySymbolicMatricesList
],
f
=
theano
.
function
([
mySymbolicMatricesList
],
z
)
z
)
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
]),
[
x
]))
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
]),
[
x
]))
class
test_append
(
unittest
.
TestCase
):
class
test_append
(
unittest
.
TestCase
):
...
@@ -156,7 +156,7 @@ class test_append(unittest.TestCase):
...
@@ -156,7 +156,7 @@ class test_append(unittest.TestCase):
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
],
y
),
[
x
,
y
]))
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
],
y
),
[
x
,
y
]))
def
test_sanity_check
(
self
):
def
test_sanity_check
(
self
):
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
...
@@ -171,7 +171,7 @@ class test_append(unittest.TestCase):
...
@@ -171,7 +171,7 @@ class test_append(unittest.TestCase):
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
],
y
),
[
x
,
y
]))
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
],
y
),
[
x
,
y
]))
def
test_interfaces
(
self
):
def
test_interfaces
(
self
):
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
...
@@ -186,7 +186,7 @@ class test_append(unittest.TestCase):
...
@@ -186,7 +186,7 @@ class test_append(unittest.TestCase):
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
],
y
),
[
x
,
y
]))
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
],
y
),
[
x
,
y
]))
class
test_extend
(
unittest
.
TestCase
):
class
test_extend
(
unittest
.
TestCase
):
...
@@ -206,7 +206,7 @@ class test_extend(unittest.TestCase):
...
@@ -206,7 +206,7 @@ class test_extend(unittest.TestCase):
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
],
[
y
]),
[
x
,
y
]))
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
],
[
y
]),
[
x
,
y
]))
def
test_sanity_check
(
self
):
def
test_sanity_check
(
self
):
mySymbolicMatricesList1
=
TypedListType
(
T
.
TensorType
(
mySymbolicMatricesList1
=
TypedListType
(
T
.
TensorType
(
...
@@ -223,7 +223,7 @@ class test_extend(unittest.TestCase):
...
@@ -223,7 +223,7 @@ class test_extend(unittest.TestCase):
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
],
[
y
]),
[
x
,
y
]))
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
],
[
y
]),
[
x
,
y
]))
def
test_interface
(
self
):
def
test_interface
(
self
):
mySymbolicMatricesList1
=
TypedListType
(
T
.
TensorType
(
mySymbolicMatricesList1
=
TypedListType
(
T
.
TensorType
(
...
@@ -240,7 +240,7 @@ class test_extend(unittest.TestCase):
...
@@ -240,7 +240,7 @@ class test_extend(unittest.TestCase):
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
],
[
y
]),
[
x
,
y
]))
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
],
[
y
]),
[
x
,
y
]))
class
test_insert
(
unittest
.
TestCase
):
class
test_insert
(
unittest
.
TestCase
):
...
@@ -260,10 +260,10 @@ class test_insert(unittest.TestCase):
...
@@ -260,10 +260,10 @@ class test_insert(unittest.TestCase):
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
],
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
],
numpy
.
asarray
(
1
,
dtype
=
'int64'
),
np
.
asarray
(
1
,
dtype
=
'int64'
),
y
),
y
),
[
x
,
y
]))
[
x
,
y
]))
def
test_sanity_check
(
self
):
def
test_sanity_check
(
self
):
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
...
@@ -279,7 +279,7 @@ class test_insert(unittest.TestCase):
...
@@ -279,7 +279,7 @@ class test_insert(unittest.TestCase):
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
],
numpy
.
asarray
(
1
,
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
],
np
.
asarray
(
1
,
dtype
=
'int64'
),
y
),
[
x
,
y
]))
dtype
=
'int64'
),
y
),
[
x
,
y
]))
def
test_interface
(
self
):
def
test_interface
(
self
):
...
@@ -296,10 +296,10 @@ class test_insert(unittest.TestCase):
...
@@ -296,10 +296,10 @@ class test_insert(unittest.TestCase):
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
],
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
],
numpy
.
asarray
(
1
,
dtype
=
'int64'
),
np
.
asarray
(
1
,
dtype
=
'int64'
),
y
),
y
),
[
x
,
y
]))
[
x
,
y
]))
class
test_remove
(
unittest
.
TestCase
):
class
test_remove
(
unittest
.
TestCase
):
...
@@ -318,7 +318,7 @@ class test_remove(unittest.TestCase):
...
@@ -318,7 +318,7 @@ class test_remove(unittest.TestCase):
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
,
y
],
y
),
[
x
]))
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
,
y
],
y
),
[
x
]))
def
test_sanity_check
(
self
):
def
test_sanity_check
(
self
):
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
...
@@ -333,7 +333,7 @@ class test_remove(unittest.TestCase):
...
@@ -333,7 +333,7 @@ class test_remove(unittest.TestCase):
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
,
y
],
y
),
[
x
]))
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
,
y
],
y
),
[
x
]))
def
test_interface
(
self
):
def
test_interface
(
self
):
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
...
@@ -348,7 +348,7 @@ class test_remove(unittest.TestCase):
...
@@ -348,7 +348,7 @@ class test_remove(unittest.TestCase):
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
,
y
],
y
),
[
x
]))
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
,
y
],
y
),
[
x
]))
class
test_reverse
(
unittest
.
TestCase
):
class
test_reverse
(
unittest
.
TestCase
):
...
@@ -366,7 +366,7 @@ class test_reverse(unittest.TestCase):
...
@@ -366,7 +366,7 @@ class test_reverse(unittest.TestCase):
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
,
y
]),
[
y
,
x
]))
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
,
y
]),
[
y
,
x
]))
def
test_sanity_check
(
self
):
def
test_sanity_check
(
self
):
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
...
@@ -380,7 +380,7 @@ class test_reverse(unittest.TestCase):
...
@@ -380,7 +380,7 @@ class test_reverse(unittest.TestCase):
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
,
y
]),
[
y
,
x
]))
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
,
y
]),
[
y
,
x
]))
def
test_interface
(
self
):
def
test_interface
(
self
):
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
...
@@ -394,7 +394,7 @@ class test_reverse(unittest.TestCase):
...
@@ -394,7 +394,7 @@ class test_reverse(unittest.TestCase):
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
y
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
n
umpy
.
array_equal
(
f
([
x
,
y
]),
[
y
,
x
]))
self
.
assertTrue
(
n
p
.
array_equal
(
f
([
x
,
y
]),
[
y
,
x
]))
class
test_index
(
unittest
.
TestCase
):
class
test_index
(
unittest
.
TestCase
):
...
@@ -570,10 +570,10 @@ class TestMakeList(unittest.TestCase):
...
@@ -570,10 +570,10 @@ class TestMakeList(unittest.TestCase):
x
=
T
.
tensor3
()
x
=
T
.
tensor3
()
y
=
T
.
tensor3
()
y
=
T
.
tensor3
()
A
=
n
umpy
.
cast
[
theano
.
config
.
floatX
](
numpy
.
random
.
rand
(
5
,
3
))
A
=
n
p
.
cast
[
theano
.
config
.
floatX
](
np
.
random
.
rand
(
5
,
3
))
B
=
n
umpy
.
cast
[
theano
.
config
.
floatX
](
numpy
.
random
.
rand
(
7
,
2
))
B
=
n
p
.
cast
[
theano
.
config
.
floatX
](
np
.
random
.
rand
(
7
,
2
))
X
=
n
umpy
.
cast
[
theano
.
config
.
floatX
](
numpy
.
random
.
rand
(
5
,
6
,
1
))
X
=
n
p
.
cast
[
theano
.
config
.
floatX
](
np
.
random
.
rand
(
5
,
6
,
1
))
Y
=
n
umpy
.
cast
[
theano
.
config
.
floatX
](
numpy
.
random
.
rand
(
1
,
9
,
3
))
Y
=
n
p
.
cast
[
theano
.
config
.
floatX
](
np
.
random
.
rand
(
1
,
9
,
3
))
make_list
((
3.
,
4.
))
make_list
((
3.
,
4.
))
c
=
make_list
((
a
,
b
))
c
=
make_list
((
a
,
b
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论