Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f7774000
提交
f7774000
authored
1月 13, 2010
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed duplicate-update bug in pfunc
上级
c23320a7
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
9 行增加
和
1 行删除
+9
-1
pfunc.py
theano/compile/pfunc.py
+3
-0
test_pfunc.py
theano/compile/tests/test_pfunc.py
+6
-1
没有找到文件。
theano/compile/pfunc.py
浏览文件 @
f7774000
...
@@ -157,6 +157,9 @@ def pfunc(params, outputs=None, mode=None, updates=[], givens=[], accept_inplace
...
@@ -157,6 +157,9 @@ def pfunc(params, outputs=None, mode=None, updates=[], givens=[], accept_inplace
for
(
store_into
,
update_val
)
in
iter_over_pairs
(
updates
):
for
(
store_into
,
update_val
)
in
iter_over_pairs
(
updates
):
if
not
isinstance
(
store_into
,
SharedVariable
):
if
not
isinstance
(
store_into
,
SharedVariable
):
raise
TypeError
(
'update target must be a SharedVariable'
,
store_into
)
raise
TypeError
(
'update target must be a SharedVariable'
,
store_into
)
if
store_into
in
new_updates
:
raise
ValueError
(
'this shared variable already has an update expression'
,
(
store_into
,
new_updates
[
store_into
]))
update_val
=
v_clone
(
store_into
.
filter_update
(
update_val
))
update_val
=
v_clone
(
store_into
.
filter_update
(
update_val
))
if
update_val
.
type
!=
store_into
.
type
:
if
update_val
.
type
!=
store_into
.
type
:
raise
TypeError
(
'an update must have the same type as the original shared variable'
,
raise
TypeError
(
'an update must have the same type as the original shared variable'
,
...
...
theano/compile/tests/test_pfunc.py
浏览文件 @
f7774000
...
@@ -2,7 +2,7 @@ import numpy
...
@@ -2,7 +2,7 @@ import numpy
import
unittest
import
unittest
import
copy
import
copy
import
theano
import
theano
from
theano.tensor
import
Tensor
,
dmatrix
,
dvector
,
lscalar
from
theano.tensor
import
Tensor
,
dmatrix
,
dvector
,
lscalar
,
dmatrices
from
theano
import
tensor
from
theano
import
tensor
from
theano.compile.sharedvalue
import
*
from
theano.compile.sharedvalue
import
*
...
@@ -193,6 +193,11 @@ class Test_pfunc(unittest.TestCase):
...
@@ -193,6 +193,11 @@ class Test_pfunc(unittest.TestCase):
inc_by_y
()
inc_by_y
()
self
.
failUnless
(
x
.
value
==
1
)
self
.
failUnless
(
x
.
value
==
1
)
def
test_duplicate_updates
(
self
):
x
,
y
=
dmatrices
(
'x'
,
'y'
)
z
=
shared
(
numpy
.
ones
((
2
,
3
)))
self
.
failUnlessRaises
(
ValueError
,
theano
.
function
,
[
x
,
y
],
[
z
],
updates
=
[(
z
,
z
+
x
+
y
),
(
z
,
z
-
x
)])
def
test_givens
(
self
):
def
test_givens
(
self
):
x
=
shared
(
0
)
x
=
shared
(
0
)
assign
=
pfunc
([],
x
,
givens
=
{
x
:
3
})
assign
=
pfunc
([],
x
,
givens
=
{
x
:
3
})
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论