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

Method test_functions_list

tensorflow/python/saved_model/load_test.py:1048–1067  ·  view source on GitHub ↗
(self, cycles)

Source from the content-addressed store, hash-verified

1046 self.assertEqual(3, len(imported.variables))
1047
1048 def test_functions_list(self, cycles):
1049 root = tracking.AutoTrackable()
1050 v1 = variables.Variable(1.)
1051 root.losses = [def_function.function(lambda: math_ops.reduce_sum(v1 ** 2))]
1052 root.variables = [v1]
1053
1054 @def_function.function
1055 def _v2_loss():
1056 if len(root.variables) == 1:
1057 v2 = variables.Variable(2.)
1058 root.variables.append(v2)
1059 return math_ops.reduce_sum(root.variables[1] ** 2)
1060
1061 root.losses.append(_v2_loss)
1062 self.assertAllClose([1., 4.], [loss() for loss in root.losses])
1063 imported = cycle(root, cycles)
1064 self.assertAllClose([1., 4.], [loss() for loss in imported.losses])
1065 imported.variables[0].assign(3.)
1066 imported.variables[1].assign(4.)
1067 self.assertAllClose([9., 16.], [loss() for loss in imported.losses])
1068
1069 def test_captured_constant(self, cycles):
1070 const = array_ops.zeros([100])

Callers

nothing calls this directly

Calls 8

cycleFunction · 0.85
VariableMethod · 0.80
reduce_sumMethod · 0.80
lossFunction · 0.50
functionMethod · 0.45
appendMethod · 0.45
assertAllCloseMethod · 0.45
assignMethod · 0.45

Tested by

no test coverage detected