Home>
I want to understand an array for dot product calculation using numpy in python
A = numpy.array (([1,2], [3,4], [5,6]]) twodimensional array
B = numpy.array ([[1,2]]) 2D array
C = numpy.array ([3,4]) 1D array
A.shape
>>>(3,2)
B.shape
>>>(1,2)
C.shape
>>>(2,)
Although A can be understood up to 3 rows and 2 columns and B can be understood up to 1 rows and 2 columns,
I don't know why C is 2 lines.
When examined, onedimensional arrays are numbers arranged side by side.
(1,) I thought it would be one line.

Answer # 1

Answer # 2
In the onedimensional case, it looks like (number of elements).
numpy.ndarray.shape
Related articles
 python  i want to calculate matrix calculation with numpy for statement with numpydot
 python 3x  i want to get a matrix with the values of a certain column removed for each row of the matrix with pytorch (speedu
 python  [xlwings] i want to copy the entire selection of a matrix containing values and paste it into the specified cell
 about python numpy calculation
 python  i want to plot the results of a complex matrix calculation
 python  about numpy genfromtxt
 python  i want to move an element of a numpy array by referring to another array
 python  why is numpy working without importing numpy?
 python  i want to take the nth to mth slices in a numpy array sometimes n is positive and sometimes it is negative
 python  position of matrix elements? ?? ??
 python  i want to make a 4 * 4 square matrix by combining matrices with 4 elements
 python 3x  pandas matrix summary table insert columns
 python  algorithm to extract numpy serial numbers
 [python] assigning a column vector to a matrix
 [python] i want to calculate an excel matrix with a for statement
 python 3x  how to remove 0 elements in numpy 2darray
 [python] i want to calculate a matrix with a strange law
 python  i want to speed up the calculation of for statements with numpy
 [python] i want to calculate a matrix for each area and reduce its size
 python  how to use subscripts to represent the values of another list in a list
Related questions
 python  how to use numpyinterp
 python  i want to create a binary mask by comparing two elements and setting the smaller one to 0
 python  i don't know how to put out the sum of the matrix
 python  i want to store a 3d array in an array using numpy
 python  about the error cannot reshape array of size
 i want to open visual studio code and run python
 how to convert the array type of the value extracted by the condition specification from the python array to the integer type?
 python asks for integers
 python  i want to create a new dataframe by repeating the work of extracting the average value of the dataframe
 evals_result error, xgboost when implementing lightgbm in python
In this regard, you need to understand concepts such as ndim, shape and axis. Please refer to the appropriate article.
What does NumPy's axis and dimension number (ndim) mean?DeepAge
Other miscellaneous things.
C in the question sentence is not called "2 lines". Usually called a onedimensional array with two elements
shape numbers do not correspond to rows or columns. In 2D, for convenience, axis 0 is sometimes referred to as row and 1 as column.
The 1D and 2D arrays are not related to the vector dimensions. Rather, it may be better to think of it as a tensor, but it is not so expensive because it is a data structure. If it's a mess, it's the number of subscripts.