Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2acc5734
提交
2acc5734
authored
1月 21, 2010
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean up unused code (left over from previous version).
上级
fa39a62d
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
0 行增加
和
87 行删除
+0
-87
pfunc.py
theano/compile/pfunc.py
+0
-87
没有找到文件。
theano/compile/pfunc.py
浏览文件 @
2acc5734
...
@@ -149,9 +149,6 @@ def pfunc(params, outputs=None, mode=None, updates=[], givens=[],
...
@@ -149,9 +149,6 @@ def pfunc(params, outputs=None, mode=None, updates=[], givens=[],
clone_d
.
setdefault
(
old_o
,
new_o
)
clone_d
.
setdefault
(
old_o
,
new_o
)
return
clone_d
[
a
]
return
clone_d
[
a
]
#def v_clone(v):
# return _v_clone(v, clone_d)
# initialize the clone_d mapping with the `givens` argument
# initialize the clone_d mapping with the `givens` argument
try
:
try
:
givens
=
givens
.
items
()
# converts a dictionary to the sort of list that we want.
givens
=
givens
.
items
()
# converts a dictionary to the sort of list that we want.
...
@@ -173,8 +170,6 @@ def pfunc(params, outputs=None, mode=None, updates=[], givens=[],
...
@@ -173,8 +170,6 @@ def pfunc(params, outputs=None, mode=None, updates=[], givens=[],
for
i
,
iv
in
zip
(
inputs
,
input_variables
):
for
i
,
iv
in
zip
(
inputs
,
input_variables
):
i
.
variable
=
iv
i
.
variable
=
iv
#set_of_param_variables = set(input_variables)
# It was decided, as a first step, to prevent shared variables from being
# It was decided, as a first step, to prevent shared variables from being
# used as function inputs. Although it is technically possible, it is also not clear
# used as function inputs. Although it is technically possible, it is also not clear
# when/how to use the value of that shared variable (is it a default? ignored?, if the
# when/how to use the value of that shared variable (is it a default? ignored?, if the
...
@@ -200,10 +195,6 @@ def pfunc(params, outputs=None, mode=None, updates=[], givens=[],
...
@@ -200,10 +195,6 @@ def pfunc(params, outputs=None, mode=None, updates=[], givens=[],
update_d
[
store_into
]
=
update_val
update_d
[
store_into
]
=
update_val
update_expr
.
append
((
store_into
,
update_val
))
update_expr
.
append
((
store_into
,
update_val
))
# computed_list is a list of output variables (which will be extended later)
#computed_list = []
# Elements of "outputs" are here cloned to "cloned_outputs"
# Elements of "outputs" are here cloned to "cloned_outputs"
if
isinstance
(
outputs
,
list
):
if
isinstance
(
outputs
,
list
):
cloned_outputs
=
[]
cloned_outputs
=
[]
...
@@ -246,7 +237,6 @@ def pfunc(params, outputs=None, mode=None, updates=[], givens=[],
...
@@ -246,7 +237,6 @@ def pfunc(params, outputs=None, mode=None, updates=[], givens=[],
shared_inputs
.
append
(
v
)
shared_inputs
.
append
(
v
)
i
+=
1
i
+=
1
#updates = update_d #?
for
sv
in
shared_inputs
:
for
sv
in
shared_inputs
:
if
sv
in
update_d
:
if
sv
in
update_d
:
si
=
In
(
variable
=
sv
,
value
=
sv
.
container
,
mutable
=
True
,
si
=
In
(
variable
=
sv
,
value
=
sv
.
container
,
mutable
=
True
,
...
@@ -258,64 +248,6 @@ def pfunc(params, outputs=None, mode=None, updates=[], givens=[],
...
@@ -258,64 +248,6 @@ def pfunc(params, outputs=None, mode=None, updates=[], givens=[],
return
orig_function
(
inputs
,
cloned_outputs
,
mode
,
return
orig_function
(
inputs
,
cloned_outputs
,
mode
,
accept_inplace
=
accept_inplace
,
name
=
name
)
accept_inplace
=
accept_inplace
,
name
=
name
)
if
0
:
# Add update values as quantities that must be computed.
# Here, we
# - extend the computed_list
# - replace some update expressions (but update keys remain)
new_updates
=
{}
for
(
store_into
,
update_val
)
in
iter_over_pairs
(
updates
):
if
not
isinstance
(
store_into
,
SharedVariable
):
raise
TypeError
(
'update target must be a SharedVariable'
,
store_into
)
if
store_into
in
new_updates
:
raise
ValueError
(
'this shared variable already has an update expression'
,
(
store_into
,
new_updates
[
store_into
]))
update_val
=
v_clone
(
store_into
.
filter_update
(
update_val
))
if
update_val
.
type
!=
store_into
.
type
:
raise
TypeError
(
'an update must have the same type as the original shared variable'
,
(
store_into
,
store_into
.
type
,
update_val
,
update_val
.
type
))
computed_list
.
append
(
update_val
)
new_updates
[
store_into
]
=
update_val
updates
=
new_updates
# Obtain all inputs we need to compute what we want.
graph_inputs
=
graph
.
inputs
(
computed_list
,
blockers
=
set_of_param_variables
)
shared_inputs
=
[
i
for
i
in
graph_inputs
if
isinstance
(
i
,
SharedVariable
)]
# Add shared variables (from shared_inputs) that were not already present in the list of
# params.
inputs
+=
[
In
(
variable
=
si
,
value
=
si
.
container
,
mutable
=
False
)
for
si
in
shared_inputs
if
si
not
in
set_of_param_variables
]
del
shared_inputs
# Iterate over the updates, which are either pairs
# (shared_var, expressionvariable), or a similar dictionary.
# For each shared_variable, find the In instance that we created for it in the inputs list.
# Give that In instance (in_sv) an update expression.
#
# I think we usually want to set these Inputs to be mutable,
# ... are there exceptions?
for
(
sv
,
new_val
)
in
iter_over_pairs
(
updates
):
in_sv
=
None
for
in_sv_i
in
inputs
:
if
in_sv_i
.
variable
is
sv
:
assert
in_sv
is
None
in_sv
=
in_sv_i
if
in_sv
is
None
:
# This variable was not used anywhere and thus is not in the input
# list yet.
inputs
.
append
(
In
(
variable
=
sv
,
value
=
sv
.
container
,
mutable
=
True
,
update
=
new_val
))
else
:
in_sv
.
update
=
new_val
in_sv
.
mutable
=
True
return
orig_function
(
inputs
,
cloned_outputs
,
mode
,
accept_inplace
=
accept_inplace
,
name
=
name
)
def
_pfunc_param_to_in
(
param
):
def
_pfunc_param_to_in
(
param
):
if
isinstance
(
param
,
Constant
):
if
isinstance
(
param
,
Constant
):
...
@@ -354,22 +286,3 @@ def iter_over_pairs(pairs):
...
@@ -354,22 +286,3 @@ def iter_over_pairs(pairs):
else
:
else
:
return
pairs
return
pairs
#TODO: Make these non-recursive so they can deal with larger graphs
def
_a_clone
(
a
,
dct
):
if
a
is
None
:
return
None
if
a
not
in
dct
:
for
i
in
a
.
inputs
:
_v_clone
(
i
,
dct
)
dct
[
a
]
=
a
.
clone_with_new_inputs
([
dct
[
i
]
for
i
in
a
.
inputs
])
for
old_o
,
new_o
in
zip
(
a
.
outputs
,
dct
[
a
]
.
outputs
):
dct
.
setdefault
(
old_o
,
new_o
)
return
dct
[
a
]
def
_v_clone
(
v
,
dct
):
assert
v
is
not
None
if
v
.
owner
:
_a_clone
(
v
.
owner
,
dct
)
return
dct
.
setdefault
(
v
,
v
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论