def test_grad_scale(): x = theano.tensor.scalar() z = theano.tensor.grad(gradient.grad_scale(x, 2)**2, x) z2 = theano.tensor.grad(x**2, x) f = theano.function([x], outputs=[z, z2]) if config.mode != "FAST_COMPILE": topo = f.maker.fgraph.toposort() assert not any( [isinstance(node.op, gradient.GradScale) for node in topo]) out = f(2.0) assert np.allclose(out, (8, 4))
def test_grad_scale(): x = theano.tensor.scalar() z = theano.tensor.grad(gradient.grad_scale(x, 2)**2, x) z2 = theano.tensor.grad(x**2, x) f = theano.function([x], outputs=[z, z2]) if theano.config.mode != "FAST_COMPILE": topo = f.maker.fgraph.toposort() assert not any([isinstance(node.op, gradient.GradScale) for node in topo]) out = f(2.) assert np.allclose(out, (8, 4))