Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
03b82c26
提交
03b82c26
authored
10月 18, 2020
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
10月 18, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update and add missing docstrings in theano.gof.graph
上级
63fd27b5
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
29 行增加
和
35 行删除
+29
-35
graph.py
theano/gof/graph.py
+29
-35
没有找到文件。
theano/gof/graph.py
浏览文件 @
03b82c26
...
@@ -22,13 +22,12 @@ NoParams = object()
...
@@ -22,13 +22,12 @@ NoParams = object()
class
Node
(
utils
.
object2
):
class
Node
(
utils
.
object2
):
"""
"""A `Node` in a Theano graph.
A Node in a theano graph.
Graphs contain two kinds of Nodes -- Variable and Apply
.
Currently, graphs contain two kinds of `Nodes`: `Variable`s and `Apply`s
.
Edges in the graph are not explicitly represented.
Edges in the graph are not explicitly represented.
Instead each
Node
keeps track of its parents via
Instead each
`Node`
keeps track of its parents via
Variable.owner / Apply.inputs
and its children
`Variable.owner` / `Apply.inputs`
and its children
via Variable.clients / Apply.outputs.
via Variable.clients / Apply.outputs.
"""
"""
...
@@ -44,48 +43,46 @@ class Node(utils.object2):
...
@@ -44,48 +43,46 @@ class Node(utils.object2):
class
Apply
(
Node
):
class
Apply
(
Node
):
"""
"""A `Node` representing the application of an operation to inputs.
An :term:`Apply` instance is a node in an expression graph which represents
the application of an `Op` to some input `Variable` nodes, producing some
output `Variable` nodes.
This class is typically instantiated by an Op's make_node() function, which
An `Apply` instance serves as a simple structure with three important
is typically called by that Op's __call__() function.
An Apply instance serves as a simple structure with three important
attributes:
attributes:
- :literal:`inputs` : a list of `Variable` nodes that represent the
- :literal:`inputs` : a list of `Variable` nodes that represent the
arguments of the expression,
arguments of the expression,
- :literal:`outputs` : a list of `Variable` nodes that represent the
- :literal:`outputs` : a list of `Variable` nodes that represent the
variable
of the expression, and
computed outputs
of the expression, and
- :literal:`op` : an `Op` instance that determines the nature of the
- :literal:`op` : an `Op` instance that determines the nature of the
expression being applied.
expression being applied.
The driver `compile.function` uses Apply's inputs attribute together with
Basically, an `Apply` instance is an object that represents the
Variable's owner attribute to search the expression graph and determine
Python statement `outputs = op(*inputs)`.
which inputs are necessary to compute the function's outputs.
This class is typically instantiated by a `PureOp.make_node` method, which
is called by `PureOp.__call__`.
A `Linker` uses the Apply instance's `op` field to compute the variables.
The driver `theano.compile.function` uses `Apply.inputs` together with
`Variable.owner` to search the expression graph and determine which inputs
are necessary to compute the function's outputs.
Comparing with the Python language, an `Apply` instance is theano's version
A `Linker` uses the `Apply` instance's `op` field to compute numeric values
of a function call (or expression instance) whereas `Op` is theano's version
for the output variables.
of a function definition.
Parameters
Parameters
----------
----------
op :
`Op`
instance
op :
A PureOp
instance
inputs : list of Variable instances
inputs : list of Variable instances
outputs : list of Variable instances
outputs : list of Variable instances
Notes
Notes
-----
-----
The owner field of each output in the outputs list will be set to self.
The `Variable.owner` field of each `Apply.outputs` element is set to `self`
in `Apply.make_node`.
If an output element has an owner that is neither
None nor self
, then a
If an output element has an owner that is neither
`None` nor `self`
, then a
ValueError
exception will be raised.
`ValueError`
exception will be raised.
"""
"""
...
@@ -381,7 +378,7 @@ class Variable(Node):
...
@@ -381,7 +378,7 @@ class Variable(Node):
__count__
=
count
(
0
)
__count__
=
count
(
0
)
def
__init__
(
self
,
type
,
owner
=
None
,
index
=
None
,
name
=
None
):
def
__init__
(
self
,
type
,
owner
=
None
,
index
=
None
,
name
=
None
):
super
(
Variable
,
self
)
.
__init__
()
super
()
.
__init__
()
self
.
tag
=
utils
.
ValidatingScratchpad
(
"test_value"
,
type
.
filter
)
self
.
tag
=
utils
.
ValidatingScratchpad
(
"test_value"
,
type
.
filter
)
...
@@ -567,25 +564,22 @@ class Variable(Node):
...
@@ -567,25 +564,22 @@ class Variable(Node):
class
Constant
(
Variable
):
class
Constant
(
Variable
):
"""
"""A `Variable` with a fixed `value` field.
A :term:`Constant` is a `Variable` with a `value` field that cannot be
changed at runtime.
Constant nodes make
eligible numerous optimizations: constant inlining in
Constant nodes make
numerous optimizations possible (e.g. constant inlining
C code, constant folding, etc.
in C code, constant folding, etc.)
Notes
Notes
-----
-----
The data field is filtered by what is provided in the constructor for the
The data field is filtered by what is provided in the constructor for the
Constant's type field.
`Constant`'s type field.
WRITEME
"""
"""
# __slots__ = ['data']
# __slots__ = ['data']
def
__init__
(
self
,
type
,
data
,
name
=
None
):
def
__init__
(
self
,
type
,
data
,
name
=
None
):
Variable
.
__init__
(
self
,
type
,
None
,
None
,
name
)
super
()
.
__init__
(
type
,
None
,
None
,
name
)
self
.
data
=
type
.
filter
(
data
)
self
.
data
=
type
.
filter
(
data
)
utils
.
add_tag_trace
(
self
)
utils
.
add_tag_trace
(
self
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论