在dask中不支持项目分配的解决方法 [英] Workaround for Item assignment not supported in dask

查看:73
本文介绍了在dask中不支持项目分配的解决方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将代码库从numpy数组转换为dask,因为我的numpy数组超出了Memory Error限制.但是,我知道dask arrays尚未实现可变数组的功能,所以我得到了
NotImplementedError: Item assignment with <class 'tuple'> not supported
下面的代码是否有任何解决方法?

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

我也尝试用dask计算所有其他计算,并使用distMap作为一个numpy数组,但仍然得到了Memory Error. 欢迎任何解决方法.

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.

推荐答案

也许您可以构造许多dask数组,然后使用da.concatenateda.stack将它们合并为单个dask数组?

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

这篇关于在dask中不支持项目分配的解决方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆