Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
27780095
提交
27780095
authored
11月 25, 2011
作者:
Razvan Pascanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Documented `equal_computations` and removed useless flag strict.
上级
469803aa
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
19 行增加
和
16 行删除
+19
-16
scan_op.py
theano/scan_module/scan_op.py
+1
-2
scan_utils.py
theano/scan_module/scan_utils.py
+18
-14
没有找到文件。
theano/scan_module/scan_op.py
浏览文件 @
27780095
...
@@ -286,8 +286,7 @@ class Scan(PureOp):
...
@@ -286,8 +286,7 @@ class Scan(PureOp):
if
not
scan_utils
.
equal_computations
(
self
.
outputs
,
if
not
scan_utils
.
equal_computations
(
self
.
outputs
,
other
.
outputs
,
other
.
outputs
,
self
.
inputs
,
self
.
inputs
,
other
.
inputs
,
other
.
inputs
):
strict
=
True
):
return
False
return
False
# If they do, then they need to match in other small details
# If they do, then they need to match in other small details
...
...
theano/scan_module/scan_utils.py
浏览文件 @
27780095
...
@@ -268,11 +268,21 @@ def expand(tensor_var, size):
...
@@ -268,11 +268,21 @@ def expand(tensor_var, size):
return
tensor
.
set_subtensor
(
empty
[:
shapes
[
0
]],
tensor_var
)
return
tensor
.
set_subtensor
(
empty
[:
shapes
[
0
]],
tensor_var
)
def
equal_computations
(
xs
,
ys
,
in_xs
=
None
,
in_ys
=
None
,
strict
=
True
):
def
equal_computations
(
xs
,
ys
,
in_xs
=
None
,
in_ys
=
None
):
'''
'''Checks if Theano graphs represent the same computations.
Checks if to theano graphs represent the same computations (with
equivalence of inputs defined by map). Inputs are always assumed
The two lists `xs`, `ys` should have the same number of entries. The
equal if strict is set to False.
function checks if for any corresponding pair `(x,y)` from `zip(xs,ys)`
`x` and `y` represent the same computations on the same variables
(unless equivalences are provided unsing `in_xs`, `in_ys`)
If `in_xs` and `in_ys` are provided, then these nodes are considered
equivalent even if they do not compare equal (they should however have
the same type). These lists could be used for example to provide
equivalence between inputs of two different graphs if what we want is
actually to see if (regardless of the input units) the two graph
actually perform the same computations on them.
'''
'''
if
in_xs
is
None
:
if
in_xs
is
None
:
in_xs
=
[]
in_xs
=
[]
...
@@ -314,12 +324,8 @@ def equal_computations(xs, ys, in_xs=None, in_ys=None, strict=True):
...
@@ -314,12 +324,8 @@ def equal_computations(xs, ys, in_xs=None, in_ys=None, strict=True):
else
:
else
:
pass
pass
else
:
else
:
if
not
strict
:
if
(
dx
,
dy
)
not
in
common
:
if
dx
.
type
!=
dy
.
type
:
return
False
return
False
else
:
if
(
dx
,
dy
)
not
in
common
:
return
False
while
cont
and
idx
<
n_nodes
:
while
cont
and
idx
<
n_nodes
:
nd_x
=
nds_x
[
idx
]
nd_x
=
nds_x
[
idx
]
...
@@ -333,7 +339,7 @@ def equal_computations(xs, ys, in_xs=None, in_ys=None, strict=True):
...
@@ -333,7 +339,7 @@ def equal_computations(xs, ys, in_xs=None, in_ys=None, strict=True):
else
:
else
:
for
dx
,
dy
in
zip
(
nd_x
.
inputs
,
nd_y
.
inputs
):
for
dx
,
dy
in
zip
(
nd_x
.
inputs
,
nd_y
.
inputs
):
if
(
dx
,
dy
)
not
in
common
:
if
(
dx
,
dy
)
not
in
common
:
if
strict
and
dx
!=
dy
:
if
dx
!=
dy
:
if
(
isinstance
(
dx
,
tensor
.
Constant
)
and
if
(
isinstance
(
dx
,
tensor
.
Constant
)
and
isinstance
(
dy
,
tensor
.
Constant
)):
isinstance
(
dy
,
tensor
.
Constant
)):
if
not
(
numpy
.
all
(
dx
.
data
==
dy
.
data
)
and
if
not
(
numpy
.
all
(
dx
.
data
==
dy
.
data
)
and
...
@@ -344,8 +350,6 @@ def equal_computations(xs, ys, in_xs=None, in_ys=None, strict=True):
...
@@ -344,8 +350,6 @@ def equal_computations(xs, ys, in_xs=None, in_ys=None, strict=True):
pass
pass
else
:
else
:
cont
=
False
cont
=
False
else
:
cont
=
cont
and
(
dx
.
type
==
dy
.
type
)
if
cont
:
if
cont
:
for
dx
,
dy
in
zip
(
nd_x
.
outputs
,
nd_y
.
outputs
):
for
dx
,
dy
in
zip
(
nd_x
.
outputs
,
nd_y
.
outputs
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论