简体   繁体   English

减去两个不同维度的数组

[英]Subtracting two arrays of different dimensions

What does this difference mean? 这种区别是什么意思?

np.array([[1], [2]]) - np.array([[1, 2]])

It outputs 它输出

array([[ 0, -1],
       [ 1,  0]])

Whereas np.array([[1], [2]]) is an array of dimension (2,1) , np.array([[1, 2]]) is an array of dimension (1,2) . np.array([[1], [2]])是维度(2,1)的数组, np.array([[1, 2]])是维度(1,2)的数组。 According to the rules of broadcasting , the difference is a numpy array of size (2,2) . 根据广播规则,差异是大小为(2,2)的numpy数组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM