def batch_shuffle(index_array, batch_size):
 batch_count = int((len(index_array) / batch_size))
 last_batch = index_array[(batch_count * batch_size):]
 index_array = index_array[:(batch_count * batch_size)]
 index_array = index_array.reshape((batch_count, batch_size))
 np.random.shuffle(index_array)
 index_array = index_array.flatten()
 return np.append(index_array, last_batch)

def batch_shuffle ( index_array , batch_size ) : batch_count = int ( ( len ( index_array ) / batch_size ) ) last_batch = index_array [ ( batch_count * batch_size ) : ] index_array = index_array [ : ( batch_count * batch_size ) ] index_array = index_array . reshape ( ( batch_count , batch_size ) ) np . random . shuffle ( index_array ) index_array = index_array . flatten ( ) return np . append ( index_array , last_batch )
this shuffles an array in a batch-wise fashion .