How to calculate Matrix Multiplication?

37 Views Asked by At

I'm following a course that asks me the following question: Calculate the logits a and b for the following formula..

I don't understand how to do this, I would like to understand how to practically calculate this.

UPDATE:
I understand now:
a = -0.5*0.2 + 0.2*0.5 + 0.1*0.6 + 0.1
b = 0.7*0.2 + -0.8*0.5 + 0.2*0.6 + 0.2

enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

Say we want to multiply an $m \times n$ matrix $A$ and an $n \times k$ matrix $B$: $$\begin{pmatrix}a_{11} & \cdots & a_{1n} \\ \vdots & \ddots & \vdots \\ a_{m1}& \cdots & a_{mn}\end{pmatrix} \begin{pmatrix}b_{11} & \cdots & b_{1n} \\ \vdots & \ddots & \vdots \\ b_{n1}& \cdots & b_{nk} \end{pmatrix}.$$ The answer will be an $m \times k$ matrix $C$. The entry in the $i$th row and $j$th column of $C$ will be the dot product of the $i$th row of $A$ with the $j$th column of $B$, as in the reference you linked.

if $B$ is a column vector, i.e., $k=1$, then we have $$\begin{pmatrix}a_{11} & \cdots & a_{1n} \\ \vdots & \ddots & \vdots \\ a_{m1}& \cdots & a_{mn}\end{pmatrix} \begin{pmatrix}b_{1} \\ \vdots \\ b_{n} \end{pmatrix}.$$ The answer will be an $m \times 1$ matrix, i.e., another column vector. Its entry in the $i$th row and $1$st column (the only column) is the dot product of the $i$th row of $A$ with the $1$st column of $B$ (i.e., the vector $B$ itself): $$\begin{pmatrix}a_{11} & \cdots & a_{1n} \\ \vdots & \ddots & \vdots \\ a_{m1}& \cdots & a_{mn}\end{pmatrix} \begin{pmatrix}b_{1} \\ \vdots \\ b_{n} \end{pmatrix}=\begin{pmatrix}a_{11}b_1+a_{12}b_2+\cdots + a_{2n}b_n\\a_{21}b_1+a_{22}b_2+\cdots + a_{2n}b_n\\ \vdots \\ a_{m1}b_1+a_{m2}b_2+\cdots + a_{mn}b_n \end{pmatrix}.$$