提交 36a6322a authored 作者: Razvan Pascanu's avatar Razvan Pascanu

look at each input seperately

上级 28f334c5
...@@ -1255,15 +1255,20 @@ class Scan(PureOp): ...@@ -1255,15 +1255,20 @@ class Scan(PureOp):
for x in node.inputs[1:]] for x in node.inputs[1:]]
def compute_gradient(y, g_y, diff_inputs): def compute_gradient(y, g_y, diff_inputs):
try: rval = []
gmp = gradient.grad_sources_inputs( gmp = {}
[(y, g_y)], consider_inps = [x for x in theano.gof.graph.inputs([y])
[x for x in theano.gof.graph.inputs([y]) if x in diff_inputs]
if x in diff_inputs]) for x in conside_inps:
except TypeError: try:
# It means the gradient is undefined (which implies _gmp = gradient.grad_sources_inputs(
# is connected) [(y, g_y)],
return diff_inputs [x])
gmp[x] = _gmp[x]
except TypeError:
# It means the gradient is undefined (which implies
# is connected)
gmp[x] = x
return [gmp.get(p, None) for p in diff_inputs] return [gmp.get(p, None) for p in diff_inputs]
def _get_inner_outs(oidx): def _get_inner_outs(oidx):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论