Thread in suction tensor flow

Background

A typical input conveyor in a tensor stream is as follows:

                  tf.train.string_input_producer(list_of_filenames)
                         (creates queue of filenames)
                                   |
                                  \|/
           fixed length reader reads records from the files
                                   |
                                  \|/
    Read records are decoded and processed(eg if dealing with images then cropping,flipping etc)
                                   |
                                  \|/
            tf.train.shuffle_batch(tensors,num_threads)
        (creates a shuffling queue and returns batches of tensors) 

Problem

Q1) There are no num_threads arguments in the tf.train.string_input_producer () function. Does this mean that only one thread is designed to read file names from the file name queue?

Q2) What is the scope of the num_threads argument of the tf.train.shuffle_batch () function, that is, the number of threads mentioned here is used to read, decode and process files, or are they just used to create tensor batches?

Q3) Is there a way to print which thread reads file names or records from a specific file, that is, some kind of record of work performed by each thread?

+6
1

tensorflow, , , - /. Tensorflow QueueRunner, . Coordinator .

https://www.tensorflow.org/programmers_guide/threading_and_queues

:

# Create a queue runner that will run 4 threads in parallel to enqueue
# examples.
qr = tf.train.QueueRunner(queue, [enqueue_op] * 4)

# Launch the graph.
sess = tf.Session()
# Create a coordinator, launch the queue runner threads.
coord = tf.train.Coordinator()
enqueue_threads = qr.create_threads(sess, coord=coord, start=True)
# Run the training loop, controlling termination with the coordinator.
for step in xrange(1000000):
    if coord.should_stop():
        break
    sess.run(train_op)
# When done, ask the threads to stop.
coord.request_stop()
# And wait for them to actually do it.
coord.join(enqueue_threads)

/ ( , TF), QueueRunner, sess.run(enqueue_op, feed_dict={...}) .

Q1: : qr.create_threads(sess, coord=coord, start=True)

Q2: TF , tf.run(...) . QueueRunner . .

Q3: tf.train.string_input_producer, , , , dequeued , sess.run([train_op, dequeue_op])

+4

Source: https://habr.com/ru/post/1016032/


All Articles