提交 ec9aa6b7 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

fixed bug where tensor.grad tried to change tuples

上级 49d2b14b
......@@ -547,8 +547,10 @@ def grad(cost, wrt, g_cost = None, consider_constant = None, warn_type = 'ignore
#populate term_dict[node] and return it
def access_term_cache(node):
if node not in term_dict:
term_dict[node] = node.op.grad(node.inputs,
[access_grad_cache(var) for var in node.outputs])
#must convert to list in case the op returns a tuple
#we won't be able to post-process out the Nones if it does that
term_dict[node] = list(node.op.grad(node.inputs,
[access_grad_cache(var) for var in node.outputs]))
for i in xrange(len(term_dict[node])):
if term_dict[node][i] is None:
term_dict[node][i] = tensor.zeros_like(node.inputs[i])
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论