提交 95eb71b3 authored 作者: Razvan Pascanu's avatar Razvan Pascanu

fix bug with list of outputs

the previous code returned list of tuples (not 100% sure why - I guess is a python thing). This makes sure we are dealing with a list of variables.
上级 75a8e24b
...@@ -755,12 +755,15 @@ def jacobian(expression, wrt, consider_constant=None, warn_type=False, ...@@ -755,12 +755,15 @@ def jacobian(expression, wrt, consider_constant=None, warn_type=False,
def inner_function(*args): def inner_function(*args):
idx = args[0] idx = args[0]
expr = args[1] expr = args[1]
return [grad(exp[idx], rvals = []
for inp in args[2:]:
rval = grad(expr[idx],
inp, inp,
consider_constant=consider_constant, consider_constant=consider_constant,
warn_type=warn_type, warn_type=warn_type,
disconnected_inputs=disconnected_inputs) disconnected_inputs=disconnected_inputs)
for inp in [args[2:]]] rvals.append(rval)
return rvals
# Computing the gradients does not affect the random seeds on any random # Computing the gradients does not affect the random seeds on any random
# generator used n expression (because during computing gradients we are # generator used n expression (because during computing gradients we are
# just backtracking over old values. (rp Jan 2012 - if anyone has a # just backtracking over old values. (rp Jan 2012 - if anyone has a
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论