新建文本文档.txt


立即下载 NetworkAttachedStorage
2024-04-19
file image batch capacity features return img read train image
1.2 KB

# Load MNIST datadef read_image(file_queue): reader = tf.TFRecordReader() key, value = reader.read(file_queue) _, serialized_example = reader.read(file_queue) features = tf.parse_single_example( serialized_example, features={ 'image_raw': tf.FixedLenFeature([], tf.string)}) image = tf.decode_raw(features['image_raw'], tf.uint8) image.set_shape([784]) image = tf.cast(image, tf.float32) * (1. / 255) - 0.5 return imagedef read_image_batch(file_queue, batch_size): img= read_image(file_queue) capacity = 3 * batch_size image_batch= tf.train.batch([img], batch_size=batch_size, capacity=capacity, num_threads=4) return image_batch train_file_path = os.path.join(FLAGS.buckets, "train.tfrecords") train_image_filename_queue = tf.train.string_input_producer( tf.train.match_filenames_once(train_file_path)) image_batch= read_image_batch(train_image_filename_queue, batch_size ) sess = tf.InteractiveSession() coord = t

file_queue/image/batch_size/capacity/features/return/img/read_image_batch/train_image_filename_queue/image_raw/ file_queue/image/batch_size/capacity/features/return/img/read_image_batch/train_image_filename_queue/image_raw/
-1 条回复
登录 后才能参与评论
-->