Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
fb3e7e66
提交
fb3e7e66
authored
8月 16, 2010
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pfunc - fixing tests to new shared variables policy
上级
5960a4ea
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
10 行增加
和
5 行删除
+10
-5
test_pfunc.py
theano/compile/tests/test_pfunc.py
+10
-5
没有找到文件。
theano/compile/tests/test_pfunc.py
浏览文件 @
fb3e7e66
...
@@ -8,6 +8,12 @@ from theano import tensor
...
@@ -8,6 +8,12 @@ from theano import tensor
from
theano.compile.sharedvalue
import
*
from
theano.compile.sharedvalue
import
*
from
theano.compile.pfunc
import
*
from
theano.compile.pfunc
import
*
def
data_of
(
s
):
"""Return the raw value of a shared variable"""
return
s
.
container
.
storage
[
0
]
class
Test_pfunc
(
unittest
.
TestCase
):
class
Test_pfunc
(
unittest
.
TestCase
):
def
test_doc
(
self
):
def
test_doc
(
self
):
...
@@ -135,9 +141,11 @@ class Test_pfunc(unittest.TestCase):
...
@@ -135,9 +141,11 @@ class Test_pfunc(unittest.TestCase):
def
test_shared_mutable
(
self
):
def
test_shared_mutable
(
self
):
bval
=
numpy
.
arange
(
5
)
bval
=
numpy
.
arange
(
5
)
b
=
shared
(
bval
)
b
=
shared
(
bval
)
assert
b
.
value
is
bval
b_out
=
b
*
2
b_out
=
b
*
2
assert
b
.
value
is
not
bval
# shared vars copy args.
bval
=
data_of
(
b
)
# so we do this to get at the underlying data
# by default, shared are not mutable unless doing an explicit update
# by default, shared are not mutable unless doing an explicit update
f
=
pfunc
([],
[
b_out
],
mode
=
'FAST_RUN'
)
f
=
pfunc
([],
[
b_out
],
mode
=
'FAST_RUN'
)
assert
(
f
()
==
numpy
.
arange
(
5
)
*
2
)
.
all
()
assert
(
f
()
==
numpy
.
arange
(
5
)
*
2
)
.
all
()
...
@@ -152,6 +160,7 @@ class Test_pfunc(unittest.TestCase):
...
@@ -152,6 +160,7 @@ class Test_pfunc(unittest.TestCase):
# do not depend on updates being in-place though!
# do not depend on updates being in-place though!
bval
=
numpy
.
arange
(
5
)
bval
=
numpy
.
arange
(
5
)
b
.
value
=
bval
b
.
value
=
bval
bval
=
data_of
(
b
)
f
=
pfunc
([],
[
b_out
],
updates
=
[(
b
,
b_out
+
3
)],
mode
=
'FAST_RUN'
)
f
=
pfunc
([],
[
b_out
],
updates
=
[(
b
,
b_out
+
3
)],
mode
=
'FAST_RUN'
)
assert
(
f
()
==
numpy
.
arange
(
5
)
*
2
)
.
all
()
assert
(
f
()
==
numpy
.
arange
(
5
)
*
2
)
.
all
()
assert
(
b
.
value
==
((
numpy
.
arange
(
5
)
*
2
)
+
3
))
.
all
()
# because of the update
assert
(
b
.
value
==
((
numpy
.
arange
(
5
)
*
2
)
+
3
))
.
all
()
# because of the update
...
@@ -479,10 +488,6 @@ class Test_pfunc(unittest.TestCase):
...
@@ -479,10 +488,6 @@ class Test_pfunc(unittest.TestCase):
def
data_of
(
s
):
"""Return the raw value of a shared variable"""
return
s
.
container
.
storage
[
0
]
class
Test_aliasing_rules
(
unittest
.
TestCase
):
class
Test_aliasing_rules
(
unittest
.
TestCase
):
"""
"""
1. Theano manages its own memory space, which typically does not overlap with the memory of
1. Theano manages its own memory space, which typically does not overlap with the memory of
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论