Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d24c03a0
提交
d24c03a0
authored
12月 04, 2012
作者:
Ian Goodfellow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
got rid of the whitelisting, it was making optimizations fail
上级
a702ad7f
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
20 行增加
和
9 行删除
+20
-9
destroyhandler.py
theano/gof/destroyhandler.py
+1
-1
ordered_set.py
theano/misc/ordered_set.py
+16
-8
test_determinism.py
theano/tests/test_determinism.py
+3
-0
没有找到文件。
theano/gof/destroyhandler.py
浏览文件 @
d24c03a0
...
...
@@ -960,7 +960,7 @@ class DestroyHandler(toolbox.Bookkeeper):
tolerate_same
=
getattr
(
app
.
op
,
'destroyhandler_tolerate_same'
,
[])
assert
isinstance
(
tolerate_same
,
list
)
tolerated
=
OrderedSet
((
idx1
for
idx0
,
idx1
in
tolerate_same
if
idx0
==
destroyed_idx
))
if
idx0
==
destroyed_idx
)
,
known_deterministc
=
True
)
tolerated
.
add
(
destroyed_idx
)
tolerate_aliased
=
getattr
(
app
.
op
,
'destroyhandler_tolerate_aliased'
,
[])
ignored
=
OrderedSet
(
idx1
for
idx0
,
idx1
in
tolerate_aliased
...
...
theano/misc/ordered_set.py
浏览文件 @
d24c03a0
...
...
@@ -7,9 +7,17 @@ except ImportError:
from
theano.gof.python25
import
OrderedDict
import
types
def
check_deterministic
(
iterable
):
if
not
isinstance
(
iterable
,
(
list
,
tuple
,
OrderedSet
,
types
.
GeneratorType
)):
raise
TypeError
(
type
(
iterable
))
def
check_deterministic
(
iterable
,
known_deterministic
):
# Most places where OrderedSet is used, theano interprets any exception
# whatsoever as a problem that an optimization introduced into the graph.
# If I raise a TypeError when the DestoryHandler tries to do something
# non-deterministic, it will just result in optimizations getting ignored.
# So I must use an assert here. In the long term we should fix the rest of
# theano to use exceptions correctly, so that this can be a TypeError.
if
iterable
is
not
None
:
assert
isinstance
(
iterable
,
(
list
,
tuple
,
OrderedSet
,
types
.
GeneratorType
))
if
isinstance
(
iterable
,
types
.
GeneratorType
):
assert
known_deterministic
if
MutableSet
is
not
None
:
# From http://code.activestate.com/recipes/576694/
...
...
@@ -39,13 +47,13 @@ if MutableSet is not None:
# Added by IG-- pre-existing theano code expected sets
# to have this method
def
update
(
self
,
iterable
):
check_deterministic
(
iterable
)
def
update
(
self
,
iterable
,
known_deterministic
=
False
):
check_deterministic
(
iterable
,
known_deterministic
)
self
|=
iterable
def
__init__
(
self
,
iterable
=
None
):
def
__init__
(
self
,
iterable
=
None
,
known_deterministic
=
False
):
# Checks added by IG
check_deterministic
(
iterable
)
check_deterministic
(
iterable
,
known_deterministic
)
self
.
end
=
end
=
[]
end
+=
[
None
,
end
,
end
]
# sentinel node for doubly linked list
self
.
map
=
{}
# key --> [key, prev, next]
...
...
@@ -118,7 +126,7 @@ else:
if
iterable
is
not
None
:
self
.
update
(
iterable
)
def
update
(
self
,
container
):
def
update
(
self
,
container
,
known_deterministic
=
False
):
check_deterministic
(
container
)
for
elem
in
container
:
self
.
add
(
elem
)
...
...
theano/tests/test_determinism.py
浏览文件 @
d24c03a0
...
...
@@ -72,3 +72,6 @@ def test_determinism_1():
# (Sometimes you sample the same outcome twice in a row)
for
i
in
xrange
(
10
):
run
(
1
,
log
)
if
__name__
==
'__main__'
:
test_determinism_1
()
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论