Numpy: Subtract 2 numpy arrays row wise

前端 未结 4 1124
被撕碎了的回忆
被撕碎了的回忆 2021-01-14 05:51

I have 2 numpy arrays a and b as below:

a = np.random.randint(0,10,(3,2))
Out[124]: 
array([[0, 2],
       [6, 8],
       [0, 4]])
b = np.random.randint(0,10         


        
4条回答
  •  甜味超标
    2021-01-14 06:06

    I'm not sure what means a fully factorized solution, but may be this will help:

    np.append(a, a, axis=1).reshape(3, 2, 2) - b
    

提交回复
热议问题