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

Method testBasic

tensorflow/python/ops/gradients_test.py:855–874  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

853
854 @test_util.run_v1_only("b/120545219")
855 def testBasic(self):
856 gamma = resource_variable_ops.ResourceVariable(
857 np.random.random((3,)),
858 dtype="float32", name="gamma")
859
860 inputs = array_ops.ones(shape=(3,), dtype="float32")
861
862 def TestFn():
863 output = inputs + gamma
864 return output
865
866 training = array_ops.placeholder_with_default(True, shape=())
867 output = control_flow_ops.cond(
868 training, TestFn, lambda: inputs)
869
870 loss = output
871
872 grads = gradients.gradients(
873 loss, [gamma])
874 self.assertTrue(None not in grads)
875
876
877class GetDependentVariablesTest(test_util.TensorFlowTestCase):

Callers

nothing calls this directly

Calls 3

onesMethod · 0.80
ResourceVariableMethod · 0.45
condMethod · 0.45

Tested by

no test coverage detected