def read_and_decode_single_example(filenames, shuffle=False, num_epochs=None):
# first construct a queue containing a list of filenames.
# this lets a user split up there dataset in multiple files to keep size down
# filename_queue = tf.train.string_input_producer([filename], num_epochs=10)
filename_queue = tf.train.string_input_producer(filenames,
shuffle=shuffle, num_epochs=num_epochs)
reader = tf.TFRecordReader()
# One can read a single serialized example from a filename
# serialized_example is a Tensor of type string.
_, serialized_ex = reader.read(filename_queue)
context, sequences = tf.parse_single_sequence_example(serialized_ex,
context_features={
"seq_length": tf.FixedLenFeature([], dtype=tf.int64)
},
sequence_features={
"seq_feature": tf.VarLenFeature(dtype=tf.int64),
"label": tf.VarLenFeature(dtype=tf.int64)
})
return context, sequences
评论列表
文章目录