简体   繁体   中英

Numpy array dimension

In [21]: a = np.array([1,2,3])

In [22]: a.shape
Out[22]: (3,)

What's the difference between (3,) and (3,1) in shape?

Why isn't the output (,3) or (1,3) ? This is a 1 by 3 matrix, right?

No. A 1x3 matrix would be a two-dimensional array (eg, np.array([[1, 2, 3]]) ). What you have is a one-dimensional array of length three. In mathematical terms, a 1D array roughly corresponds to a vector.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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