Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f15bc27c
提交
f15bc27c
authored
12月 28, 2016
作者:
khaotik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
better doc / cleanups
上级
19dea460
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
14 行增加
和
9 行删除
+14
-9
builders.py
theano/compile/builders.py
+14
-9
没有找到文件。
theano/compile/builders.py
浏览文件 @
f15bc27c
...
@@ -39,7 +39,8 @@ class OpFromGraph(gof.Op):
...
@@ -39,7 +39,8 @@ class OpFromGraph(gof.Op):
- `None` : will use default gradient routine.
- `None` : will use default gradient routine.
- theano.utils.undef : No gradient will be used (zero)
- theano.utils.undef : No gradient will be used (zero)
- OpFromGraph instance: the OfG instance should accept inputs with same
- OpFromGraph instance: the OfG instance should accept inputs with same
order and types as specified in "inputs" and "outputs" arguments
order and types of "inputs" and "output_grads" arguments as one would
specify in grad() method
- function : must return list of Variable.
- function : must return list of Variable.
- list : each function must return a single Variable. The order
- list : each function must return a single Variable. The order
of the list must corresponds to inputs
of the list must corresponds to inputs
...
@@ -47,6 +48,11 @@ class OpFromGraph(gof.Op):
...
@@ -47,6 +48,11 @@ class OpFromGraph(gof.Op):
list of (None|undef|function), optional
list of (None|undef|function), optional
similar to grad_overrides, list order should match two list of "inputs"
similar to grad_overrides, list order should match two list of "inputs"
concatenated.
concatenated.
**kwargs: optional
Whenever this OfG instance is precompiled instead of inline, a call to
theano.compile.function_module.orig_function during precompile phase
will take the extra keyword args
TODO:
TODO:
- examples for a multi-layer mlp. where?
- examples for a multi-layer mlp. where?
...
@@ -55,14 +61,13 @@ class OpFromGraph(gof.Op):
...
@@ -55,14 +61,13 @@ class OpFromGraph(gof.Op):
local_outputs)
local_outputs)
- c_code() to remove the double overhead?
- c_code() to remove the double overhead?
- grad() make it support DisconnectedType and the new interface
- grad() make it support DisconnectedType and the new interface
- implement R_op()
- check how it works with updates.
- check how it works with updates.
- add test with constant as input or inside the inner graph.
- add test with constant as input or inside the inner graph.
- Add support for the GPU? Probably just need an opt to remove transfer
- Add support for the GPU? Probably just need an opt to remove transfer
- Add support to pickle this Op.
- Add support to pickle this Op.
- Add support/test with random generator
- Add support/test with random generator
-
Recursion detection to prevent Op "forkbomb", either set depth
-
Add optimization prior to inilne expansion such as removing unused
limit or manually check them.
inputs/outputs
Notes
Notes
-----
-----
...
@@ -74,6 +79,8 @@ class OpFromGraph(gof.Op):
...
@@ -74,6 +79,8 @@ class OpFromGraph(gof.Op):
of compilation time. Like "inline" keyword in C, this is merely a
of compilation time. Like "inline" keyword in C, this is merely a
suggestion to compiler which is not guaranteed. Currently only
suggestion to compiler which is not guaranteed. Currently only
works with "fast_compile" or "fast_run" mode.
works with "fast_compile" or "fast_run" mode.
- The function(s) supplied for overrding gradient/rop will be called
only once
Examples
Examples
--------
--------
...
@@ -125,8 +132,6 @@ class OpFromGraph(gof.Op):
...
@@ -125,8 +132,6 @@ class OpFromGraph(gof.Op):
fn(2., 3., 4.) # [1., 8., 3.]
fn(2., 3., 4.) # [1., 8., 3.]
"""
"""
# NOTE: if you make a subclass of this, make sure add test for it under:
# theano/compile/tests/test_builders.py
def
__init__
(
self
,
inputs
,
outputs
,
inline
=
False
,
grad_overrides
=
None
,
rop_overrides
=
None
,
**
kwargs
):
def
__init__
(
self
,
inputs
,
outputs
,
inline
=
False
,
grad_overrides
=
None
,
rop_overrides
=
None
,
**
kwargs
):
if
not
isinstance
(
outputs
,
list
):
if
not
isinstance
(
outputs
,
list
):
raise
TypeError
(
'outputs must be list'
,
outputs
)
raise
TypeError
(
'outputs must be list'
,
outputs
)
...
@@ -416,13 +421,13 @@ def inline_ofg_expansion(node):
...
@@ -416,13 +421,13 @@ def inline_ofg_expansion(node):
u
:
v
for
u
,
v
in
izip
(
u
:
v
for
u
,
v
in
izip
(
node
.
op
.
local_inputs
,
node
.
inputs
)})
node
.
op
.
local_inputs
,
node
.
inputs
)})
# We want to run this before the first merge optimizer
# and before the first scan optimizer.
optdb
.
register
(
optdb
.
register
(
'inline_ofg_expansion'
,
'inline_ofg_expansion'
,
gof
.
opt
.
in2out
(
inline_ofg_expansion
),
gof
.
opt
.
in2out
(
inline_ofg_expansion
),
0.5
,
'fast_compile'
,
'fast_run'
)
-
0.01
,
'fast_compile'
,
'fast_run'
)
# Since OpFromGraph contains a Theano compiled function,
# Since OpFromGraph contains a Theano compiled function,
# we should let DebugMode know about it
# we should let DebugMode know about it
ops_with_inner_function
[
OpFromGraph
]
=
'fn'
ops_with_inner_function
[
OpFromGraph
]
=
'fn'
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论