Concurrent_AP.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:ProjectOfDataMining 作者: IljaNovo 项目源码 文件源码
def compute_responsibilities(hdf5_file, N_columns, damping, N_processes):
    """Organize the computation and update of the responsibility matrix
        for Affinity Propagation clustering with 'damping' as the eponymous 
        damping parameter. Each of the processes concurrently involved in this task 
        is an instance of the class 'Responsibilities_worker' defined above.
    """

    slice_queue = multiprocessing.JoinableQueue()

    pid_list = []
    for i in xrange(N_processes):
        worker = Responsibilities_worker(hdf5_file, '/aff_prop_group',
                   N_columns, damping, slice_queue)
        worker.daemon = True
        worker.start()
        pid_list.append(worker.pid)

    for rows_slice in chunk_generator(N_columns, 8 * N_processes):
        slice_queue.put(rows_slice)

    slice_queue.join()
    slice_queue.close()

    terminate_processes(pid_list)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号