Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3ca1e9ab
提交
3ca1e9ab
authored
8月 14, 2015
作者:
Iban Harlouchet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
numpydoc for theano/compile/io.py
上级
c537f5ef
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
103 行增加
和
112 行删除
+103
-112
io.py
theano/compile/io.py
+103
-112
没有找到文件。
theano/compile/io.py
浏览文件 @
3ca1e9ab
"""Define `SymbolicInput`, `SymbolicOutput`, `In`, `Out` """
"""
Define `SymbolicInput`, `SymbolicOutput`, `In`, `Out`.
"""
from
theano
import
gof
from
theano
import
gof
from
.sharedvalue
import
SharedVariable
from
.sharedvalue
import
SharedVariable
...
@@ -15,52 +17,43 @@ class SymbolicInput(object):
...
@@ -15,52 +17,43 @@ class SymbolicInput(object):
"""
"""
Represents a symbolic input for use with function or FunctionMaker.
Represents a symbolic input for use with function or FunctionMaker.
variable: a Variable instance.
Parameters
This will be assigned a value before running the function,
----------
not computed from its owner.
variable : a Variable instance
This will be assigned a value before running the function, not computed
name: Any type. (If autoname=True, defaults to variable.name).
from its owner.
If name is a valid Python identifier, this input can be set by
name : Any type
kwarg, and its value can be accessed by self.<name>.
If autoname=True, defaults to variable.name.
If name is a valid Python identifier, this input can be set by kwarg,
update: Variable instance (default: None)
and its value can be accessed by self.<name>.
value (see previous) will be replaced with this expression
update : Variable instance
variable after each function call. If update is None, the
Defaults to None. Value (see previous) will be replaced with this
expression variable after each function call. If update is None, the
update will be the default value of the input.
update will be the default value of the input.
mutable : bool
Defaults to False if update is None, True if update is not None.
True: permit the compiled function to modify the python object being
passed as the input.
False: do not permit the compiled function to modify the python object
being passed as the input.
strict : bool
Defaults to False.
True: means that the value you pass for this input must have exactly the
right type.
False: the value you pass for this input may be cast automatically to
the proper type.
allow_downcast : bool or None
Defaults to None. Only applies when `strict` is False.
True: the value you pass for this input can be silently downcasted to
fit the right type, which may lose precision.
False: the value will only be cast to a more general, or precise, type.
None: Almost like False, but allows downcast of Python floats to floatX.
autoname : bool
Defaults to True. See the name option.
implicit : bool
Defaults to False. See help(In). Note that 'None' is not allowed here,
since we are in the symbolic case.
mutable: Bool (default: False if update is None, True if update is
not None)
True: permit the compiled function to modify the python object
being passed as the input
False: do not permit the compiled function to modify the
python object being passed as the input.
strict: Bool (default: False)
True: means that the value you pass for this input must have
exactly the right type
False: the value you pass for this input may be cast
automatically to the proper type
allow_downcast: Bool or None (default: None)
Only applies when `strict` is False.
True: the value you pass for this input can be silently
downcasted to fit the right type, which may lose precision.
False: the value will only be cast to a more general, or
precise, type. None: Almost like False, but allows downcast
of Python floats to floatX.
autoname: Bool (default: True)
See the name option.
implicit: Bool (default: False)
See help(In). Note that 'None' is not allowed here, since we
are in the symbolic case.
"""
"""
def
__init__
(
self
,
variable
,
name
=
None
,
update
=
None
,
mutable
=
None
,
def
__init__
(
self
,
variable
,
name
=
None
,
update
=
None
,
mutable
=
None
,
...
@@ -105,19 +98,22 @@ class SymbolicInputKit(object):
...
@@ -105,19 +98,22 @@ class SymbolicInputKit(object):
A SymbolicInputKit provides the distribute function in order to set or
A SymbolicInputKit provides the distribute function in order to set or
initialize several inputs from a single value. Specialized Kits should
initialize several inputs from a single value. Specialized Kits should
override it.
override it.
"""
"""
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
):
if
not
isinstance
(
name
,
string_types
):
if
not
isinstance
(
name
,
string_types
):
raise
TypeError
(
'na
em
must be a string (got:
%
s)'
%
name
)
raise
TypeError
(
'na
me
must be a string (got:
%
s)'
%
name
)
self
.
name
=
name
self
.
name
=
name
self
.
sinputs
=
[]
self
.
sinputs
=
[]
self
.
variables
=
[]
self
.
variables
=
[]
def
add_input
(
self
,
sinput
):
def
add_input
(
self
,
sinput
):
"""
"""
Add a SymbolicInput to this SymbolicInputKit. It will be given the
Add a SymbolicInput to this SymbolicInputKit.
next available index.
It will be given the next available index.
"""
"""
self
.
sinputs
.
append
(
sinput
)
self
.
sinputs
.
append
(
sinput
)
self
.
variables
.
append
(
sinput
.
variable
)
self
.
variables
.
append
(
sinput
.
variable
)
...
@@ -127,18 +123,20 @@ class SymbolicInputKit(object):
...
@@ -127,18 +123,20 @@ class SymbolicInputKit(object):
Given a list of indices corresponding to SymbolicInputs in this kit
Given a list of indices corresponding to SymbolicInputs in this kit
as well as a corresponding list of containers, initialize all the
as well as a corresponding list of containers, initialize all the
containers using the provided value.
containers using the provided value.
"""
"""
raise
NotImplementedError
raise
NotImplementedError
def
complete
(
self
,
inputs
):
def
complete
(
self
,
inputs
):
"""
"""
Given inputs (a list of Variable instances), checks through all
Given inputs (a list of Variable instances), checks through all the
the SymbolicInputs in the kit and return a sorted list of
SymbolicInputs in the kit and return a sorted list of indices and a list
indices and a list of their corresponding SymbolicInputs such
of their corresponding SymbolicInputs such that each of them represents
that each of them represents some variable in the inputs list.
some variable in the inputs list.
Not all the provided inputs will have a corresponding SymbolicInput in
the kit.
Not all the provided inputs will have a corresponding
SymbolicInput in the kit.
"""
"""
ret
=
[]
ret
=
[]
for
input
in
inputs
:
for
input
in
inputs
:
...
@@ -157,73 +155,62 @@ class In(SymbolicInput):
...
@@ -157,73 +155,62 @@ class In(SymbolicInput):
"""
"""
Represents a symbolic input for use with function or FunctionMaker.
Represents a symbolic input for use with function or FunctionMaker.
variable: a Variable instance.
Parameters
This will be assigned a value before running the function,
----------
not computed from its owner.
variable : a Variable instance
This will be assigned a value before running the function, not computed
name: Any type. (If autoname=True, defaults to variable.name).
from its owner.
If name is a valid Python identifier, this input can be set by
name : Any type
kwarg, and its value can be accessed by self.<name>.
If autoname=True, defaults to variable.name.
If name is a valid Python identifier, this input can be set by kwarg,
value: Any type.
and its value can be accessed by self.<name>.
value : Any type
The initial/default value for this input. If update is None,
The initial/default value for this input. If update is None,
this input acts just like an argument with a default value in
this input acts just like an argument with a default value in
Python. If update is not None, changes to this value will
Python. If update is not None, changes to this value will
"stick around", whether due to an update or a user's explicit
"stick around", whether due to an update or a user's explicit
action.
action.
update : Variable instance
update: Variable instance (default: None)
Defaults to None. Value (see previous) will be replaced with this
value (see previous) will be replaced with this expression
expression variable after each function call. If update is None, the
variable after each function call. If update is None, the
update will be the default value of the input.
update will be the default value of the input.
mutable : bool
mutable: Bool (default: False if update is None, True if update is
Defaults to False if update is None, True if update is not None.
not None)
True: permit the compiled function to modify the python object
True: permit the compiled function to modify the python object
being passed as the input
being passed as the input.
False: do not permit the compiled function to modify the
False: do not permit the compiled function to modify the
python object being passed as the input.
python object being passed as the input.
borrow : bool
borrow: Bool (default: take the same value as mutable)
Default : take the same value as mutable.
True: permit the output of the compiled function to be aliased
True: permit the output of the compiled function to be aliased
to the input
to the input.
False: do not permit any output to be aliased to the input.
False: do not permit any output to be aliased to the input
strict : bool
Defaults to False.
strict: Bool (default: False)
True: means that the value you pass for this input must have exactly
the right type.
True: means that the value you pass for this input must have
False: the value you pass for this input may be cast automatically to
exactly the right type
the proper type.
allow_downcast : bool or None
False: the value you pass for this input may be cast
Defaults to None. Only applies when `strict` is False.
automatically to the proper type
True: the value you pass for this input can be silently downcasted to
fit the right type, which may lose precision.
allow_downcast: Bool or None (default: None)
False: the value will only be cast to a more general, or precise, type.
Only applies when `strict` is False.
None: Almost like False, but allows downcast of Python floats to floatX.
autoname : bool
True: the value you pass for this input can be silently
Defaults to True. See the name option.
downcasted to fit the right type, which may lose precision.
implicit : bool or None
Defaults to None.
False: the value will only be cast to a more general, or
precise, type. None: Almost like False, but allows downcast
of Python floats to floatX.
autoname: Bool (default: True)
See the name option.
implicit: Bool or None (default: None)
True: This input is implicit in the sense that the user is not allowed
True: This input is implicit in the sense that the user is not allowed
to provide a value for it. Requires 'value' to be set.
to provide a value for it. Requires 'value' to be set.
False: The user can provide a value for this input. Be careful when
False: The user can provide a value for this input. Be careful when
'value' is a container, because providing an input value will
'value' is a container, because providing an input value will
overwrite the content of this container.
overwrite the content of this container.
None: Automatically choose between True or False depending on the
None: Automatically choose between True or False depending on the
situation. It will be set to False in all cases except if 'value'
situation. It will be set to False in all cases except if 'value' is a
is a container (so that there is less risk of accidentally
container (so that there is less risk of accidentally overwriting its
overwriting its content without being aware of it).
content without being aware of it).
"""
"""
# Note: the documentation above is duplicated in doc/topics/function.txt,
# Note: the documentation above is duplicated in doc/topics/function.txt,
# try to keep it synchronized.
# try to keep it synchronized.
...
@@ -273,10 +260,14 @@ class SymbolicOutput(object):
...
@@ -273,10 +260,14 @@ class SymbolicOutput(object):
"""
"""
Represents a symbolic output for use with function or FunctionMaker.
Represents a symbolic output for use with function or FunctionMaker.
borrow: set this to True to indicate that a reference to
Parameters
function's internal storage may be returned. A value
----------
returned for this output might be clobbered by running
borrow : bool
the function again, but the function might be faster.
Set this to True to indicate that a reference to function's internal
storage may be returned. A value returned for this output might be
clobbered by running the function again, but the function might be
faster.
"""
"""
def
__init__
(
self
,
variable
,
borrow
=
False
):
def
__init__
(
self
,
variable
,
borrow
=
False
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论