با سلام من با این تا بعد tfrecord ساختم
def convert_to(images, labels, name):
num_examples = len(labels)
if images.shape[0] != num_examples:
raise ValueError("Images size %d does not match label size %d." %
(images.shape[0], num_examples))
rows = 60
cols = 60
depth = 1
filename = os.path.join('./data/', name + '.tfrecords')
print('Writing', filename)
writer = tf.python_io.TFRecordWriter(filename)
for index in range(num_examples):
image_raw = images[index].tostring()
example = tf.train.Example(features=tf.train.Features(feature={
'height': _int64_feature(rows),
'width': _int64_feature(cols),
'depth': _int64_feature(depth),
'label': _int64_feature(int(labels[index])),
'image_raw': _bytes_feature(image_raw)
}))
writer.write(example.SerializeToString())
و مخواستم با این تابع داده ها رو بخونم
def read_and_decode(filename, batch_size, num_epochs, num_samples):
filename_queue = tf.train.string_input_producer([train_tfrecord_addr],
num_epochs=num_epochs)
reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
features = tf.parse_single_example(
serialized_example,
features={
'image_raw': tf.FixedLenFeature([], tf.string),
'label': tf.FixedLenFeature([], tf.int64),
'height': tf.FixedLenFeature([], tf.int64),
'width': tf.FixedLenFeature([], tf.int64),
'depth': tf.FixedLenFeature([], tf.int64)
})
image_raw = tf.decode_raw(features['image_raw'], tf.float32)
image_resized = tf.reshape(image_raw, [60, 60, 1])
label_raw = tf.cast(features['label'], tf.int32)
images, labels = tf.train.shuffle_batch([image_resized, label_raw], batch_size=batch_size, capacity=num_samples, num_threads=1,
min_after_dequeue=10)
return images, labels
منتهی این ارور راجب bath بهم نشون میده
OutOfRangeError (see above for traceback): RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 10, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_INT32], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/device:CPU:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
مشکل از کجاست ؟ داده هام رو میتونم پرینت کنم یعنی tfrecords خالی نیست
پیشاپیش ممنونم