開始使用免費開始

矩陣相乘(二)

來測試一下你在矩陣相乘方面的功力。

本練習屬於課程

使用 PySpark 打造推薦引擎

檢視課程

練習說明

  • 使用 .shape 屬性查看矩陣 CD 的維度,判斷這兩個矩陣是否可以相乘。
  • 如果可以相乘,使用 np.matmul() 來相乘;如果不行,將 C_times_D 設為 None

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Print the dimensions of C
print(____.____)

# Print the dimensions of D
print(____.____)

# Can C and D be multiplied together?
C_times_D = ____
編輯並執行程式碼