Matrix-vector products
A matrix–vector product dots every matrix row with the input vector, producing one output entry per row.
On this page 7 sections
01Several row scores#
A matrix-vector product evaluates several dot products with the same input. Each row contains one set of weights. Its result becomes one entry of the output vector, in row order.
Let have rows and , with input . The first row asks for . The second asks for .
There are two output values because there are two rows. Both rows use the entire input. Assigning the first input entry to the first row and the second entry to the second row would omit terms from both dot products.
A has rows and . Input is . Compute .
Show answer and explanation
Row 1 gives ; row 2 gives .
02Dimensions describe the operation#
An matrix has rows, each with weights. Its input needs entries so every weight has a partner. It returns entries, one per row.
A matrix has 4 rows and 2 columns. The input has 2 entries. How many output entries?
Show answer and explanation
One dot product per row gives four entries.
For rows , , and with input , the outputs are , , and . The last row compares the input coordinates. A rectangular matrix can produce more or fewer coordinates than it receives.
03Rows can describe observations#
A data matrix can put one observation in each row. If the rows are , , and and shared weights are , the three scores are , , and .
This uses exactly the same row rule. The matrix's interpretation tells you whether outputs label observations or different scoring rules; the dimensions alone do not assign those meanings.
Input . P weights ; Q weights . Dot each with the input. Return (P, Q).
Show answer and explanation
P is ; Q is .
Changing just one row changes only its output score. Changing an input coordinate can affect every row whose corresponding weight is nonzero. These are direct consequences of evaluating each row separately.
Dot each row with the whole input. Keep the results in row order.
- Compute a matrix-vector product from row dot products.
Sources & further reading
- [1]Margalit and Rabinoff: Interactive Linear Algebra, 2.3 Matrix Equations ↗textbooks.math.gatech.edu · Article
- [2]Goodfellow, Bengio and Courville: Deep Learning, 2.1–2.2 ↗www.deeplearningbook.org · Article
- [3]Boyd and Vandenberghe, Introduction to Applied Linear Algebra ↗stanford.edu · Article