def test_1in_Nout(self):
"""Test grad is called correctly for a 1-to-many op"""
gval = theano.tensor.matrix()
class O(gof.op.Op):
__props__ = ()
def make_node(self):
inputs = [theano.tensor.matrix()]
outputs = [theano.tensor.scalar(), theano.tensor.scalar()]
return gof.Apply(self, inputs, outputs)
def grad(self, inp, grads):
x, = inp
gz1, gz2 = grads
return gval,
a1 = O().make_node()
g = grad_sources_inputs([(a1.outputs[0], one)], None)
self.assertTrue(g[a1.inputs[0]] is gval)
评论列表
文章目录