Ejemplo n.º 1
0
 def test_spec_to_from_file(self):
     example_encoding_dataset.encode_spec_to_file(self.dataset_path,
                                                  self.simple_data_spec)
     loaded_spec = example_encoding_dataset.parse_encoded_spec_from_file(
         self.dataset_path)
     self.assertTupleEqual(loaded_spec, self.simple_data_spec)
     with self.assertRaises(IOError):
         example_encoding_dataset.parse_encoded_spec_from_file(
             "fake_file.tfrecord")
Ejemplo n.º 2
0
 def test_conflicting_specs(self):
   # If two different specs are encountered an error should be thrown
   self.other_data_spec = SimpleSpec(
       step_type=tf.TensorSpec(shape=(1), dtype=tf.int32, name="step_type"),
       value=tf.TensorSpec(shape=(1, 5), dtype=tf.float64, name="value"))
   self.other_dataset_path = os.path.join(
       self.get_temp_dir(), "other_test_tfrecord_dataset.tfrecord")
   example_encoding_dataset.encode_spec_to_file(self.other_dataset_path,
                                                self.other_data_spec)
   with self.assertRaises(IOError):
     example_encoding_dataset.load_tfrecord_dataset(
         [self.dataset_path, self.other_dataset_path])