MCPcopy Create free account
hub / github.com/google-research/language / parse_tf_example

Function parse_tf_example

language/realm/retrieval.py:596–619  ·  view source on GitHub ↗
(serialized)

Source from the content-addressed store, hash-verified

594 run_config=tpu_run_config)
595
596 def parse_tf_example(serialized):
597 # FixedLenSequenceFeature requires allow_missing to be True, even though we
598 # can't actually handle those cases.
599 feature_spec = {
600 'title':
601 tf.FixedLenSequenceFeature([], tf.string, allow_missing=True),
602 'text':
603 tf.FixedLenSequenceFeature([], tf.string, allow_missing=True),
604 'title_token_ids':
605 tf.FixedLenSequenceFeature([], tf.int64, allow_missing=True),
606 'body_token_ids':
607 tf.FixedLenSequenceFeature([], tf.int64, allow_missing=True),
608 }
609 features = tf.parse_single_example(serialized, feature_spec)
610
611 # tf.Example only supports tf.int64, but the TPU only supports tf.int32.
612 # So cast all int64 to int32.
613 for name in list(features.keys()):
614 tensor = features[name]
615 if tensor.dtype == tf.int64:
616 tensor = tf.cast(tensor, tf.int32)
617 features[name] = tensor
618
619 return features
620
621 def get_documents_dataset():
622 # Note: num_parallel_reads should be None to guarantee that shard_paths

Callers

nothing calls this directly

Calls 1

keysMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…