Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c54ef356
提交
c54ef356
authored
1月 25, 2022
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
2月 22, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor properties and docstrings in Apply
上级
7e351b93
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
34 行增加
和
40 行删除
+34
-40
basic.py
aesara/graph/basic.py
+34
-40
没有找到文件。
aesara/graph/basic.py
浏览文件 @
c54ef356
...
@@ -63,20 +63,8 @@ class Node(MetaObject):
...
@@ -63,20 +63,8 @@ class Node(MetaObject):
class
Apply
(
Node
):
class
Apply
(
Node
):
"""A `Node` representing the application of an operation to inputs.
"""A `Node` representing the application of an operation to inputs.
An `Apply` instance serves as a simple structure with three important
attributes:
- :literal:`inputs` : a list of `Variable` nodes that represent the
arguments of the expression,
- :literal:`outputs` : a list of `Variable` nodes that represent the
computed outputs of the expression, and
- :literal:`op` : an `Op` instance that determines the nature of the
expression being applied.
Basically, an `Apply` instance is an object that represents the
Basically, an `Apply` instance is an object that represents the
Python statement `
outputs = op(*inputs)
`.
Python statement `
`outputs = op(*inputs)`
`.
This class is typically instantiated by a `Op.make_node` method, which
This class is typically instantiated by a `Op.make_node` method, which
is called by `Op.__call__`.
is called by `Op.__call__`.
...
@@ -88,12 +76,6 @@ class Apply(Node):
...
@@ -88,12 +76,6 @@ class Apply(Node):
A `Linker` uses the `Apply` instance's `op` field to compute numeric values
A `Linker` uses the `Apply` instance's `op` field to compute numeric values
for the output variables.
for the output variables.
Parameters
----------
op : A Op instance
inputs : list of Variable instances
outputs : list of Variable instances
Notes
Notes
-----
-----
The `Variable.owner` field of each `Apply.outputs` element is set to `self`
The `Variable.owner` field of each `Apply.outputs` element is set to `self`
...
@@ -102,9 +84,26 @@ class Apply(Node):
...
@@ -102,9 +84,26 @@ class Apply(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.
Attributes
----------
op : Op
The operation that produces `outputs` given `inputs`.
inputs : List[Variable]
The arguments of the expression modeled by the `Apply` node.
outputs : List[Variable]
The outputs of the expression modeled by the `Apply` node.
"""
"""
def
__init__
(
self
,
op
,
inputs
,
outputs
):
def
__init__
(
self
,
op
,
inputs
,
outputs
):
"""
Parameters
----------
op : Op
inputs : List[Variable]
outputs : List[Variable]
"""
self
.
op
=
op
self
.
op
=
op
self
.
inputs
=
[]
self
.
inputs
=
[]
self
.
tag
=
Scratchpad
()
self
.
tag
=
Scratchpad
()
...
@@ -187,21 +186,12 @@ class Apply(Node):
...
@@ -187,21 +186,12 @@ class Apply(Node):
raise
ValueError
(
f
"{self.op}.default_output is out of range."
)
raise
ValueError
(
f
"{self.op}.default_output is out of range."
)
return
self
.
outputs
[
do
]
return
self
.
outputs
[
do
]
out
=
property
(
default_output
,
doc
=
"alias for self.default_output()"
)
"""
Alias for self.default_output().
"""
def
__str__
(
self
):
def
__str__
(
self
):
return
op_as_string
(
self
.
inputs
,
self
)
return
op_as_string
(
self
.
inputs
,
self
)
def
__repr__
(
self
):
def
__repr__
(
self
):
return
str
(
self
)
return
str
(
self
)
def
__asapply__
(
self
):
return
self
def
clone
(
self
):
def
clone
(
self
):
"""
"""
Duplicate this Apply instance with inputs = self.inputs.
Duplicate this Apply instance with inputs = self.inputs.
...
@@ -266,20 +256,24 @@ class Apply(Node):
...
@@ -266,20 +256,24 @@ class Apply(Node):
def
get_parents
(
self
):
def
get_parents
(
self
):
return
list
(
self
.
inputs
)
return
list
(
self
.
inputs
)
# convenience properties
@property
nin
=
property
(
lambda
self
:
len
(
self
.
inputs
),
doc
=
"same as len(self.inputs)"
)
def
out
(
self
):
"""
"""An alias for `self.default_output`
"""
Property: Number of inputs.
return
self
.
default_output
()
"""
@property
nout
=
property
(
lambda
self
:
len
(
self
.
outputs
),
doc
=
"same as len(self.outputs)"
)
def
nin
(
self
):
"""
"""The number of inputs.
"""
Property: Number of outputs.
return
len
(
self
.
inputs
)
"""
@property
params_type
=
property
(
def
nout
(
self
):
lambda
self
:
self
.
op
.
params_type
,
doc
=
"type to use for the params"
"""The number of outputs."""
)
return
len
(
self
.
outputs
)
@property
def
params_type
(
self
):
return
self
.
op
.
params_type
class
Variable
(
Node
):
class
Variable
(
Node
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论