小编Eng*_*her的帖子

为什么在使用pythons多处理在for循环中使用共享numpy数据进行令人难以置信的并行问题时,没有加速?

我想加快一个与贝叶斯推理相关的令人尴尬的并行问题.目的是在给定矩阵A的情况下推断出一组图像x的系数u,使得X = A*U. X的尺寸为mxn,A mxp和U pxn.对于X的每一列,必须推断系数U的最佳对应列.最后,该信息用于更新A.我使用m = 3000,p = 1500和n = 100.因此,因为它是在线性模型中,系数矩阵u的推断由n个独立的计算组成.因此,我尝试使用Python的多处理模块,但没有加速.

这是我做的:

没有并行化的主要结构是:

import numpy as np
from convex import Crwlasso_cd

S = np.empty((m, batch_size))

for t in xrange(start_iter, niter):

    ## Begin Warm Start ##
    # Take 5 gradient steps w/ this batch using last coef. to warm start inf.
    for ws in range(5):
        # Initialize the coefficients
        if ws:
            theta = U
        else:
            theta = np.dot(A.T, X)

        # Infer the Coefficients for the given data batch X of …
Run Code Online (Sandbox Code Playgroud)

python multiprocessing

15
推荐指数
1
解决办法
2134
查看次数

标签 统计

multiprocessing ×1

python ×1