MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / testGrad

Method testGrad

tensorflow/python/ops/math_ops_test.py:401–413  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

VariableMethod · 0.80
rangeFunction · 0.70
seedMethod · 0.45
cached_sessionMethod · 0.45
evaluateMethod · 0.45
assertAllEqualMethod · 0.45
repeatMethod · 0.45
evalMethod · 0.45

Tested by

no test coverage detected