dumping queue into list/array in python -
i running number of threads , collecting there result on queue. dump array or list can indexing , retrieve results. each of elements in queue array of dimension n. access arrays. please let me know, how it?
def dump_queue(model_queue): queue_list = [] in iter(model_queue.get,'stop'): queue_list.append(i) return queue_list aux_model=train_svm(np.array(trainexample),np.array(trainlabel)) model_queue.put(aux_model.coef_)
thus arrays learned model parameters of svm
. model_queue shared among threads. want access each of model parameters vectors not each of entries of model parameters.
you're done parallel part , want results in list, it? try:
list(my_queue.queue)
example:
from queue import queue q = queue() in range(5): q.put(i) l = list(q.queue) print(l)
output:
[0, 1, 2, 3, 4]
Comments
Post a Comment