Block to block operations between 2 dask arrays

Viewed 41

Good day friends, I have a question about map_blocks(). I'm trying something simple, I want to take the dot product between columns (the blocks) of 2 arrays like so:

    x=da.random.random((100,5), chunks=(100,1))
    y=da.random.random((100,5), chunks=(100,1))
    
    def block_dot_product(a, b):
        out=np.dot(a,b)
        return out
    
    result=da.map_blocks(block_dot_product, x, y,dtype=np.float64).compute()

If this works as expected it should return a single float for the dot product of each block. So, output should be a single 1x5 array.

I'm clearly missing something because this raises the exception ValueError: shapes (100,1) and (100,1) not aligned: 1 (dim 1) != 100 (dim 0)

Any pointers as to what I'm not understanding???

1 Answers
Related