Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c0b57d75
提交
c0b57d75
authored
3月 15, 2011
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Indentation.
上级
d8cee62e
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
11 行增加
和
12 行删除
+11
-12
sharedvalue.py
theano/compile/sharedvalue.py
+11
-12
没有找到文件。
theano/compile/sharedvalue.py
浏览文件 @
c0b57d75
...
@@ -22,8 +22,8 @@ def warning(*msg): _logger.warning(' '.join(str(m) for m in msg))
...
@@ -22,8 +22,8 @@ def warning(*msg): _logger.warning(' '.join(str(m) for m in msg))
def
error
(
*
msg
):
_logger
.
error
(
' '
.
join
(
str
(
m
)
for
m
in
msg
))
def
error
(
*
msg
):
_logger
.
error
(
' '
.
join
(
str
(
m
)
for
m
in
msg
))
AddConfigVar
(
'shared.value_borrows'
,
AddConfigVar
(
'shared.value_borrows'
,
(
"False: shared variables 'value' property is guaranteed to not"
(
"False: shared variables 'value' property is guaranteed to not"
" alias theano-managed memory. True: no guarantee, but faster."
" alias theano-managed memory. True: no guarantee, but faster."
" For more control consider using shared.get_value() instead."
),
" For more control consider using shared.get_value() instead."
),
BoolParam
(
True
))
BoolParam
(
True
))
...
@@ -86,7 +86,7 @@ class SharedVariable(Variable):
...
@@ -86,7 +86,7 @@ class SharedVariable(Variable):
def
get_value
(
self
,
borrow
=
False
,
return_internal_type
=
False
):
def
get_value
(
self
,
borrow
=
False
,
return_internal_type
=
False
):
"""Get the non-symbolic value associated with this SharedVariable.
"""Get the non-symbolic value associated with this SharedVariable.
:param borrow:
:param borrow:
True to permit returning of an object aliased to internal memory.
True to permit returning of an object aliased to internal memory.
:param return_internal_type:
:param return_internal_type:
True to permit the returning of an arbitrary type object used internally to store
True to permit the returning of an arbitrary type object used internally to store
...
@@ -95,7 +95,7 @@ class SharedVariable(Variable):
...
@@ -95,7 +95,7 @@ class SharedVariable(Variable):
Only with borrow=False and return_internal_type=True does this function guarantee that
Only with borrow=False and return_internal_type=True does this function guarantee that
you actually get the internal object. But in that case, you may get different return
you actually get the internal object. But in that case, you may get different return
types when using different compute devices.
types when using different compute devices.
"""
"""
if
borrow
:
if
borrow
:
return
self
.
container
.
value
return
self
.
container
.
value
...
@@ -105,10 +105,10 @@ class SharedVariable(Variable):
...
@@ -105,10 +105,10 @@ class SharedVariable(Variable):
def
set_value
(
self
,
new_value
,
borrow
=
False
):
def
set_value
(
self
,
new_value
,
borrow
=
False
):
"""Set the non-symbolic value associated with this SharedVariable.
"""Set the non-symbolic value associated with this SharedVariable.
:param borrow:
:param borrow:
True to use the new_value directly, potentially creating problems
True to use the new_value directly, potentially creating problems
related to aliased memory.
related to aliased memory.
Changes to this value will be visible to all functions using this SharedVariable.
Changes to this value will be visible to all functions using this SharedVariable.
"""
"""
if
borrow
:
if
borrow
:
...
@@ -119,7 +119,7 @@ class SharedVariable(Variable):
...
@@ -119,7 +119,7 @@ class SharedVariable(Variable):
def
clone
(
self
):
def
clone
(
self
):
cp
=
self
.
__class__
(
cp
=
self
.
__class__
(
name
=
self
.
name
,
name
=
self
.
name
,
type
=
self
.
type
,
type
=
self
.
type
,
value
=
None
,
value
=
None
,
strict
=
None
,
strict
=
None
,
container
=
self
.
container
)
container
=
self
.
container
)
...
@@ -135,8 +135,8 @@ class SharedVariable(Variable):
...
@@ -135,8 +135,8 @@ class SharedVariable(Variable):
# Semantically things are clearer when using non-borrow versions. That should be the
# Semantically things are clearer when using non-borrow versions. That should be the
# default. The default support transparently (if slowly) when the 'raw' value is in a
# default. The default support transparently (if slowly) when the 'raw' value is in a
# different memory space (e.g. GPU or other machine).
# different memory space (e.g. GPU or other machine).
value
=
property
(
_value_get
,
_value_set
,
value
=
property
(
_value_get
,
_value_set
,
doc
=
(
"shortcut for self.get_value() and self.set_value()."
doc
=
(
"shortcut for self.get_value() and self.set_value()."
"The `borrow` argument to these methods is read from "
"The `borrow` argument to these methods is read from "
"`theano.config.shared.value_borrows`"
))
"`theano.config.shared.value_borrows`"
))
...
@@ -174,10 +174,10 @@ def shared(value, name=None, strict=False, allow_downcast=None, **kwargs):
...
@@ -174,10 +174,10 @@ def shared(value, name=None, strict=False, allow_downcast=None, **kwargs):
This function iterates over constructor functions (see `shared_constructor`) to find a
This function iterates over constructor functions (see `shared_constructor`) to find a
suitable SharedVariable subclass.
suitable SharedVariable subclass.
:note:
:note:
By passing kwargs, you effectively limit the set of potential constructors to those that
By passing kwargs, you effectively limit the set of potential constructors to those that
can accept those kwargs.
can accept those kwargs.
"""
"""
for
ctor
in
reversed
(
shared
.
constructors
):
for
ctor
in
reversed
(
shared
.
constructors
):
try
:
try
:
...
@@ -198,4 +198,3 @@ def generic_constructor(value, name=None, strict=False, allow_downcast=None):
...
@@ -198,4 +198,3 @@ def generic_constructor(value, name=None, strict=False, allow_downcast=None):
"""SharedVariable Constructor"""
"""SharedVariable Constructor"""
return
SharedVariable
(
type
=
generic
,
value
=
value
,
name
=
name
,
strict
=
strict
,
return
SharedVariable
(
type
=
generic
,
value
=
value
,
name
=
name
,
strict
=
strict
,
allow_downcast
=
allow_downcast
)
allow_downcast
=
allow_downcast
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论