Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a0290484
提交
a0290484
authored
11月 18, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix Warning in AdvancedSubtensor.infer_shape.
This just remove warning and to not implement the case where the warning was generated.
上级
4c513ba6
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
31 行增加
和
4 行删除
+31
-4
subtensor.py
theano/tensor/subtensor.py
+3
-1
test_subtensor.py
theano/tensor/tests/test_subtensor.py
+21
-0
unittest_tools.py
theano/tests/unittest_tools.py
+7
-3
没有找到文件。
theano/tensor/subtensor.py
浏览文件 @
a0290484
...
@@ -1893,7 +1893,9 @@ class AdvancedSubtensor(Op):
...
@@ -1893,7 +1893,9 @@ class AdvancedSubtensor(Op):
# Really special case
# Really special case
if
len
(
ishapes
)
==
3
:
if
len
(
ishapes
)
==
3
:
xshp
,
ind1shp
,
ind2shp
=
ishapes
xshp
,
ind1shp
,
ind2shp
=
ishapes
if
len
(
xshp
)
==
2
and
len
(
ind1shp
)
==
1
and
len
(
ind2shp
)
==
1
:
if
(
len
(
xshp
)
==
2
and
ind1shp
is
not
None
and
len
(
ind1shp
)
==
1
and
ind2shp
is
not
None
and
len
(
ind2shp
)
==
1
):
# if the graph is correct, we can assume ind1shp[0] and
# if the graph is correct, we can assume ind1shp[0] and
# ind2shp[0] will have the same value.
# ind2shp[0] will have the same value.
# Try to return the one closest to the graph input.
# Try to return the one closest to the graph input.
...
...
theano/tensor/tests/test_subtensor.py
浏览文件 @
a0290484
...
@@ -1455,3 +1455,24 @@ class TestInferShape(utt.InferShapeTester):
...
@@ -1455,3 +1455,24 @@ class TestInferShape(utt.InferShapeTester):
self
.
_compile_and_check
([
admat
,
advec
],
self
.
_compile_and_check
([
admat
,
advec
],
[
set_subtensor
(
admat
[
aivec_val
,
bivec_val
],
advec
)],
[
set_subtensor
(
admat
[
aivec_val
,
bivec_val
],
advec
)],
[
admat_val
,
advec_val
],
AdvancedIncSubtensor
)
[
admat_val
,
advec_val
],
AdvancedIncSubtensor
)
def
test_adv_sub
(
self
):
admat
=
dmatrix
()
aivec
=
lvector
()
bivec
=
lvector
()
admat_val
=
rand
(
5
,
4
)
aivec_val
=
[
1
,
3
,
2
]
bivec_val
=
[
0
,
3
,
3
]
self
.
_compile_and_check
([
admat
,
aivec
,
bivec
],
[
admat
[
aivec
,
bivec
]],
[
admat_val
,
aivec_val
,
bivec_val
],
AdvancedSubtensor
)
# Test case that aren't implemented, but make sure they do not crash.
self
.
_compile_and_check
([
admat
,
aivec
],
[
admat
[
aivec
,
1
:
3
]],
[
admat_val
,
aivec_val
],
AdvancedSubtensor
,
check_topo
=
False
)
self
.
_compile_and_check
([
admat
,
aivec
],
[
admat
[
1
:
3
,
aivec
]],
[
admat_val
,
aivec_val
],
AdvancedSubtensor
,
check_topo
=
False
)
theano/tests/unittest_tools.py
浏览文件 @
a0290484
...
@@ -191,7 +191,7 @@ class InferShapeTester(unittest.TestCase):
...
@@ -191,7 +191,7 @@ class InferShapeTester(unittest.TestCase):
self
.
mode
=
mode
.
including
(
"canonicalize"
)
self
.
mode
=
mode
.
including
(
"canonicalize"
)
def
_compile_and_check
(
self
,
inputs
,
outputs
,
numeric_inputs
,
cls
,
def
_compile_and_check
(
self
,
inputs
,
outputs
,
numeric_inputs
,
cls
,
excluding
=
None
,
warn
=
True
):
excluding
=
None
,
warn
=
True
,
check_topo
=
True
):
"""This tests the infer_shape method only
"""This tests the infer_shape method only
When testing with input values with shapes that take the same
When testing with input values with shapes that take the same
...
@@ -204,6 +204,9 @@ class InferShapeTester(unittest.TestCase):
...
@@ -204,6 +204,9 @@ class InferShapeTester(unittest.TestCase):
matrices will not detect the problem. If warn=True, we emit a
matrices will not detect the problem. If warn=True, we emit a
warning when testing with such values.
warning when testing with such values.
:param check_topo: If True, we check that the Op where removed
from the graph. False is useful to test not implemented case.
"""
"""
mode
=
self
.
mode
mode
=
self
.
mode
if
excluding
:
if
excluding
:
...
@@ -236,8 +239,9 @@ class InferShapeTester(unittest.TestCase):
...
@@ -236,8 +239,9 @@ class InferShapeTester(unittest.TestCase):
mode
=
mode
)
mode
=
mode
)
#theano.printing.debugprint(shapes_function)
#theano.printing.debugprint(shapes_function)
# Check that the Op is removed from the compiled function.
# Check that the Op is removed from the compiled function.
topo_shape
=
shapes_function
.
maker
.
fgraph
.
toposort
()
if
check_topo
:
assert
not
any
(
isinstance
(
t
.
op
,
cls
)
for
t
in
topo_shape
)
topo_shape
=
shapes_function
.
maker
.
fgraph
.
toposort
()
assert
not
any
(
isinstance
(
t
.
op
,
cls
)
for
t
in
topo_shape
)
topo_out
=
outputs_function
.
maker
.
fgraph
.
toposort
()
topo_out
=
outputs_function
.
maker
.
fgraph
.
toposort
()
assert
any
(
isinstance
(
t
.
op
,
cls
)
for
t
in
topo_out
)
assert
any
(
isinstance
(
t
.
op
,
cls
)
for
t
in
topo_out
)
# Check that the shape produced agrees with the actual shape.
# Check that the shape produced agrees with the actual shape.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论