Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5c907045
提交
5c907045
authored
6月 07, 2011
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix optimizations to exit gracefully when env.feature_shape is not present.
Also test it. This should fix the problem experienced by Justin Bayer.
上级
40274190
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
22 行增加
和
0 行删除
+22
-0
opt.py
theano/tensor/opt.py
+12
-0
test_opt.py
theano/tensor/tests/test_opt.py
+10
-0
没有找到文件。
theano/tensor/opt.py
浏览文件 @
5c907045
...
...
@@ -841,6 +841,9 @@ def local_useless_alloc(node):
@gof.local_optimizer
([
T
.
_shape
])
def
local_shape_to_shape_i
(
node
):
if
node
.
op
==
T
.
_shape
:
# This optimization needs ShapeOpt and env.shape_feature
if
not
hasattr
(
node
.
env
,
'shape_feature'
):
return
shape_feature
=
node
.
env
.
shape_feature
return
[
shape_feature
.
make_vector_shape
(
node
.
inputs
[
0
])]
...
...
@@ -866,6 +869,9 @@ def local_subtensor_make_vector(node):
# [a,b,c][0:2] -> [a,b]
# we can do this for constant indexes
if
isinstance
(
node
.
op
,
T
.
Subtensor
):
# This optimization needs ShapeOpt and env.shape_feature
if
not
hasattr
(
node
.
env
,
'shape_feature'
):
return
shape_feature
=
node
.
env
.
shape_feature
x
=
node
.
inputs
[
0
]
if
x
.
owner
and
x
.
owner
.
op
==
make_vector
:
...
...
@@ -1173,6 +1179,9 @@ def local_useless_subtensor(node):
Remove Subtensor if it take the full input
"""
if
isinstance
(
node
.
op
,
T
.
Subtensor
):
# This optimization needs ShapeOpt and env.shape_feature
if
not
hasattr
(
node
.
env
,
'shape_feature'
):
return
shape_of
=
node
.
env
.
shape_feature
.
shape_of
node_input_idx
=
1
for
pos
,
idx
in
enumerate
(
node
.
op
.
idx_list
):
...
...
@@ -1778,6 +1787,9 @@ if 0:
@gof.local_optimizer
([])
def
local_sum_over_empty
(
node
):
if
isinstance
(
node
.
op
,
T
.
Sum
):
# This optimization needs ShapeOpt and env.shape_feature
if
not
hasattr
(
node
.
env
,
'shape_feature'
):
return
y
,
=
node
.
outputs
y_shape
=
node
.
env
.
shape_feature
.
shape_of
[
y
]
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
5c907045
...
...
@@ -1697,6 +1697,16 @@ class test_shapeoptimizer(unittest.TestCase):
assert
identity_noshape
not
in
h_ops
assert
identity_shape
not
in
h_ops
def
test_no_shapeopt
(
self
):
# Test that a basic example works even when ShapeOpt is excluded
X
=
T
.
matrix
()
expr
=
X
.
shape
[
0
]
mode
=
theano
.
compile
.
get_default_mode
()
.
excluding
(
'ShapeOpt'
)
f
=
theano
.
function
([
X
],
expr
,
mode
=
mode
)
print
f
([[
1
,
2
],
[
2
,
3
]])
class
test_assert
(
unittest
.
TestCase
):
def
test0
(
self
):
x
=
T
.
scalar
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论