攝影或3C

Python: 如何做矩陣乘法? numpy.matmul (ary1, ary2) 或 ary1 @ ary2 或 numpy.dot (ary1, ary2)

numpy.matmul (ary1, ary2):
import numpy as np
list1 = [1,2,3]
list2 = [
      [3],
      [2],
      [1]]
a1 = np.array(list1)
a2 = np.array(list2)
print(“對list做矩陣乘法np.matmul():”,
    np.matmul(list1,list2))
print(“對array做矩陣乘法np.matmul():”,
    np.matmul(a1,a2))
print(“只有array能用@做矩陣乘法:”,a1 @ a2)
print(“矩陣乘法@:”,list1 @ list2)

 

numpy.dot()

推薦hahow線上學習python: https://igrape.net/30afN

儲蓄保險王

儲蓄險是板主最喜愛的儲蓄工具,最喜愛的投資理財工具則是ETF,最喜愛的省錢工具則是信用卡