Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0350b33a
提交
0350b33a
authored
3月 14, 2017
作者:
khaotik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
microrefinements
- use `def` syntax for flake8 syntax issue - cleaner condition - use assert instead of raise for internal state
上级
90ba4b94
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
16 行增加
和
15 行删除
+16
-15
builders.py
theano/compile/builders.py
+16
-15
没有找到文件。
theano/compile/builders.py
浏览文件 @
0350b33a
...
...
@@ -284,13 +284,13 @@ class OpFromGraph(gof.Op):
self
.
kwargs
=
kwargs
self
.
input_types
=
[
inp
.
type
for
inp
in
inputs
]
self
.
output_types
=
[
out
.
type
for
out
in
outputs
]
cond
=
int
(
lop_overrides
==
'default'
)
*
2
+
int
(
grad_overrides
==
'default'
)
if
cond
==
0
:
raise
ValueError
(
'lop_overrides and grad_overrides are mutually exclusive'
)
elif
cond
==
1
:
self
.
set_lop_overrides
(
lop_overrides
)
self
.
_lop_type
=
'lop'
elif
cond
==
2
:
if
lop_overrides
!=
'default'
:
if
grad_overrides
!=
'default'
:
raise
ValueError
(
'lop_overrides and grad_overrides are mutually exclusive'
)
else
:
self
.
set_lop_overrides
(
lop_overrides
)
self
.
_lop_type
=
'lop'
elif
grad_overrides
!=
'default'
:
self
.
set_lop_overrides
(
grad_overrides
)
self
.
_lop_type
=
'grad'
else
:
...
...
@@ -329,6 +329,8 @@ class OpFromGraph(gof.Op):
if
isinstance
(
lop_op
,
OpFromGraph
):
if
self
.
_lop_op_is_cached
:
return
assert
self
.
_lop_type
in
[
'lop'
,
'grad'
],
\
self
.
LOP_TYPE_ERR_MSG
%
self
.
_lop_type
if
self
.
_lop_type
==
'grad'
:
needed_ninps
=
inp_len
+
len
(
local_outputs
)
ninps
=
len
(
lop_op
.
local_inputs
)
...
...
@@ -336,7 +338,8 @@ class OpFromGraph(gof.Op):
raise
ValueError
(
self
.
OV_INP_LEN_ERR_MSG
%
(
needed_ninps
,
ninps
))
# make a wrapper callable
lop_op
=
lambda
inps
,
grads
:
self
.
_lop_op
(
*
(
inps
+
grads
))
# flake8: noqa
def
lop_op
(
inps
,
grads
):
return
self
.
_lop_op
(
*
(
inps
+
grads
))
elif
self
.
_lop_type
==
'lop'
:
# OfG can be directly used in L_op format
needed_ninps
=
inp_len
+
2
*
len
(
local_outputs
)
...
...
@@ -348,8 +351,6 @@ class OpFromGraph(gof.Op):
self
.
_lop_op_stypes_l
=
[
None
]
*
inp_len
self
.
_lop_op
.
kwargs
[
'on_unused_input'
]
=
'ignore'
return
else
:
raise
ValueError
(
self
.
LOP_TYPE_ERR_MSG
%
self
.
_lop_type
)
output_grads
=
[
out_t
()
for
out_t
in
self
.
output_types
]
fn_grad
=
partial
(
...
...
@@ -360,12 +361,12 @@ class OpFromGraph(gof.Op):
null_gradients
=
'return'
,
known_grads
=
OrderedDict
(
izip
(
local_outputs
,
output_grads
)))
assert
self
.
_lop_type
in
[
'lop'
,
'grad'
],
\
self
.
LOP_TYPE_ERR_MSG
%
self
.
_lop_type
if
self
.
_lop_type
==
'lop'
:
callable_args
=
(
local_inputs
,
local_outputs
,
output_grads
)
elif
self
.
_lop_type
==
'grad'
:
callable_args
=
(
local_inputs
,
output_grads
)
else
:
raise
ValueError
(
self
.
LOP_TYPE_ERR_MSG
%
self
.
_lop_type
)
# we need to convert _lop_op into an OfG instance
if
lop_op
==
'default'
:
...
...
@@ -640,10 +641,10 @@ class OpFromGraph(gof.Op):
cpmat_self
=
io_connection_pattern
(
self
.
local_inputs
,
self
.
local_outputs
)
grad
_op
=
self
.
get_lop_op
()
lop
_op
=
self
.
get_lop_op
()
cpmat_grad
=
io_connection_pattern
(
grad
_op
.
local_inputs
[
inp_len
:],
grad
_op
.
local_outputs
)
lop
_op
.
local_inputs
[
inp_len
:],
lop
_op
.
local_outputs
)
# cpmat_self |= cpmat_grad.T
# cpmat_self &= out_is_disconnected
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论