Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7ccbc028
提交
7ccbc028
authored
11月 28, 2012
作者:
Ian Goodfellow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use isinstance(foo, python25.OrderedDict) instead of 'Ordered' in
str(type(foo))
上级
5d8ae96e
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
13 行增加
和
8 行删除
+13
-8
function.py
theano/compile/function.py
+3
-3
scan.py
theano/sandbox/scan.py
+5
-2
scan_utils.py
theano/scan_module/scan_utils.py
+5
-3
没有找到文件。
theano/compile/function.py
浏览文件 @
7ccbc028
...
@@ -13,6 +13,7 @@ from profiling import ProfileStats
...
@@ -13,6 +13,7 @@ from profiling import ProfileStats
from
pfunc
import
pfunc
from
pfunc
import
pfunc
from
numpy
import
any
# to work in python 2.4
from
numpy
import
any
# to work in python 2.4
import
warnings
import
warnings
from
theano
import
gof
def
function
(
inputs
,
outputs
=
None
,
mode
=
None
,
updates
=
None
,
givens
=
None
,
def
function
(
inputs
,
outputs
=
None
,
mode
=
None
,
updates
=
None
,
givens
=
None
,
no_default_updates
=
False
,
accept_inplace
=
False
,
name
=
None
,
no_default_updates
=
False
,
accept_inplace
=
False
,
name
=
None
,
...
@@ -163,9 +164,8 @@ def function(inputs, outputs=None, mode=None, updates=None, givens=None,
...
@@ -163,9 +164,8 @@ def function(inputs, outputs=None, mode=None, updates=None, givens=None,
if
updates
is
None
:
if
updates
is
None
:
updates
=
[]
updates
=
[]
# I use the string value of the type to do type checking here since
if
isinstance
(
updates
,
dict
)
and
\
# OrderedDict is not available in python2.4
not
isinstance
(
updates
,
gof
.
python25
.
OrderedDict
):
if
isinstance
(
updates
,
dict
)
and
'Ordered'
not
in
str
(
type
(
updates
)):
warnings
.
warn
(
"Expected OrderedDict, got "
+
str
(
type
(
updates
))
+
"Using "
warnings
.
warn
(
"Expected OrderedDict, got "
+
str
(
type
(
updates
))
+
"Using "
"a standard dictionary here results in "
"a standard dictionary here results in "
"non-deterministic behavior. You should use an OrderedDict"
"non-deterministic behavior. You should use an OrderedDict"
...
...
theano/sandbox/scan.py
浏览文件 @
7ccbc028
...
@@ -13,6 +13,7 @@ __contact__ = "Razvan Pascanu <r.pascanu@gmail>"
...
@@ -13,6 +13,7 @@ __contact__ = "Razvan Pascanu <r.pascanu@gmail>"
import
itertools
import
itertools
import
logging
import
logging
import
numpy
import
numpy
import
warnings
from
theano.compile
import
SharedVariable
,
function
from
theano.compile
import
SharedVariable
,
function
from
theano
import
compile
from
theano
import
compile
...
@@ -468,8 +469,10 @@ def scan(fn,
...
@@ -468,8 +469,10 @@ def scan(fn,
dummy_outs
.
append
(
condition
)
dummy_outs
.
append
(
condition
)
# If we use a regular dict here, the results are non-deterministic
# If we use a regular dict here, the results are non-deterministic
assert
isinstance
(
updates
,
(
list
,
tuple
))
or
(
isinstance
(
updates
,
dict
)
and
\
if
not
isinstance
(
updates
,
(
list
,
tuple
)):
'Ordered'
in
str
(
type
(
updates
)))
if
isinstance
(
updates
,
dict
)
and
\
not
isinstance
(
updates
,
gof
.
python25
.
OrderedDict
):
warnings
.
warn
(
"Using non-deterministic dictionary."
)
dummy_f
=
function
(
dummy_args
,
dummy_f
=
function
(
dummy_args
,
dummy_outs
,
dummy_outs
,
...
...
theano/scan_module/scan_utils.py
浏览文件 @
7ccbc028
...
@@ -18,6 +18,7 @@ import logging
...
@@ -18,6 +18,7 @@ import logging
from
itertools
import
izip
from
itertools
import
izip
import
numpy
import
numpy
import
warnings
import
theano
import
theano
from
theano.compile.pfunc
import
rebuild_collect_shared
from
theano.compile.pfunc
import
rebuild_collect_shared
...
@@ -203,9 +204,10 @@ def get_updates_and_outputs(ls):
...
@@ -203,9 +204,10 @@ def get_updates_and_outputs(ls):
def
is_updates
(
elem
):
def
is_updates
(
elem
):
if
isinstance
(
elem
,
dict
):
if
isinstance
(
elem
,
dict
):
# Make sure the updates will be applied in a deterministic order
# Make sure the updates will be applied in a deterministic order
if
'Ordered'
not
in
str
(
type
(
elem
)):
if
not
isinstance
(
elem
,
gof
.
python25
.
OrderedDict
):
raise
TypeError
(
"Expected OrderedDict or OrderedUpdates, got "
\
warnings
.
warn
(
"Expected OrderedDict or OrderedUpdates, got "
\
+
str
(
type
(
elem
)))
+
str
(
type
(
elem
))
+
". This can make your script non-"
"deterministic."
)
return
True
return
True
# Dictionaries can be given as lists of tuples
# Dictionaries can be given as lists of tuples
if
(
isinstance
(
elem
,
(
list
,
tuple
))
and
if
(
isinstance
(
elem
,
(
list
,
tuple
))
and
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论