#NEWLINE# def patches_gen_ordered( images , patch_size = ( 50 , 50 ) , chunk_size = 4096 ) : #NEWLINE# #INDENT# ( p_x , p_y ) = patch_size #NEWLINE# num_images = len ( images ) #NEWLINE# num_chunks = int ( np . ceil ( ( num_images / float ( chunk_size ) ) ) ) #NEWLINE# idx = 0 #NEWLINE# for n in xrange ( num_chunks ) : #NEWLINE# #INDENT# chunk_x = np . zeros ( ( chunk_size , p_x , p_y ) , dtype = 'float32' ) #NEWLINE# chunk_length = chunk_size #NEWLINE# for k in xrange ( chunk_size ) : #NEWLINE# #INDENT# if ( idx >= num_images ) : #NEWLINE# #INDENT# chunk_length = k #NEWLINE# break #NEWLINE# #UNINDENT# img = images [ idx ] #NEWLINE# extract_image_patch ( chunk_x [ k ] , img ) #NEWLINE# idx += 1 #NEWLINE# #UNINDENT# ( yield ( images , chunk_length ) )