def read_pascifar(pascifar_path, queue):
""" Reads and parses files from the queue.
Args:
pascifar_path: a constant string tensor representing the path of the PASCIFAR dataset
queue: A queue of strings in the format: file, label
Returns:
image_path: a tf.string tensor. The absolute path of the image in the dataset
label: a int64 tensor with the label
"""
# Reader for text lines
reader = tf.TextLineReader(skip_header_lines=1)
# read a record from the queue
_, row = reader.read(queue)
# file,width,height,label
record_defaults = [[""], [0]]
image_path, label = tf.decode_csv(row, record_defaults, field_delim=",")
image_path = pascifar_path + tf.constant("/") + image_path
label = tf.cast(label, tf.int64)
return image_path, label
评论列表
文章目录