Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
265311c0
提交
265311c0
authored
3月 20, 2015
作者:
AlexLamb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactored dictionary wrapper into Function.call
上级
a1f266b1
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
36 行增加
和
15 行删除
+36
-15
function.py
theano/compile/function.py
+3
-8
function_module.py
theano/compile/function_module.py
+28
-5
pfunc.py
theano/compile/pfunc.py
+2
-2
test_flake8.py
theano/tests/test_flake8.py
+3
-0
没有找到文件。
theano/compile/function.py
浏览文件 @
265311c0
...
@@ -211,7 +211,7 @@ def function(inputs, outputs=None, mode=None, updates=None, givens=None,
...
@@ -211,7 +211,7 @@ def function(inputs, outputs=None, mode=None, updates=None, givens=None,
else
:
else
:
outputs_dict_format
=
False
outputs_dict_format
=
False
output_keys
=
None
if
name
is
None
:
if
name
is
None
:
# Determine possible file names
# Determine possible file names
...
@@ -291,17 +291,12 @@ def function(inputs, outputs=None, mode=None, updates=None, givens=None,
...
@@ -291,17 +291,12 @@ def function(inputs, outputs=None, mode=None, updates=None, givens=None,
rebuild_strict
=
rebuild_strict
,
rebuild_strict
=
rebuild_strict
,
allow_input_downcast
=
allow_input_downcast
,
allow_input_downcast
=
allow_input_downcast
,
on_unused_input
=
on_unused_input
,
on_unused_input
=
on_unused_input
,
profile
=
profile
)
profile
=
profile
,
output_dictionary_flag
=
outputs_dict_format
,
output_keys
=
output_keys
)
# We need to add the flag check_aliased inputs if we have any mutable or
# We need to add the flag check_aliased inputs if we have any mutable or
# borrowed used defined inputs
# borrowed used defined inputs
fn
.
_check_for_aliased_inputs
=
check_for_aliased_inputs
fn
.
_check_for_aliased_inputs
=
check_for_aliased_inputs
if
outputs_dict_format
:
fn_dict_output
=
(
lambda
*
args
,
**
kwargs
:
output_dictionary_wrapper
(
args
,
kwargs
,
fn
=
fn
,
keys
=
output_keys
))
return
fn_dict_output
return
fn
return
fn
...
...
theano/compile/function_module.py
浏览文件 @
265311c0
...
@@ -280,7 +280,7 @@ class Function(object):
...
@@ -280,7 +280,7 @@ class Function(object):
"""
"""
def
__init__
(
self
,
fn
,
input_storage
,
output_storage
,
indices
,
outputs
,
def
__init__
(
self
,
fn
,
input_storage
,
output_storage
,
indices
,
outputs
,
defaults
,
unpack_single
,
return_none
,
maker
):
defaults
,
unpack_single
,
return_none
,
output_dictionary_flag
,
output_keys
,
maker
):
"""
"""
Initialize attributes. create finder, inv_finder.
Initialize attributes. create finder, inv_finder.
"""
"""
...
@@ -298,6 +298,8 @@ class Function(object):
...
@@ -298,6 +298,8 @@ class Function(object):
self
.
trust_input
=
False
# If True, we don't check the input parameter
self
.
trust_input
=
False
# If True, we don't check the input parameter
self
.
name
=
None
self
.
name
=
None
self
.
nodes_with_inner_function
=
[]
self
.
nodes_with_inner_function
=
[]
self
.
output_dictionary_flag
=
output_dictionary_flag
self
.
output_keys
=
output_keys
# We will be popping stuff off this `containers` object. It is a copy.
# We will be popping stuff off this `containers` object. It is a copy.
containers
=
list
(
self
.
input_storage
)
containers
=
list
(
self
.
input_storage
)
...
@@ -671,11 +673,26 @@ class Function(object):
...
@@ -671,11 +673,26 @@ class Function(object):
if
hasattr
(
self
.
fn
,
'update_profile'
):
if
hasattr
(
self
.
fn
,
'update_profile'
):
self
.
fn
.
update_profile
(
profile
)
self
.
fn
.
update_profile
(
profile
)
if
self
.
return_none
:
if
self
.
return_none
:
return
None
return
None
elif
self
.
unpack_single
and
len
(
outputs
)
==
1
:
elif
self
.
unpack_single
and
len
(
outputs
)
==
1
:
return
outputs
[
0
]
return
outputs
[
0
]
else
:
else
:
if
self
.
output_dictionary_flag
:
outputDict
=
{}
assert
len
(
self
.
output_keys
)
==
len
(
outputs
)
for
i
in
range
(
0
,
len
(
self
.
output_keys
)):
outputDict
[
self
.
output_keys
[
i
]]
=
outputs
[
i
]
outputs
=
outputDict
return
outputs
return
outputs
value
=
property
(
value
=
property
(
...
@@ -1047,7 +1064,8 @@ class FunctionMaker(object):
...
@@ -1047,7 +1064,8 @@ class FunctionMaker(object):
def
__init__
(
self
,
inputs
,
outputs
,
def
__init__
(
self
,
inputs
,
outputs
,
mode
=
None
,
accept_inplace
=
False
,
function_builder
=
Function
,
mode
=
None
,
accept_inplace
=
False
,
function_builder
=
Function
,
profile
=
None
,
on_unused_input
=
None
,
fgraph
=
None
):
profile
=
None
,
on_unused_input
=
None
,
fgraph
=
None
,
output_dictionary_flag
=
False
,
output_keys
=
None
):
"""
"""
:type inputs: a list of SymbolicInput instances
:type inputs: a list of SymbolicInput instances
...
@@ -1201,6 +1219,8 @@ class FunctionMaker(object):
...
@@ -1201,6 +1219,8 @@ class FunctionMaker(object):
self
.
accept_inplace
=
accept_inplace
self
.
accept_inplace
=
accept_inplace
self
.
function_builder
=
function_builder
self
.
function_builder
=
function_builder
self
.
on_unused_input
=
on_unused_input
# Used only for the pickling
self
.
on_unused_input
=
on_unused_input
# Used only for the pickling
self
.
output_dictionary_flag
=
output_dictionary_flag
self
.
output_keys
=
output_keys
self
.
required
=
[(
i
.
value
is
None
)
for
i
in
self
.
inputs
]
self
.
required
=
[(
i
.
value
is
None
)
for
i
in
self
.
inputs
]
self
.
refeed
=
[
self
.
refeed
=
[
...
@@ -1336,7 +1356,7 @@ class FunctionMaker(object):
...
@@ -1336,7 +1356,7 @@ class FunctionMaker(object):
self
.
profile
.
import_time
+=
import_time
self
.
profile
.
import_time
+=
import_time
fn
=
self
.
function_builder
(
_fn
,
_i
,
_o
,
self
.
indices
,
self
.
outputs
,
fn
=
self
.
function_builder
(
_fn
,
_i
,
_o
,
self
.
indices
,
self
.
outputs
,
defaults
,
self
.
unpack_single
,
self
.
return_none
,
self
)
defaults
,
self
.
unpack_single
,
self
.
return_none
,
self
.
output_dictionary_flag
,
self
.
output_keys
,
self
)
fn
.
profile
=
self
.
profile
fn
.
profile
=
self
.
profile
return
fn
return
fn
...
@@ -1396,7 +1416,8 @@ def register_checker(checker):
...
@@ -1396,7 +1416,8 @@ def register_checker(checker):
def
orig_function
(
inputs
,
outputs
,
mode
=
None
,
accept_inplace
=
False
,
def
orig_function
(
inputs
,
outputs
,
mode
=
None
,
accept_inplace
=
False
,
name
=
None
,
profile
=
None
,
on_unused_input
=
None
):
name
=
None
,
profile
=
None
,
on_unused_input
=
None
,
output_dictionary_flag
=
False
,
output_keys
=
None
):
"""
"""
Return a Function that will calculate the outputs from the inputs.
Return a Function that will calculate the outputs from the inputs.
...
@@ -1462,7 +1483,9 @@ def orig_function(inputs, outputs, mode=None, accept_inplace=False,
...
@@ -1462,7 +1483,9 @@ def orig_function(inputs, outputs, mode=None, accept_inplace=False,
mode
,
mode
,
accept_inplace
=
accept_inplace
,
accept_inplace
=
accept_inplace
,
profile
=
profile
,
profile
=
profile
,
on_unused_input
=
on_unused_input
)
.
create
(
on_unused_input
=
on_unused_input
,
output_dictionary_flag
=
output_dictionary_flag
,
output_keys
=
output_keys
)
.
create
(
defaults
)
defaults
)
t2
=
time
.
time
()
t2
=
time
.
time
()
...
...
theano/compile/pfunc.py
浏览文件 @
265311c0
...
@@ -333,7 +333,7 @@ class Param(object):
...
@@ -333,7 +333,7 @@ class Param(object):
self
.
implicit
=
implicit
self
.
implicit
=
implicit
def
pfunc
(
params
,
outputs
=
None
,
mode
=
None
,
updates
=
None
,
givens
=
None
,
def
pfunc
(
params
,
output
_dictionary_flag
,
output_keys
,
output
s
=
None
,
mode
=
None
,
updates
=
None
,
givens
=
None
,
no_default_updates
=
False
,
accept_inplace
=
False
,
name
=
None
,
no_default_updates
=
False
,
accept_inplace
=
False
,
name
=
None
,
rebuild_strict
=
True
,
allow_input_downcast
=
None
,
rebuild_strict
=
True
,
allow_input_downcast
=
None
,
profile
=
None
,
on_unused_input
=
None
):
profile
=
None
,
on_unused_input
=
None
):
...
@@ -506,7 +506,7 @@ def pfunc(params, outputs=None, mode=None, updates=None, givens=None,
...
@@ -506,7 +506,7 @@ def pfunc(params, outputs=None, mode=None, updates=None, givens=None,
mutable
=
False
,
borrow
=
True
,
shared
=
True
)
mutable
=
False
,
borrow
=
True
,
shared
=
True
)
inputs
.
append
(
si
)
inputs
.
append
(
si
)
return
orig_function
(
inputs
,
cloned_outputs
,
mode
,
return
orig_function
(
inputs
,
cloned_outputs
,
mode
,
output_dictionary_flag
=
output_dictionary_flag
,
output_keys
=
output_keys
,
accept_inplace
=
accept_inplace
,
name
=
name
,
profile
=
profile
,
accept_inplace
=
accept_inplace
,
name
=
name
,
profile
=
profile
,
on_unused_input
=
on_unused_input
)
on_unused_input
=
on_unused_input
)
...
...
theano/tests/test_flake8.py
浏览文件 @
265311c0
...
@@ -16,6 +16,9 @@ try:
...
@@ -16,6 +16,9 @@ try:
except
ImportError
:
except
ImportError
:
flake8_available
=
False
flake8_available
=
False
print
theano
.
__file__
print
"fake8available"
,
flake8_available
whitelist_flake8
=
[
whitelist_flake8
=
[
"updates.py"
,
"updates.py"
,
"printing.py"
,
"printing.py"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论