(self)
| 40 | class 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() |
nothing calls this directly
no test coverage detected