1
私はイメージの名前とラベルをリストとして持っており、64イメージ/ラベルのバッチを取得したいと思います。私はイメージを正しい方法で得ることができましたが、ラベルでは次元は(64,8126)です。各列には同じ要素が64回あります。また、行は8126個の元のラベル値で構成され、シャッフルされません。入力パイプラインのラベルを扱う方法は?
私はすべてのイメージtf.train.shuffle_batchが8126要素のラベルベクトルを考慮するという問題を理解しています。しかし、どのように私は各画像に単一の要素だけを渡すだろうか?
def _get_images(shuffle=True):
"""Gets the images and labels as a batch"""
#get image and label list
_img_names,_img_class = _get_list() #list of image names and labels
filename_queue = tf.train.string_input_producer(_img_names)
#reader
image_reader = tf.WholeFileReader()
_, image_file = image_reader.read(filename_queue)
#decode jpeg
image_original = tf.image.decode_jpeg(image_file)
label_original = tf.convert_to_tensor(_img_class,dtype=tf.int32)
#print label_original
#image preprocessing
image = tf.image.resize_images(image_original, [224,224])
float_image = tf.cast(image,dtype=tf.float32)
float_image = tf.image.per_image_standardization(image)
#set the shape
float_image.set_shape((224, 224, 3))
#label_original.set_shape([8126]) #<<<<<=========== causes (64,8126) dimension label without shuffle
#parameters for shuffle
batch_size = 64
num_preprocess_threads = 16
num_examples_per_epoch = 8000
min_fraction_of_examples_in_queue = 0.4
min_queue_examples = int(num_examples_per_epoch *
min_fraction_of_examples_in_queue)
if shuffle:
images_batch, label_batch = tf.train.shuffle_batch(
[float_image,label_original],
batch_size=batch_size,
num_threads=num_preprocess_threads,
capacity=min_queue_examples + 3 * batch_size,
min_after_dequeue=min_queue_examples)
else:
images_batch, label_original = tf.train.batch(
[float_image,_img_class],
batch_size=batch_size,
num_threads=num_preprocess_threads,
capacity=min_queue_examples + 3 * batch_size)
return images_batch,label_batch
Greattttを使用することができます!ありがとう..ありがとう! –