Matrix vector addition

$\begingroup$

Given A a 3x3 matrix and B a 3x1 matrix (or column vector), I am asked to calculate A + B. Both are initially filled with one's. To my knowledge the two matrices would have to be of the same n×m dimensionions. However, if I do the addition in Python (using Numpy matrices and the '+' operator) I get a 3x3 matrix filled with two's.

How is this matrix and column vector added? Might I be misunderstanding what Python does?

$\endgroup$

2 Answers

$\begingroup$

This is a case of less conventional notation used in deep learning: We allow the addition of a matrix and a vector, yielding another matrix: $C = A+b$, where $C_{i,j}$ is $A_{i,j} + b_j$. See: (page 32)

$\endgroup$ 0 $\begingroup$

Usually, the addition of matrix and vector is not defined. So if you were asked to calculate such thing, you have to make it clear what he/she means.

I think this is what you get (in this example, $M + v$). If you try another combination (like $M + u$ in the example), you'll see what happens. Let $M = (m_1, m_2, m_3)^T$. Then it returns $$ M + v := (m_1 + v, m_2 + v, m_3 + v)^T $$ somehow. So it's a problem of Numpy and I think Stack Overflow is more appropriate place to ask if you want to know why this happens.

$\endgroup$ 1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like