Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0e9fe3a9
提交
0e9fe3a9
authored
9月 30, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
In a work around, warn about the problem so that the real cause get fixed.
The added test currently fail.
上级
77c4f4d1
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
23 行增加
和
1 行删除
+23
-1
opt.py
theano/gof/opt.py
+7
-1
test_opt.py
theano/gof/tests/test_opt.py
+14
-0
subtensor.py
theano/tensor/subtensor.py
+2
-0
没有找到文件。
theano/gof/opt.py
浏览文件 @
0e9fe3a9
...
@@ -8,6 +8,7 @@ import logging
...
@@ -8,6 +8,7 @@ import logging
import
pdb
import
pdb
import
sys
import
sys
import
time
import
time
import
warnings
import
numpy
import
numpy
...
@@ -731,7 +732,8 @@ def pre_constant_merge(vars):
...
@@ -731,7 +732,8 @@ def pre_constant_merge(vars):
seen_var
=
set
()
seen_var
=
set
()
# signature -> variable (for constants)
# signature -> variable (for constants)
const_sig_inv
=
{}
const_sig_inv
=
{}
if
isinstance
(
vars
,
graph
.
Variable
):
vars
=
[
vars
]
def
recursive_merge
(
var
):
def
recursive_merge
(
var
):
if
var
in
seen_var
:
if
var
in
seen_var
:
return
var
return
var
...
@@ -747,6 +749,10 @@ def pre_constant_merge(vars):
...
@@ -747,6 +749,10 @@ def pre_constant_merge(vars):
return
const_sig_inv
[
sig
]
return
const_sig_inv
[
sig
]
const_sig_inv
[
sig
]
=
var
const_sig_inv
[
sig
]
=
var
except
TypeError
:
# unhashable type
except
TypeError
:
# unhashable type
warnings
.
warn
(
"We work around a problem, the following variable"
" signature isn't hashable. Please, report this to"
" theano-dev so that the better fix is done.
%
s"
%
var
)
# Some python object like slice aren't hashable. So
# Some python object like slice aren't hashable. So
# don't merge them here.
# don't merge them here.
pass
pass
...
...
theano/gof/tests/test_opt.py
浏览文件 @
0e9fe3a9
...
@@ -409,3 +409,17 @@ class TestEquilibrium(object):
...
@@ -409,3 +409,17 @@ class TestEquilibrium(object):
_logger
.
setLevel
(
oldlevel
)
_logger
.
setLevel
(
oldlevel
)
#print 'after', g
#print 'after', g
assert
str
(
g
)
==
'[Op1(x, y)]'
assert
str
(
g
)
==
'[Op1(x, y)]'
def
test_pre_constant_merge_slice
():
ms
=
theano
.
tensor
.
type_other
.
MakeSlice
()(
1
)
pre_constant_merge
([
ms
])
const_slice
=
theano
.
gof
.
graph
.
Constant
(
type
=
theano
.
tensor
.
type_other
.
slicetype
,
data
=
slice
(
1
,
None
,
2
))
adv
=
theano
.
tensor
.
subtensor
.
AdvancedSubtensor
()(
theano
.
tensor
.
matrix
(),
[
2
,
3
],
const_slice
)
pre_constant_merge
(
adv
)
# Make sure constant of slice signature is hashable.
hash
(
const_slice
.
signature
())
theano/tensor/subtensor.py
浏览文件 @
0e9fe3a9
...
@@ -1807,6 +1807,8 @@ def as_index_variable(idx):
...
@@ -1807,6 +1807,8 @@ def as_index_variable(idx):
return
NoneConst
.
clone
()
return
NoneConst
.
clone
()
if
isinstance
(
idx
,
slice
):
if
isinstance
(
idx
,
slice
):
return
make_slice
(
idx
)
return
make_slice
(
idx
)
if
isinstance
(
idx
,
gof
.
Variable
)
and
isinstance
(
idx
.
type
,
SliceType
):
return
idx
idx
=
theano
.
tensor
.
as_tensor_variable
(
idx
)
idx
=
theano
.
tensor
.
as_tensor_variable
(
idx
)
if
idx
.
type
.
dtype
[:
3
]
not
in
(
'int'
,
'uin'
):
if
idx
.
type
.
dtype
[:
3
]
not
in
(
'int'
,
'uin'
):
raise
TypeError
(
'index must be integers'
)
raise
TypeError
(
'index must be integers'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论