Home > Article > Backend Development > How to use numpy array and matrix multiplication
This time I will show you how to use numpyarray and matrix multiplication, what are the precautions when using numpy array and matrix multiplication, the following is a practical case, let's take a look one time.
1, When it is array, the default d*f is the product of the corresponding elements, multiply is also the product of the corresponding elements, dot (d, f) will be converted into the product of matrices. dot dot multiplication means addition, while multiply only multiplies the corresponding elements and does not add.
2, When it is mat, the default d*f is the product of the matrix, multiply is converted into the product of the corresponding elements, dot (d, f) is the product of the matrix
3. When mixing, generally do not mix.
When mixing, the default is matrix multiplication. , multiply is converted into the product of the corresponding elements, dot (d, f) is the product of the matrix
Summary: The default for array multiplication is dot multiplication, and the default for matrix It is matrix multiplication. When mixed together, the default is matrix multiplication. multiply is converted into the product of the corresponding elements, and dot (d, f) will be converted into the product of the matrix. Note that when multiply does not satisfy the corresponding element, it is performed in the broadcast manner.
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
How to solve the greatest common divisor in Python
How to merge numpy arrays in Python
The above is the detailed content of How to use numpy array and matrix multiplication. For more information, please follow other related articles on the PHP Chinese website!