Created
October 19, 2011 16:11
-
-
Save bayerj/1298794 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/theano/tensor/basic.py b/theano/tensor/basic.py | |
| index f9e7240..091486b 100644 | |
| --- a/theano/tensor/basic.py | |
| +++ b/theano/tensor/basic.py | |
| @@ -5091,6 +5091,7 @@ class AdvancedSubtensor(Op): | |
| rest = inputs[1:] | |
| return [AdvancedIncSubtensor(self.args)(zeros_like(x), gz, *rest)] + [None]*len(rest) | |
| + | |
| class AdvancedIncSubtensor(Op): | |
| """Increments a subtensor using advanced indexing. | |
| """ | |
| @@ -5121,10 +5122,14 @@ class AdvancedIncSubtensor(Op): | |
| out[0] = inputs[0].copy() | |
| out[0][inputs[2:]] += inputs[1] | |
| - #def grad? | |
| - # grad on x is grad on output | |
| - # grad on y is grad_output[idx_list] | |
| - # grad on rest is None | |
| + def grad(self, inputs, grads): | |
| + x, rest = inputs[0], inputs[2:] | |
| + grad, = grads | |
| + res = [grad, | |
| + AdvancedIncSubtensor(self.args)(zeros_like(x), grad, *rest)] | |
| + res += [None for _ in rest] | |
| + return res | |
| + | |
| def R_op(self, inputs, eval_points): | |
| if None in eval_points[:2]: | |
| return [None] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment