MCPcopy Index your code
hub / github.com/tensorflow/models / test_export_module

Method test_export_module

official/core/export_base_test.py:42–66  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

40class ExportBaseTest(tf.test.TestCase):
41
42 def test_export_module(self):
43 tmp_dir = self.get_temp_dir()
44 model = tf_keras.layers.Dense(2)
45 inputs = tf.ones([2, 4], tf.float32)
46 expected_output = model(inputs, training=False)
47 module = TestModule(params=None, model=model)
48 ckpt_path = tf.train.Checkpoint(model=model).save(
49 os.path.join(tmp_dir, 'ckpt'))
50 export_dir = export_base.export(
51 module, ['foo'],
52 export_savedmodel_dir=tmp_dir,
53 checkpoint_path=ckpt_path,
54 timestamped=True)
55 self.assertTrue(os.path.exists(os.path.join(export_dir, 'saved_model.pb')))
56 self.assertTrue(
57 os.path.exists(
58 os.path.join(export_dir, 'variables', 'variables.index')))
59 self.assertTrue(
60 os.path.exists(
61 os.path.join(export_dir, 'variables',
62 'variables.data-00000-of-00001')))
63
64 imported = tf.saved_model.load(export_dir)
65 output = imported.signatures['foo'](inputs)
66 self.assertAllClose(output['outputs'].numpy(), expected_output.numpy())
67
68 def test_custom_inference_step(self):
69 tmp_dir = self.get_temp_dir()

Callers

nothing calls this directly

Calls 6

TestModuleClass · 0.85
get_temp_dirMethod · 0.80
saveMethod · 0.80
exportMethod · 0.80
joinMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected