band/utils.py
def process_feature(self, feature):
        """Write a InputFeature to the TFRecordWriter as a tf.train.Example."""
        self.num_features += 1

        def create_int_feature(values):
            feature = tf.train.Feature(
                int64_list=tf.train.Int64List(value=list(values)))
            return feature

        features = collections.OrderedDict()
        features["unique_ids"] = create_int_feature([feature.unique_id])
        features["input_ids"] = create_int_feature(feature.input_ids)
        features["input_mask"] = create_int_feature(feature.input_mask)
        features["segment_ids"] = create_int_feature(feature.segment_ids)

        if self.is_training:
            features["start_positions"] = create_int_feature([feature.start_position])
            features["end_positions"] = create_int_feature([feature.end_position])
            impossible = 0
            if feature.is_impossible:
                impossible = 1
            features["is_impossible"] = create_int_feature([impossible])

        tf_example = tf.train.Example(features=tf.train.Features(feature=features))
        self._writer.write(tf_example.SerializeToString())
Write a InputFeature to the TFRecordWriter as a tf.train.Example.
Write a InputFeature to the TFRecordWriter as a tf.train.Example.
Write a InputFeature to the TFRecordWriter as a tf . train . Example .
def process_feature(self, feature):
        self.num_features += 1
        def create_int_feature(values):
            feature = tf.train.Feature(
                int64_list=tf.train.Int64List(value=list(values)))
            return feature
        features = collections.OrderedDict()
        features["unique_ids"] = create_int_feature([feature.unique_id])
        features["input_ids"] = create_int_feature(feature.input_ids)
        features["input_mask"] = create_int_feature(feature.input_mask)
        features["segment_ids"] = create_int_feature(feature.segment_ids)
        if self.is_training:
            features["start_positions"] = create_int_feature([feature.start_position])
            features["end_positions"] = create_int_feature([feature.end_position])
            impossible = 0
            if feature.is_impossible:
                impossible = 1
            features["is_impossible"] = create_int_feature([impossible])
        tf_example = tf.train.Example(features=tf.train.Features(feature=features))
        self._writer.write(tf_example.SerializeToString())
def process_feature ( self , feature ) : self . num_features += 1 def create_int_feature ( values ) : feature = tf . train . Feature ( int64_list = tf . train . Int64List ( value = list ( values ) ) ) return feature features = collections . OrderedDict ( ) features [ "unique_ids" ] = create_int_feature ( [ feature . unique_id ] ) features [ "input_ids" ] = create_int_feature ( feature . input_ids ) features [ "input_mask" ] = create_int_feature ( feature . input_mask ) features [ "segment_ids" ] = create_int_feature ( feature . segment_ids ) if self . is_training : features [ "start_positions" ] = create_int_feature ( [ feature . start_position ] ) features [ "end_positions" ] = create_int_feature ( [ feature . end_position ] ) impossible = 0 if feature . is_impossible : impossible = 1 features [ "is_impossible" ] = create_int_feature ( [ impossible ] ) tf_example = tf . train . Example ( features = tf . train . Features ( feature = features ) ) self . _writer . write ( tf_example . SerializeToString ( ) )
Write a InputFeature to the TFRecordWriter as a tf.train.Example.
Write a InputFeature to the TFRecordWriter as a tf . train . Example .
"""Write a InputFeature to the TFRecordWriter as a tf.train.Example."""
self
feature