Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4289537c
提交
4289537c
authored
8月 13, 2015
作者:
Iban Harlouchet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
numpydoc for theano/gof/toolbox.py
上级
17429f38
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
23 行增加
和
6 行删除
+23
-6
toolbox.py
theano/gof/toolbox.py
+23
-6
没有找到文件。
theano/gof/toolbox.py
浏览文件 @
4289537c
...
@@ -11,18 +11,24 @@ from theano.gof import graph
...
@@ -11,18 +11,24 @@ from theano.gof import graph
class
AlreadyThere
(
Exception
):
class
AlreadyThere
(
Exception
):
"""Raised by a Feature's on_attach callback method if the FunctionGraph
"""
Raised by a Feature's on_attach callback method if the FunctionGraph
attempting to attach the feature already has a functionally identical
attempting to attach the feature already has a functionally identical
feature."""
feature.
"""
pass
pass
class
ReplacementDidntRemovedError
(
Exception
):
class
ReplacementDidntRemovedError
(
Exception
):
"""This exception should be thrown by replace_all_validate_remove
"""
This exception should be thrown by replace_all_validate_remove
when an optimization wanted to remove a Variable or a Node from
when an optimization wanted to remove a Variable or a Node from
the graph, but the replacement it gived didn't do that.
the graph, but the replacement it gived didn't do that.
"""
"""
pass
pass
...
@@ -34,7 +40,10 @@ class Feature(object):
...
@@ -34,7 +40,10 @@ class Feature(object):
by various operations on FunctionGraphs. It can be used to enforce
by various operations on FunctionGraphs. It can be used to enforce
graph properties at all stages of graph optimization.
graph properties at all stages of graph optimization.
See :func:`theano.gof.toolbox` for common extensions.
See Also
--------
theano.gof.toolbox : for common extensions.
"""
"""
def
on_attach
(
self
,
function_graph
):
def
on_attach
(
self
,
function_graph
):
...
@@ -51,12 +60,14 @@ class Feature(object):
...
@@ -51,12 +60,14 @@ class Feature(object):
The feature has great freedom in what it can do with the
The feature has great freedom in what it can do with the
function_graph: it may, for example, add methods to it dynamically.
function_graph: it may, for example, add methods to it dynamically.
"""
"""
def
on_detach
(
self
,
function_graph
):
def
on_detach
(
self
,
function_graph
):
"""
"""
Called by remove_feature(feature). Should remove any dynamically-added
Called by remove_feature(feature). Should remove any dynamically-added
functionality that it installed into the function_graph.
functionality that it installed into the function_graph.
"""
"""
def
on_import
(
self
,
function_graph
,
node
,
reason
):
def
on_import
(
self
,
function_graph
,
node
,
reason
):
...
@@ -66,12 +77,14 @@ class Feature(object):
...
@@ -66,12 +77,14 @@ class Feature(object):
Note: on_import is not called when the graph is created. If you
Note: on_import is not called when the graph is created. If you
want to detect the first nodes to be implemented to the graph,
want to detect the first nodes to be implemented to the graph,
you should do this by implementing on_attach.
you should do this by implementing on_attach.
"""
"""
def
on_prune
(
self
,
function_graph
,
node
,
reason
):
def
on_prune
(
self
,
function_graph
,
node
,
reason
):
"""
"""
Called whenever a node is pruned (removed) from the function_graph,
Called whenever a node is pruned (removed) from the function_graph,
after it is disconnected from the graph.
after it is disconnected from the graph.
"""
"""
def
on_change_input
(
self
,
function_graph
,
node
,
i
,
r
,
new_r
,
reason
=
None
):
def
on_change_input
(
self
,
function_graph
,
node
,
i
,
r
,
new_r
,
reason
=
None
):
...
@@ -82,6 +95,7 @@ class Feature(object):
...
@@ -82,6 +95,7 @@ class Feature(object):
If you raise an exception in this function, the state of the graph
If you raise an exception in this function, the state of the graph
might be broken for all intents and purposes.
might be broken for all intents and purposes.
"""
"""
def
orderings
(
self
,
function_graph
):
def
orderings
(
self
,
function_graph
):
...
@@ -92,6 +106,7 @@ class Feature(object):
...
@@ -92,6 +106,7 @@ class Feature(object):
If you raise an exception in this function, the state of the graph
If you raise an exception in this function, the state of the graph
might be broken for all intents and purposes.
might be broken for all intents and purposes.
"""
"""
return
OrderedDict
()
return
OrderedDict
()
...
@@ -168,6 +183,7 @@ class History(Feature):
...
@@ -168,6 +183,7 @@ class History(Feature):
Reverts the graph to whatever it was at the provided
Reverts the graph to whatever it was at the provided
checkpoint (undoes all replacements). A checkpoint at any
checkpoint (undoes all replacements). A checkpoint at any
given time can be obtained using self.checkpoint().
given time can be obtained using self.checkpoint().
"""
"""
h
=
self
.
history
[
fgraph
]
h
=
self
.
history
[
fgraph
]
self
.
history
[
fgraph
]
=
None
self
.
history
[
fgraph
]
=
None
...
@@ -302,8 +318,9 @@ class ReplaceValidate(History, Validator):
...
@@ -302,8 +318,9 @@ class ReplaceValidate(History, Validator):
def
replace_all_validate_remove
(
self
,
fgraph
,
replacements
,
def
replace_all_validate_remove
(
self
,
fgraph
,
replacements
,
remove
,
reason
=
None
,
warn
=
True
):
remove
,
reason
=
None
,
warn
=
True
):
"""As replace_all_validate, revert the replacement if the ops
"""
in the list remove are still in the graph. It also print a warning.
As replace_all_validate, revert the replacement if the ops
in the list remove are still in the graph. Also print a warning.
"""
"""
chk
=
fgraph
.
replace_all_validate
(
replacements
,
reason
)
chk
=
fgraph
.
replace_all_validate
(
replacements
,
reason
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论