Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d9166080
提交
d9166080
authored
7月 13, 2015
作者:
Iban Harlouchet
提交者:
Frederic
7月 22, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
flake8 of theano/gof/graph.py; 1 E left
上级
f4edcc59
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
18 行增加
和
20 行删除
+18
-20
graph.py
theano/gof/graph.py
+18
-19
test_flake8.py
theano/tests/test_flake8.py
+0
-1
没有找到文件。
theano/gof/graph.py
浏览文件 @
d9166080
...
...
@@ -7,18 +7,17 @@ To read about what theano graphs are from a user perspective, have a look at
"""
from
__future__
import
print_function
__docformat__
=
"restructuredtext en"
from
collections
import
deque
from
copy
import
copy
from
itertools
import
count
import
theano
import
warnings
from
theano.gof
import
utils
from
six
import
string_types
,
integer_types
,
iteritems
from
theano.misc.ordered_set
import
OrderedSet
__docformat__
=
"restructuredtext en"
# Lazy imports to avoid circular dependencies.
is_same_graph_with_merge
=
None
equal_computations
=
None
...
...
@@ -310,7 +309,7 @@ class Variable(Node):
`compile.function` uses each `Apply` instance's `inputs` attribute
together with each Variable's `owner` field to determine which inputs are necessary to compute the function's outputs.
"""
#__slots__ = ['type', 'owner', 'index', 'name']
#
__slots__ = ['type', 'owner', 'index', 'name']
__count__
=
count
(
0
)
def
__init__
(
self
,
type
,
owner
=
None
,
index
=
None
,
name
=
None
):
...
...
@@ -409,7 +408,7 @@ class Variable(Node):
self
.
_fn_cache
=
dict
()
inputs
=
tuple
(
sorted
(
inputs_to_values
.
keys
(),
key
=
id
))
if
not
inputs
in
self
.
_fn_cache
:
if
inputs
not
in
self
.
_fn_cache
:
self
.
_fn_cache
[
inputs
]
=
theano
.
function
(
inputs
,
self
)
args
=
[
inputs_to_values
[
param
]
for
param
in
inputs
]
...
...
@@ -429,7 +428,7 @@ class Constant(Variable):
Constant nodes make eligible numerous optimizations: constant inlining in C code, constant folding, etc.
"""
#__slots__ = ['data']
#
__slots__ = ['data']
def
__init__
(
self
,
type
,
data
,
name
=
None
):
"""Initialize self.
...
...
@@ -481,8 +480,7 @@ class Constant(Variable):
raise
ValueError
(
"Constant instances cannot have an owner."
)
owner
=
property
(
lambda
self
:
None
,
__set_owner
)
value
=
property
(
lambda
self
:
self
.
data
,
doc
=
'read-only data access method'
)
value
=
property
(
lambda
self
:
self
.
data
,
doc
=
'read-only data access method'
)
# index is not defined, because the `owner` attribute must necessarily be None
...
...
@@ -654,9 +652,7 @@ def clone(i, o, copy_inputs=True):
return
[
equiv
[
input
]
for
input
in
i
],
[
equiv
[
output
]
for
output
in
o
]
def
clone_get_equiv
(
inputs
,
outputs
,
copy_inputs_and_orphans
=
True
,
memo
=
None
):
def
clone_get_equiv
(
inputs
,
outputs
,
copy_inputs_and_orphans
=
True
,
memo
=
None
):
"""
Return a dictionary that maps from Variable and Apply nodes in the
original graph to a new node (a clone) in a new graph.
...
...
@@ -776,7 +772,8 @@ def general_toposort(r_out, deps, debug_print=False,
rlist
.
append
(
node
)
rset
.
add
(
node
)
for
client
in
clients
.
get
(
node
,
[]):
deps_cache
[
client
]
=
[
a
for
a
in
deps_cache
[
client
]
if
a
is
not
node
]
deps_cache
[
client
]
=
[
a
for
a
in
deps_cache
[
client
]
if
a
is
not
node
]
if
not
deps_cache
[
client
]:
sources
.
append
(
client
)
...
...
@@ -858,8 +855,10 @@ def io_toposort(inputs, outputs, orderings=None):
default_leaf_formatter
=
str
default_node_formatter
=
lambda
op
,
argstrings
:
"
%
s(
%
s)"
%
(
op
.
op
,
", "
.
join
(
argstrings
))
def
default_node_formatter
(
op
,
argstrings
):
return
"
%
s(
%
s)"
%
(
op
.
op
,
", "
.
join
(
argstrings
))
def
io_connection_pattern
(
inputs
,
outputs
):
...
...
@@ -1010,7 +1009,7 @@ def is_same_graph(var1, var2, givens=None, debug=False):
inside
=
dict
((
v
,
[
in_var
(
v
,
k
)
for
k
in
(
1
,
2
)])
for
v
in
(
to_replace
,
replace_by
))
if
(
inside
[
to_replace
][
0
]
and
not
inside
[
to_replace
][
1
]
and
inside
[
replace_by
][
1
]
and
not
inside
[
replace_by
][
0
]):
inside
[
replace_by
][
1
]
and
not
inside
[
replace_by
][
0
]):
# Substitute variable in `var1` by one from `var2`.
in_xs
.
append
(
to_replace
)
in_ys
.
append
(
replace_by
)
...
...
@@ -1151,7 +1150,7 @@ def view_roots(r):
def
list_of_nodes
(
inputs
,
outputs
):
""" Return the apply nodes of the graph between inputs and outputs """
return
stack_search
(
deque
([
o
.
owner
for
o
in
outputs
]),
lambda
o
:
[
inp
.
owner
for
inp
in
o
.
inputs
if
inp
.
owner
and
not
any
(
i
in
inp
.
owner
.
outputs
for
i
in
inputs
)])
deque
([
o
.
owner
for
o
in
outputs
]),
lambda
o
:
[
inp
.
owner
for
inp
in
o
.
inputs
if
inp
.
owner
and
not
any
(
i
in
inp
.
owner
.
outputs
for
i
in
inputs
)])
theano/tests/test_flake8.py
浏览文件 @
d9166080
...
...
@@ -224,7 +224,6 @@ whitelist_flake8 = [
"sparse/sandbox/truedot.py"
,
"sparse/sandbox/sp.py"
,
"gof/unify.py"
,
"gof/graph.py"
,
"gof/__init__.py"
,
"gof/op.py"
,
"gof/tests/test_cmodule.py"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论