42-AI / bootcamp_machine-learning

Bootcamp to learn basics in Machine Learning
Other
203 stars 41 forks source link

ML00 ex00: return type of Matrix * Vector #230

Open mli42 opened 1 year ago

mli42 commented 1 year ago

There is a commentary for the __mul__ method that says returns a Vector if we perform Matrix * Vector multiplication

IMG_20220810_120113

But in the examples, there is the choice between Matrix and Vector:

m1 * v1
# Output:
Matrix([[8], [16]])
# Or: Vector([[8], [16]

(Also the last line has ]) missing)

But there is an exception, if we multiply a Matrix of shape (3, 1) with a Vector of shape (1, 2), we should obtain a Matrix of shape (3, 2) and not a Vector. We might want a row vector or a colomn vector when possible, but definitly not every time.

Fixed on: