tensorflow|tf.train.slice_input_producer|tf.train.Coordinator|tf.train.start_queue_runners

# ### 
'' ' 
tf.train.slice_input_producer: definition of sample is placed in a queue file name mode [iterations, whether scrambled], but this time the file name has not really write data queue 
    slice_input_producer (tensor_list, num_epochs = None , shuffle = True, SEED = None, Capacity = 32, shared_name = None, name = None) 
        tensor_list: The [images, labels] = [[ 'img1', 'image2', 'imag3', 'img4', 'img5 ',' img6 '], [1,2,3,4,5,6]] 
        num_epochs: an optional parameter, an unlimited number of iterations num_epochs = None tensor traversal list generator num_epochs = N only through a list of N times 
        shuffle: shuffle = True scrambled sample shuffle = False tf.train required when the batch.shuffle_batch function disrupted sample 
        seed: seed a random number used in the shuffle = True when 
        capacity: Capacity list provided tensor 
        shared_name: Alternatively, if set to a 'shared_name', then in different contexts (Session) may by this name the generated shared Tensor 
        name: name of the setting operation 

'' ' 
ImportAS TF tensorflow 

# ## ideas: Prepare a file name to create a thread queue enqueue thread 
ImagesRF Royalty Free = [ ' img1 ' , ' image2 ' , ' imag3 ' , ' img4 ' , ' img5 ' , ' img6 ' ] 
Labels = [1, 2,3,4,5,6 ] 

epoch_num = 8 
queue = tf.train.slice_input_producer ([ImagesRF Royalty Free, Labels], num_epochs = None, shuffle = False) # extract tensor from the file, ready to put in the file name queue 
with tf the .session () AS sess: 
    sess.run (tf.global_variables_initializer ()) 
    coordTf.train.Coordinator = ()                              # ## coordinator creates a thread, and then start to manage the Session after all threads 
    # ## team started the thread, a multiple or single thread, in accordance with the rules set to read a file filename into the queue, returns a list of thread ID. In general, the number of nuclear systems, the team will start the number of threads 
    # ## into the team how many threads using a specific set tf.train.batch in 
    Threads = tf.train.start_queue_runners (sess, coord = coord)
     for I in (epoch_num) Range: 
        K = sess.run (Queue)
         Print ( " ************* " )
         Print (I, K, K [0], K [. 1 ]) 

        '' ' 
        ************* 
0 [b'img1',. 1] b'img1 '. 1 
*************  
. 1 [b'image2', 2] b '
******* ******
2 [b'imag3', 3] b'imag3' 3
*************
3 [b'img4', 4] b'img4' 4
*************
4 [b'img5', 5] b'img5' 5
*************
5 [b'img6', 6] b'img6' 6
*************
6 [b'img1', 1] b'img1' 1
*************
7 [b'image2', 2] b'image2' 2
        '''
Ready - to create a thread - the thread into the team

 

Guess you like

Origin www.cnblogs.com/liuhuacai/p/11725911.html