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

Method testVariables

tensorflow/python/training/saver_test.py:614–636  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

612 self.evaluate(variables.global_variables_initializer())
613
614 def testVariables(self):
615 save_path = os.path.join(self.get_temp_dir(), "variables")
616 with session.Session("", graph=ops_lib.Graph()) as sess:
617 one = variables.VariableV1(1.0)
618 twos = variables.VariableV1([2.0, 2.0, 2.0])
619 v2 = saver_test_utils.CheckpointedOp(name="v2")
620 init = variables.global_variables_initializer()
621 save = saver_module.Saver()
622 init.run()
623 v2.insert("k1", 3.0).run()
624 save.save(sess, save_path)
625
626 with session.Session("", graph=ops_lib.Graph()) as sess:
627 one = variables.VariableV1(0.0)
628 twos = variables.VariableV1([0.0, 0.0, 0.0])
629 v2 = saver_test_utils.CheckpointedOp(name="v2")
630 # Saver with no arg, defaults to 'all variables'.
631 save = saver_module.Saver()
632 save.restore(sess, save_path)
633 self.assertAllClose(1.0, self.evaluate(one))
634 self.assertAllClose([2.0, 2.0, 2.0], self.evaluate(twos))
635 self.assertEqual(b"k1", self.evaluate(v2.keys()))
636 self.assertEqual(3.0, self.evaluate(v2.values()))
637
638 def testVarListShouldBeEmptyInDeferredBuild(self):
639 with ops_lib.Graph().as_default():

Callers

nothing calls this directly

Calls 12

insertMethod · 0.95
saveMethod · 0.95
restoreMethod · 0.95
keysMethod · 0.95
valuesMethod · 0.95
get_temp_dirMethod · 0.80
joinMethod · 0.45
SessionMethod · 0.45
GraphMethod · 0.45
runMethod · 0.45
assertAllCloseMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected