Last active
September 4, 2017 12:01
-
-
Save tomrunia/9ed29e4add47df35f511a0d008254ec2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Initialize placeholders for feeding in to the queue | |
self.queue_inputs = tf.placeholder(tf.float32, shape=[None, self.config.seq_length, self.config.image_size, self.config.image_size], name="queue_inputs") | |
self.queue_targets = tf.placeholder(tf.uint8, shape=[None, self.config.seq_length], name="queue_targets") | |
min_after_dequeue = 10000 | |
capacity = min_after_dequeue + 3 * self.config.batch_size | |
q = tf.FIFOQueue( | |
capacity=15000, | |
dtypes=[tf.float32, tf.uint8], | |
shapes=[[self.config.seq_length, self.config.image_size, self.config.image_size], [self.config.seq_length]] | |
) | |
self.enqueue_op = q.enqueue_many([self.queue_inputs, self.queue_targets]) | |
self.examples_in_queue = q.size() | |
# This must be the input for the training operation | |
self.inputs_batch_queue, self.targets_batch_queue = q.dequeue_many(self.config.batch_size) | |
# Placeholders for training and evaluation | |
self.inputs_batch = tf.placeholder_with_default(self.inputs_batch_queue, [None, self.config.seq_length, self.config.image_size, self.config.image_size], name="model_inputs") | |
self.targets_batch = tf.placeholder_with_default(self.targets_batch_queue, [None, self.config.seq_length], name="model_targets") | |
# ... | |
############################################################################ | |
############################################################################ | |
############################################################################ | |
# Coordinator for threads | |
coord = tf.train.Coordinator() | |
# Start a thread to enqueue data asynchronously, and hide I/O latency. | |
t = threading.Thread(target=load_and_enqueue, args=( | |
config.input_dir, sess, coord, | |
model.enqueue_op, model.queue_inputs, | |
model.queue_targets, config.num_train, 100, config.rewrite_targets, | |
)) | |
t.setDaemon(True) | |
t.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment