MCPcopy Create free account
hub / github.com/tensorflow/datasets / _serialize_example

Method _serialize_example

tensorflow_datasets/core/writer.py:533–545  ·  view source on GitHub ↗

Returns (shard#, (hkey, serialized_example)).

(
      self,
      key_example: tuple[hashing.HashKey, Example],
  )

Source from the content-addressed store, hash-verified

531 self.__init__(**state)
532
533 def _serialize_example(
534 self,
535 key_example: tuple[hashing.HashKey, Example],
536 ) -> tuple[Any, bytes]:
537 """Returns (shard#, (hkey, serialized_example))."""
538 key, example = key_example
539 serialized_example = self._serializer.serialize_example(example)
540 if self._disable_shuffling:
541 hkey = key
542 else:
543 hkey = self._hasher.hash_key(key)
544 self.inc_counter(name="serialized_examples")
545 return (hkey, serialized_example)
546
547 def _check_num_examples(self, num_examples: int) -> int:
548 if num_examples <= 0:

Callers

nothing calls this directly

Calls 3

inc_counterMethod · 0.95
hash_keyMethod · 0.80
serialize_exampleMethod · 0.45

Tested by

no test coverage detected