def _parse_example(self, serialized):
"""Unpack a serialized example to Tensor."""
feats = self._get_data_features()
sz_feats = self._get_sz_features()
for s in sz_feats:
feats[s] = sz_feats[s]
sample = tf.parse_single_example(serialized, features=feats)
data = {}
for i, f in enumerate(self.FEATURES):
s = tf.to_int32(sample[f+'_sz'])
data[f] = tf.decode_raw(sample[f], self.dtypes[f], name='decode_{}'.format(f))
data[f] = tf.reshape(data[f], s)
return data
评论列表
文章目录