(self, serialized_example)
Parse serialized examples.
Parse serialized examples.
Parse serialized examples .
def parser_fn(self, serialized_example):
    """Parse serialized examples."""
    if self.is_supervised:
      features = tf.io.parse_single_example(
          serialized_example,
          features={
              "inputs": tf.io.FixedLenFeature([], tf.string),
              "targets": tf.io.FixedLenFeature([], tf.string),
          })
      return {
          "inputs": features["inputs"],
          "targets": features["targets"],
          "supervised": tf.constant(True)
      }
    else:
      features = tf.io.parse_single_example(
          serialized_example,
          features={
              "text": tf.io.FixedLenFeature([], tf.string),
          })
      return {
          "inputs": features["text"],
          "targets": tf.constant(""),
          "supervised": tf.constant(False)
      }
def parser_fn ( self , serialized_example ) : if self . is_supervised : features = tf . io . parse_single_example ( serialized_example , features = { "inputs" : tf . io . FixedLenFeature ( [ ] , tf . string ) , "targets" : tf . io . FixedLenFeature ( [ ] , tf . string ) , } ) return { "inputs" : features [ "inputs" ] , "targets" : features [ "targets" ] , "supervised" : tf . constant ( True ) } else : features = tf . io . parse_single_example ( serialized_example , features = { "text" : tf . io . FixedLenFeature ( [ ] , tf . string ) , } ) return { "inputs" : features [ "text" ] , "targets" : tf . constant ( "" ) , "supervised" : tf . constant ( False ) }