(self)
| 399 | |
| 400 | @test_util.run_deprecated_v1 |
| 401 | def testGrad(self): |
| 402 | np.random.seed(42) |
| 403 | for num_inputs in range(1, 10): |
| 404 | with self.cached_session(use_gpu=True) as sess: |
| 405 | input_vars = [ |
| 406 | variables.Variable(10.0 * np.random.random()) |
| 407 | for i in range(0, num_inputs) |
| 408 | ] |
| 409 | addn = math_ops.add_n(input_vars) |
| 410 | self.evaluate(variables.global_variables_initializer()) |
| 411 | add_n_grad = gradients.gradients(addn, input_vars) |
| 412 | self.assertAllEqual(np.repeat(1.0, num_inputs), # d/dx (x + y + ...) = 1 |
| 413 | [g.eval() for g in add_n_grad]) |
| 414 | |
| 415 | |
| 416 | @test_util.run_deprecated_v1 |
nothing calls this directly
no test coverage detected