Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
74c89acd
提交
74c89acd
authored
7月 30, 2014
作者:
Tanjay94
提交者:
Frederic
10月 17, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added infer_shape test for choose function.
上级
89c8b664
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
20 行增加
和
18 行删除
+20
-18
test_basic.py
theano/tensor/tests/test_basic.py
+20
-18
没有找到文件。
theano/tensor/tests/test_basic.py
浏览文件 @
74c89acd
...
@@ -46,7 +46,7 @@ from theano.tensor import (_shared, wvector, bvector, autocast_float_as,
...
@@ -46,7 +46,7 @@ from theano.tensor import (_shared, wvector, bvector, autocast_float_as,
itensor3
,
Tile
,
switch
,
Diagonal
,
Diag
,
itensor3
,
Tile
,
switch
,
Diagonal
,
Diag
,
nonzero
,
flatnonzero
,
nonzero_values
,
nonzero
,
flatnonzero
,
nonzero_values
,
stacklists
,
DimShuffle
,
hessian
,
ptp
,
power
,
stacklists
,
DimShuffle
,
hessian
,
ptp
,
power
,
swapaxes
,
choose
swapaxes
,
choose
,
Choose
)
)
from
theano.tests
import
unittest_tools
as
utt
from
theano.tests
import
unittest_tools
as
utt
...
@@ -7012,7 +7012,10 @@ class T_Power():
...
@@ -7012,7 +7012,10 @@ class T_Power():
self
.
assertRaise
(
ValueError
,
f
,
[
1
,
2
,
3
,
4
])
self
.
assertRaise
(
ValueError
,
f
,
[
1
,
2
,
3
,
4
])
class
T_Choose
():
class
T_Choose
(
utt
.
InferShapeTester
):
op
=
staticmethod
(
choose
)
op_class
=
Choose
def
test_numpy_compare
(
self
):
def
test_numpy_compare
(
self
):
a
=
tensor
.
vector
(
dtype
=
'int64'
)
a
=
tensor
.
vector
(
dtype
=
'int64'
)
...
@@ -7036,25 +7039,24 @@ class T_Choose():
...
@@ -7036,25 +7039,24 @@ class T_Choose():
c
=
tensor
.
matrix
(
dtype
=
'int64'
)
c
=
tensor
.
matrix
(
dtype
=
'int64'
)
d
=
tensor
.
vector
(
dtype
=
'int64'
)
d
=
tensor
.
vector
(
dtype
=
'int64'
)
A
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
4
,
4
),
dtype
=
'int64'
)
A
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
5
,
4
),
dtype
=
'int64'
)
B
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
4
),
dtype
=
'int64'
)
B
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
4
),
dtype
=
'int64'
)
C
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
4
,
4
),
dtype
=
'int64'
)
C
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
7
,
4
),
dtype
=
'int64'
)
D
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
4
),
dtype
=
'int64'
)
D
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
4
),
dtype
=
'int64'
)
fa
=
function
([
a
,
c
],
choose
(
a
,
c
))
var1
=
[
a
,
b
,
a
,
b
]
fb
=
function
([
b
,
d
],
choose
(
b
,
d
))
var2
=
[
c
,
d
,
b
,
a
]
fc
=
function
([
a
,
b
],
choose
(
a
,
b
))
mat1
=
[
A
,
B
,
A
,
B
]
fd
=
function
([
b
,
a
],
choose
(
b
,
a
))
mat2
=
[
C
,
D
,
B
,
A
]
t_ca
=
fa
(
A
,
C
)
for
v
,
m
,
w
,
n
in
zip
(
var1
,
mat1
,
var2
,
mat2
):
t_cb
=
fb
(
B
,
D
)
self
.
_compile_and_check
([
v
,
w
],
# theano.function inputs
t_cc
=
fc
(
A
,
B
)
[
self
.
op
(
v
,
w
)],
# theano.function outputs
t_cd
=
fd
(
B
,
A
)
# Always use not square matrix!
# inputs data
assert
numpy
.
allclose
(
A
.
shape
,
t_ca
.
shape
)
[
m
,
n
],
assert
numpy
.
allclose
(
B
.
shape
,
t_cb
.
shape
)
# Op that should be removed from the graph.
assert
numpy
.
allclose
(
A
.
shape
,
t_cc
.
shape
)
self
.
op_class
)
assert
numpy
.
allclose
(
B
.
shape
,
t_cd
.
shape
)
"""
"""
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论