Things that are easy to overlook when using numpy to construct vectors

#Refer to Wu Enda's deep learning section 2.16 ( http://www.ai-start.com/dl2017/html/lesson1-week2.html

   It can be seen that the shape (shape) of a is a (5,) structure, which is called a one-dimensional array in Python . It should be noted that it is neither a row vector nor a column vector, and its transpose and As itself, if you calculate the dot product of a and its transpose, you get a number instead of a matrix. In order to avoid confusion with matrices or vectors, this form should be used sparingly, and the following form should be used instead:

 When (5,1) is used, a vector with 5 rows and 1 column is generated. At this time, the operation on a is consistent with the operation on the matrix. Pay attention to a subtle difference. In this data structure, when we output the transpose, there are two square brackets, and there is only one square bracket before, so this is the difference between a matrix with 1 row and 5 columns and a one-dimensional array.

Guess you like

Origin blog.csdn.net/weixin_42149550/article/details/99707545