Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6f315a3b
提交
6f315a3b
authored
8月 16, 2012
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix corner case in cvm updates, add test.
The bug appeared when some shared variable was updated with itself, the values of update expressions would be assigned to incorrect shared variables.
上级
2f9368a2
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
36 行增加
和
1 行删除
+36
-1
test_pfunc.py
theano/compile/tests/test_pfunc.py
+36
-0
vm.py
theano/gof/vm.py
+0
-1
没有找到文件。
theano/compile/tests/test_pfunc.py
浏览文件 @
6f315a3b
...
...
@@ -618,6 +618,42 @@ class Test_pfunc(unittest.TestCase):
self
.
assertRaises
(
theano
.
compile
.
UnusedInputError
,
theano
.
function
,
[
x
,
x
,
x
],
x
)
def
test_update_same
(
self
):
# There was a bug in CVM, triggered when a shared variable
# was its own update expression.
a
=
shared
(
1.
,
'a'
)
b
=
shared
(
numpy
.
ones
((
2
,
3
)),
'b'
)
# The order of the variables is not determined, so we try
# both shared variables.
f
=
theano
.
function
([],
[],
updates
=
{
a
:
a
,
b
:
(
2
*
b
)})
g
=
theano
.
function
([],
[],
updates
=
{
a
:
(
a
*
2
),
b
:
b
})
f
()
assert
a
.
get_value
(
borrow
=
True
)
.
shape
==
(),
a
.
get_value
()
assert
b
.
get_value
(
borrow
=
True
)
.
shape
==
(
2
,
3
),
b
.
get_value
()
g
()
assert
a
.
get_value
(
borrow
=
True
)
.
shape
==
(),
a
.
get_value
()
assert
b
.
get_value
(
borrow
=
True
)
.
shape
==
(
2
,
3
),
b
.
get_value
()
def
test_update_equiv
(
self
):
# Like test_update_same, but the update expression is simplified until
# it is found to be equal to the original variable
a
=
shared
(
1.
,
'a'
)
b
=
shared
(
numpy
.
ones
((
2
,
3
)),
'b'
)
# The order of the variables is not determined, so we try
# both shared variables.
f
=
theano
.
function
([],
[],
updates
=
{
a
:
a
,
b
:
(
2
*
b
-
b
)})
g
=
theano
.
function
([],
[],
updates
=
{
a
:
(
a
*
2
-
a
),
b
:
b
})
f
()
assert
a
.
get_value
(
borrow
=
True
)
.
shape
==
(),
a
.
get_value
()
assert
b
.
get_value
(
borrow
=
True
)
.
shape
==
(
2
,
3
),
b
.
get_value
()
g
()
assert
a
.
get_value
(
borrow
=
True
)
.
shape
==
(),
a
.
get_value
()
assert
b
.
get_value
(
borrow
=
True
)
.
shape
==
(
2
,
3
),
b
.
get_value
()
class
Test_aliasing_rules
(
unittest
.
TestCase
):
"""
...
...
theano/gof/vm.py
浏览文件 @
6f315a3b
...
...
@@ -716,7 +716,6 @@ class VM_Linker(link.LocalLinker):
update_storage
=
[]
update_in_from_out
=
{}
for
(
ivar
,
ovar
)
in
updated_vars
.
items
():
if
ivar
!=
ovar
:
update_in_from_out
[
vars_idx
[
ovar
]]
=
vars_idx
[
ivar
]
for
oidx
in
output_vars
:
if
oidx
in
update_in_from_out
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论