Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
429b4469
提交
429b4469
authored
9月 03, 2015
作者:
--global
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add optional parameter update_mapping to FunctionGraph
上级
f762278f
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
28 行增加
和
3 行删除
+28
-3
function_module.py
theano/compile/function_module.py
+14
-2
fg.py
theano/gof/fg.py
+14
-1
没有找到文件。
theano/compile/function_module.py
浏览文件 @
429b4469
...
@@ -159,10 +159,22 @@ def std_fgraph(input_specs, output_specs, accept_inplace=False):
...
@@ -159,10 +159,22 @@ def std_fgraph(input_specs, output_specs, accept_inplace=False):
"""
"""
orig_inputs
=
[
spec
.
variable
for
spec
in
input_specs
]
orig_inputs
=
[
spec
.
variable
for
spec
in
input_specs
]
updates
=
[
spec
.
update
for
spec
in
input_specs
if
spec
.
update
]
# Extract the updates and the mapping between update outputs and
# the updated inputs.
updates
=
[]
update_mapping
=
{}
out_idx
=
len
(
output_specs
)
for
inp_idx
in
range
(
len
(
input_specs
)):
if
input_specs
[
inp_idx
]
.
update
:
updates
.
append
(
input_specs
[
inp_idx
]
.
update
)
update_mapping
[
out_idx
]
=
inp_idx
out_idx
+=
1
orig_outputs
=
[
spec
.
variable
for
spec
in
output_specs
]
+
updates
orig_outputs
=
[
spec
.
variable
for
spec
in
output_specs
]
+
updates
fgraph
=
gof
.
fg
.
FunctionGraph
(
orig_inputs
,
orig_outputs
)
fgraph
=
gof
.
fg
.
FunctionGraph
(
orig_inputs
,
orig_outputs
,
update_mapping
=
update_mapping
)
for
node
in
fgraph
.
apply_nodes
:
for
node
in
fgraph
.
apply_nodes
:
if
getattr
(
node
.
op
,
'destroy_map'
,
None
):
if
getattr
(
node
.
op
,
'destroy_map'
,
None
):
...
...
theano/gof/fg.py
浏览文件 @
429b4469
...
@@ -109,7 +109,19 @@ class FunctionGraph(utils.object2):
...
@@ -109,7 +109,19 @@ class FunctionGraph(utils.object2):
"""
"""
def
__init__
(
self
,
inputs
,
outputs
,
features
=
None
,
clone
=
True
):
def
__init__
(
self
,
inputs
,
outputs
,
features
=
None
,
clone
=
True
,
update_mapping
=
None
):
"""
Create an FunctionGraph which operates on the subgraph bound by the
inputs and outputs sets.
:param inputs: inputs nodes of the graph, usually declared by the user
:param outputs: outputs nodes of the graph.
:param clone: If true, we will clone the graph. This is
useful to remove the constant cache problem.
:param update_mapping: dictionnary describing the mapping between
the inputs with updates and the outputs corresponding to their updates
"""
if
clone
:
if
clone
:
inputs
,
outputs
=
graph
.
clone
(
inputs
,
outputs
)
inputs
,
outputs
=
graph
.
clone
(
inputs
,
outputs
)
...
@@ -157,6 +169,7 @@ class FunctionGraph(utils.object2):
...
@@ -157,6 +169,7 @@ class FunctionGraph(utils.object2):
self
.
node_locks
=
{}
self
.
node_locks
=
{}
self
.
variable_locks
=
{}
self
.
variable_locks
=
{}
self
.
profile
=
None
self
.
profile
=
None
self
.
update_mapping
=
update_mapping
# Setup a Variable #
# Setup a Variable #
def
__setup_r__
(
self
,
r
):
def
__setup_r__
(
self
,
r
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论