Exercises
These exercises check whether you can read matrix entries, predict shapes, compute small products, and explain what the operations mean.
Try each prompt before opening the hint or solution.
Fluency
If
what is ?
Compute it first, then check your number.
HintRow first
Go to row 3, then column 2.
SolutionEntry lookup
Row 3 is [3, 6]. The second entry is 6. Matrix entry notation reads
row first, then column.
In the same matrix, what is the first entry of column 2?
Compute it first, then check your number.
HintColumn direction
Column 2 is vertical.
SolutionColumn 2
Column 2 is:
[4, 5, 6]
Its first entry is 4. Reading a column means moving vertically, from top
to bottom.
Shape Reasoning
If has shape 5 x 4 and has shape 4 x 2, what shape does
have?
Compute it first, then check your number.
HintKeep the outside dimensions
The middle 4 values match. The outside dimensions remain.
SolutionShape rule
The middle dimensions match, so the product is defined. The output keeps the outside dimensions: rows from the first matrix and columns from the second.
Enter 1 if (5 x 4)(3 x 2) is a valid matrix product, or 0 if it is not.
Compute it first, then check your number.
HintCheck the middle
Compare the second number of the first shape with the first number of the second shape.
SolutionInvalid product
Enter 0. In:
(5 x 4)(3 x 2)
^ ^
the middle dimensions are 4 and 3, so the product is not defined.
Computation
If
and , what is the first entry of ?
Compute it first, then check your number.
HintUse the first row
Compute .
SolutionFirst row
The first output entry uses the first row of the matrix against the whole input vector.
Let
and
What is the top-left entry of ?
Compute it first, then check your number.
HintRow-column dot product
Compute .
SolutionTop-left entry
Top-left means row 1 of with column 1 of . One entry of the
product is one row-column dot product.
Patterns
If has shape 2 x 7, what shape does have?
Compute it first, then check your number.
HintSwap the numbers
The transpose swaps rows and columns.
SolutionTranspose shape
A 2 x 7 matrix has 2 rows and 7 columns. Its transpose has 7 rows
and 2 columns.
If a diagonal matrix has diagonal entries 2 and 5, what is the second
entry of ?
Compute it first, then check your number.
HintSecond coordinate
Multiply the second coordinate 4 by the second diagonal entry 5.
SolutionDiagonal scaling
A diagonal matrix with entries 2 and 5 scales:
The second entry is 20. The diagonal entries act as separate scale
factors, so the second diagonal entry only scales the second coordinate.
Interpretation
If has length 10 and has shape 4 x 10, what is the length of
?
Compute it first, then check your number.
HintUse the rows
The output length is the number of rows of .
SolutionLayer output
The input length 10 matches the columns of . The output length is the
number of rows: 4.
Enter 1 if this sentence is correct:
Each output entry of Ax
is the dot product of one row
of A with x.
Compute it first, then check your number.
HintUse dot product language
Each row of the matrix interacts with the input vector.
SolutionRow rule
Enter 1. Each output entry is the dot product of one row of the matrix
with the input vector.
Let have shape 2 x 3 and have shape 3 x 5.
Enter 1 if is defined and has shape 2 x 5.
Compute it first, then check your number.
HintMiddle, then outside
Write (2 x 3)(3 x 5).
SolutionDefined product
The middle dimensions match, so the product is defined. The result has 2
rows from and 5 columns from .
A batch has shape 12 x 8: 12 examples and 8 features per example. A
weight matrix has shape 8 x 4.
How many output features does each example have in ?
Compute it first, then check your number.
HintKeep examples, change features
The batch size remains 12; the last dimension becomes the output-feature
count.
SolutionOutput feature count
There are still 12 examples. Each output row has 4 features, because the weight matrix maps 8 input features into 4 output features.
Use the solutions page if you want the same reasoning in one linear review.