Workaround for Item assignment not supported in dask

穿精又带淫゛_ 提交于 2019-12-11 08:13:03

问题


I am trying to convert my code base from numpy array to dask because my numpy arrays are exceeding the Memory Error limit. But, I come to know that the feature of mutable arrays are not yet implemented in dask arrays so I am getting
NotImplementedError: Item assignment with <class 'tuple'> not supported
Is there any workaround for my code below-

for i, mask in enumerate(masks):
    bounds = find_boundaries(mask, mode='inner')
    X2, Y2 = np.nonzero(bounds)
    X2 = da.from_array(X2, 'auto')
    Y2 = da.from_array(Y2, 'auto')
    xSum = (X2.reshape(-1, 1) - X1.reshape(1, -1)) ** 2
    ySum = (Y2.reshape(-1, 1) - Y1.reshape(1, -1)) ** 2
    #Failing on below line
    distMap[:,i] = da.sqrt(xSum + ySum).min(axis=0)

    break

I also tried computing all other computations in dask and using distMap as a numpy array but still got the Memory Error. Any workarounds are welcome.


回答1:


Maybe you can construct many dask arrays and then use da.concatenate or da.stack to merge them into a single dask array?



来源:https://stackoverflow.com/questions/58277168/dask-implementation-for-mutation-operation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!