是否可以通过使用其他延迟值指定其形状来从延迟值创建 dask 数组?
我的算法直到计算很晚才给我数组的形状。
最终,我将创建一些具有由我的计算的中间结果指定的形状的块,最终调用da.concatenate所有结果(da.block如果它更灵活的话)
如果我不能,我认为这不会太有害,但如果可以的话会很酷。
示例代码
from dask import delayed
from dask import array as da
import numpy as np
n_shape = (3, 3)
shape = delayed(n_shape, nout=2)
d_shape = (delayed(n_shape[0]), delayed(n_shape[1]))
n = delayed(np.zeros)(n_shape, dtype=np.float)
# this doesn't work
# da.from_delayed(n, shape=shape, dtype=np.float)
# this doesn't work either, but I think goes a little deeper
# into the function call
da.from_delayed(n, shape=d_shape, dtype=np.float)
Run Code Online (Sandbox Code Playgroud) dask ×1