Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c53a8e84
提交
c53a8e84
authored
8月 29, 2012
作者:
Ian Goodfellow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed what looks like a bug in Lop where it looks like it was (never)
handling consider_constant correctly made Lop work nicely with new grad_sources_inputs to not compute unnecessary values
上级
5a04235b
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
17 行增加
和
5 行删除
+17
-5
gradient.py
theano/gradient.py
+17
-5
没有找到文件。
theano/gradient.py
浏览文件 @
c53a8e84
...
@@ -288,10 +288,23 @@ def Lop(f, wrt, eval_points, consider_constant=None, warn_type=False,
...
@@ -288,10 +288,23 @@ def Lop(f, wrt, eval_points, consider_constant=None, warn_type=False,
if
not
isinstance
(
f
,
(
list
,
tuple
)):
if
not
isinstance
(
f
,
(
list
,
tuple
)):
f
=
[
f
]
f
=
[
f
]
inputs
=
gof
.
graph
.
inputs
(
f
)
f
=
[
elem
for
elem
in
f
]
grads
=
[
elem
for
elem
in
eval_points
]
for
elem
in
consider_constant
:
assert
elem
not
in
f
f
.
append
(
elem
)
grads
.
append
(
elem
.
zeros_like
())
if
not
isinstance
(
wrt
,
(
list
,
tuple
)):
wrt
=
[
wrt
]
arg1
=
zip
(
f
,
eval_points
)
arg2
=
list
(
wrt
)
gmap
=
grad_sources_inputs
(
gmap
=
grad_sources_inputs
(
zip
(
f
,
eval_points
)
,
arg1
,
list
(
inputs
)
+
list
(
consider_constant
)
,
arg2
,
warn_type
=
warn_type
)
warn_type
=
warn_type
)
# Note : If p is not in gmap there can be several reasons, among which
# Note : If p is not in gmap there can be several reasons, among which
...
@@ -301,8 +314,6 @@ def Lop(f, wrt, eval_points, consider_constant=None, warn_type=False,
...
@@ -301,8 +314,6 @@ def Lop(f, wrt, eval_points, consider_constant=None, warn_type=False,
# such subtle cases can be fixed by a more careful implementation of the
# such subtle cases can be fixed by a more careful implementation of the
# gradient, but for now Theano needs to throw an exception, and make the
# gradient, but for now Theano needs to throw an exception, and make the
# user aware that it does not know how to compute that gradient
# user aware that it does not know how to compute that gradient
if
not
isinstance
(
wrt
,
(
list
,
tuple
)):
wrt
=
[
wrt
]
ret
=
[]
ret
=
[]
for
p
in
wrt
:
for
p
in
wrt
:
if
p
in
gmap
:
if
p
in
gmap
:
...
@@ -400,6 +411,7 @@ def grad(cost, wrt, g_cost = None, consider_constant = None, warn_type = False,
...
@@ -400,6 +411,7 @@ def grad(cost, wrt, g_cost = None, consider_constant = None, warn_type = False,
if
not
using_list
and
not
using_tuple
:
if
not
using_list
and
not
using_tuple
:
wrt
=
[
wrt
]
wrt
=
[
wrt
]
var_to_node_to_idx
=
_populate_var_to_node_to_idx
([
cost
])
var_to_node_to_idx
=
_populate_var_to_node_to_idx
([
cost
])
#build a dict mapping var to the gradient of cost with respect to var
#build a dict mapping var to the gradient of cost with respect to var
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论