Skip to content
Justice Tech School

Dot Product and Matrix Multiplication

Use @ or np.dot for matrix multiplication. The inner dimensions must match.

Example
import numpy as np
a = np.array([[1, 2], [3, 4]])
b = np.array([[5, 6], [7, 8]])
print(a @ b)
print(np.dot([1, 2, 3], [4, 5, 6]))

Result

[[19 22]
 [43 50]]
32

Exercise

Matrix product operator.

a  b

Quiz Test

Which operator multiplies matrices?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.