def read_and_decode_embedding(filename_queue):
reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
features = tf.parse_single_example(
serialized_example,
# Defaults are not specified since both keys are required.
features={
'label': tf.FixedLenFeature(
[], tf.int64),
'sequence_raw': tf.FixedLenFeature(
[], tf.string),
})
sequence = features['sequence_raw']
# preprocess
s_decode = tf.decode_raw(sequence, tf.int32)
s_decode.set_shape([FLAGS.embed_length])
# Convert label from a scalar uint8 tensor to an int32 scalar.
label = tf.cast(features['label'], tf.int32)
return s_decode, label
评论列表
文章目录