def test_verify_second_grad_sitsot(self):
def get_sum_of_grad(inp):
scan_outputs, updates = theano.scan(fn=lambda x: x * 2,
outputs_info=[inp],
n_steps=5)
# Take the gradient of each output wrt its corresponding initial
# state
return theano.grad(scan_outputs.sum(), inp).sum()
# Call verify_grad to ensure the correctness of the second gradients
floatX = theano.config.floatX
inputs_test_values = [numpy.random.random((3)).astype(floatX)]
theano.tests.unittest_tools.verify_grad(get_sum_of_grad,
inputs_test_values)
评论列表
文章目录