python 乘

来源:互联网 发布:windows vista下载 编辑:程序博客网 时间:2024/04/25 04:57

Array
import numpy as np

#3*4
A = np.array([[1, 2 ,3 ,4],[5,6,7,8],[9,10,11,12]])

# 2 * 6

B = A.reshape(2,6)
B =[[ 1 2 3 4 5 6]
[ 7 8 9 10 11 12]]

# 6 * 2
C = A.reshape(6,-1)
C = [[ 1 2]
[ 3 4]
[ 5 6]
[ 7 8]
[ 9 10]
[11 12]]

1.np.dot()
正常的矩阵相乘(不论是一维还是多维)
这里写图片描述

2. * / np.multiply()
数组的shape 必须相同对应位置的元素相乘
这里写图片描述

Martrix
1.不论是 np.dot或者 都是正常的矩阵相乘*
这里写图片描述
2.np.multiply()
数组的shape 必须相同对应位置的元素相乘
这里写图片描述