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

Method testBasics

tensorflow/contrib/eager/python/saver_test.py:40–55  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

38 return '/device:GPU:0' if context.num_gpus() else '/device:CPU:0'
39
40 def testBasics(self):
41 with ops.device(self._dev()):
42 v1 = resource_variable_ops.ResourceVariable(1.0, name='v1')
43 def model():
44 return array_ops.constant(2.0) * v1
45
46 ckpt_prefix = os.path.join(test.get_temp_dir(), 'ckpt')
47
48 _ = model()
49 saver = _saver.Saver([v1])
50 saver.save(ckpt_prefix)
51 v1.assign(2.0)
52 self.assertEqual(v1.read_value().numpy(), 2.0)
53
54 saver.restore(ckpt_prefix)
55 self.assertEqual(v1.read_value().numpy(), 1.0)
56
57 def testSameNameNoClobbering(self):
58 with ops.device(self._dev()):

Callers

nothing calls this directly

Calls 11

_devMethod · 0.95
saveMethod · 0.95
restoreMethod · 0.95
modelFunction · 0.85
get_temp_dirMethod · 0.80
deviceMethod · 0.45
ResourceVariableMethod · 0.45
joinMethod · 0.45
assignMethod · 0.45
numpyMethod · 0.45
read_valueMethod · 0.45

Tested by

no test coverage detected