Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
724412fa
提交
724412fa
authored
8月 11, 2016
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix test now that we replace a reshape with a dimshuffle
上级
70e23f42
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
16 行增加
和
2 行删除
+16
-2
test_basic.py
theano/tensor/tests/test_basic.py
+16
-2
没有找到文件。
theano/tensor/tests/test_basic.py
浏览文件 @
724412fa
...
@@ -5114,12 +5114,15 @@ class T_reshape(utt.InferShapeTester, utt.TestOptimizationMixin):
...
@@ -5114,12 +5114,15 @@ class T_reshape(utt.InferShapeTester, utt.TestOptimizationMixin):
self
.
ignore_topo
=
ignore_topo
self
.
ignore_topo
=
ignore_topo
super
(
T_reshape
,
self
)
.
__init__
(
name
)
super
(
T_reshape
,
self
)
.
__init__
(
name
)
def
function
(
self
,
inputs
,
outputs
):
def
function
(
self
,
inputs
,
outputs
,
ignore_empty
=
False
):
f
=
function
(
inputs
,
outputs
,
mode
=
self
.
mode
)
f
=
function
(
inputs
,
outputs
,
mode
=
self
.
mode
)
if
self
.
mode
is
not
None
or
theano
.
config
.
mode
!=
"FAST_COMPILE"
:
if
self
.
mode
is
not
None
or
theano
.
config
.
mode
!=
"FAST_COMPILE"
:
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo_
=
[
node
for
node
in
topo
if
not
isinstance
(
node
.
op
,
topo_
=
[
node
for
node
in
topo
if
not
isinstance
(
node
.
op
,
self
.
ignore_topo
)]
self
.
ignore_topo
)]
if
ignore_empty
:
assert
len
(
topo_
)
<=
1
,
topo_
else
:
assert
len
(
topo_
)
==
1
,
topo_
assert
len
(
topo_
)
==
1
,
topo_
assert
type
(
topo_
[
0
]
.
op
)
is
self
.
op
assert
type
(
topo_
[
0
]
.
op
)
is
self
.
op
return
f
return
f
...
@@ -5194,12 +5197,23 @@ class T_reshape(utt.InferShapeTester, utt.TestOptimizationMixin):
...
@@ -5194,12 +5197,23 @@ class T_reshape(utt.InferShapeTester, utt.TestOptimizationMixin):
# test broadcast flag for constant value of 1
# test broadcast flag for constant value of 1
c
=
reshape
(
b
,
(
b
.
shape
[
0
],
b
.
shape
[
1
],
1
))
c
=
reshape
(
b
,
(
b
.
shape
[
0
],
b
.
shape
[
1
],
1
))
f
=
self
.
function
([
b
],
c
)
# That reshape may get replaced with a dimshuffle, with is ignored,
# so we pass "ignore_empty=True"
f
=
self
.
function
([
b
],
c
,
ignore_empty
=
True
)
assert
numpy
.
all
(
f
(
numpy
.
asarray
([[
0
,
1
,
2
],
[
3
,
4
,
5
]]))
==
assert
numpy
.
all
(
f
(
numpy
.
asarray
([[
0
,
1
,
2
],
[
3
,
4
,
5
]]))
==
numpy
.
asarray
([[[
0
],
[
1
],
[
2
]],
[[
3
],
[
4
],
[
5
]]]))
numpy
.
asarray
([[[
0
],
[
1
],
[
2
]],
[[
3
],
[
4
],
[
5
]]]))
assert
(
f
.
maker
.
fgraph
.
toposort
()[
-
1
]
.
outputs
[
0
]
.
type
.
broadcastable
==
assert
(
f
.
maker
.
fgraph
.
toposort
()[
-
1
]
.
outputs
[
0
]
.
type
.
broadcastable
==
(
False
,
False
,
True
))
(
False
,
False
,
True
))
# test broadcast flag for constant value of 1 if it cannot be
# replaced with dimshuffle
c
=
reshape
(
b
,
(
b
.
shape
[
1
],
b
.
shape
[
0
],
1
))
f
=
self
.
function
([
b
],
c
,
ignore_empty
=
True
)
assert
numpy
.
all
(
f
(
numpy
.
asarray
([[
0
,
1
,
2
],
[
3
,
4
,
5
]]))
==
numpy
.
asarray
([[[
0
],
[
1
]],
[[
2
],
[
3
]],
[[
4
],
[
5
]]]))
assert
(
f
.
maker
.
fgraph
.
toposort
()[
-
1
]
.
outputs
[
0
]
.
type
.
broadcastable
==
(
False
,
False
,
True
))
def
test_m1
(
self
):
def
test_m1
(
self
):
t
=
tensor3
()
t
=
tensor3
()
rng
=
numpy
.
random
.
RandomState
(
seed
=
utt
.
fetch_seed
())
rng
=
numpy
.
random
.
RandomState
(
seed
=
utt
.
fetch_seed
())
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论