Example #1
0
 def tf_record(self):
     if self._tf_record is None:
         try:
             example = common.convert_dict_to_tf_example(self._raw)
             self._tf_record = example.SerializeToString()
         except Exception as e:  # pylint: disable=broad-except
             logging.error("Failed convert csv dict to tf example, "\
                           "reason %s", e)
             self._tf_record = tf.train.Example().SerializeToString()
     return self._tf_record
Example #2
0
 def make(cls, example_id, event_time, raw_id, fname=None, fvalue=None):
     fields = OrderedDict()
     fields["example_id"] = example_id
     fields["event_time"] = event_time
     fields["raw_id"] = raw_id
     if fname:
         assert len(fname) == len(fvalue), \
                 "Field name should match field value"
         for i, v in enumerate(fname):
             fields[v] = fvalue[i]
     ex = common.convert_dict_to_tf_example(fields)
     return cls(ex.SerializeToString())