ml.lab
Python sleeps until you run code
02 Matrices are machines

Checkpoint

Matrices are machines

Twelve questions on matrices as maps, products, shapes and layers, with new numbers and a few classic traps. Work them without the lessons open. You need 80% to pass. The code question needs one line of numpy.

  1. Question 1 of 12.

    A linear map sends (1,0)(1,\allowbreak 0) to (3,−1)(3,\allowbreak -1) and (0,1)(0,\allowbreak 1) to (2,5)(2,\allowbreak 5). Which matrix represents it?

  2. Question 2 of 12.

    Compute Ax\mathbf{A}\mathbf{x} for A=[10−2311]\mathbf{A} = \begin{bmatrix} 1 & 0 & -2 \\ 3 & 1 & 1 \end{bmatrix} and x=(1,4,−1)\mathbf{x} = (1,\allowbreak 4,\allowbreak -1). Enter the result as a column, top to bottom.

    Ax

    One entry per box, top to bottom. 0.25, -2, 3/4 and sqrt(2) all work. Enter moves to the next empty box.

  3. Question 3 of 12.

    Which of these can be done by multiplying by a 2×22 \times 2 matrix? Select all that apply.

    Choose every option that applies.

  4. Question 4 of 12.

    Find the single matrix that first applies the shear [1201]\begin{bmatrix} 1 & 2 \\ 0 & 1 \end{bmatrix} and then stretches horizontally by 3 with [3001]\begin{bmatrix} 3 & 0 \\ 0 & 1 \end{bmatrix}. Enter the 2×22 \times 2 matrix row by row.

    One entry per box, row by row (Tab moves along a row). 0.25, -2, 3/4 and sqrt(2) all work. Enter moves to the next empty box.

  5. Question 5 of 12.

    Let A=[2−10134]\mathbf{A} = \begin{bmatrix} 2 & -1 & 0 \\ 1 & 3 & 4 \end{bmatrix} and B=[120−151]\mathbf{B} = \begin{bmatrix} 1 & 2 \\ 0 & -1 \\ 5 & 1 \end{bmatrix}. What is (AB)21(\mathbf{AB})_{21}, the entry in row 2 and column 1?

    Type a number: 0.25, -2, 3/4 and sqrt(2) all work.

  6. Question 6 of 12.

    In numpy, a has shape (8, 1) and b has shape (3,). What does a + b do?

  7. Question 7 of 12.

    An MLP maps 20 input features through two hidden layers of 50 units each to 5 outputs. Every layer is dense with a bias. How many parameters does it have? Enter a whole number.

    Type a number: 0.25, -2, 3/4 and sqrt(2) all work.

  8. Question 8 of 12.

    Which expression equals (ABC)⊤(\mathbf{ABC})^\top for matrices whose shapes fit?

  9. Question 9 of 12.

    A\mathbf{A} is 100×200100 \times 200, B\mathbf{B} is 200×300200 \times 300 and C\mathbf{C} is 300×10300 \times 10. You compute ABC\mathbf{ABC} with whichever grouping is cheaper. How many multiply-adds does it take? Enter a whole number.

    Type a number: 0.25, -2, 3/4 and sqrt(2) all work.

  10. Question 10 of 12.

    Two dense layers with no nonlinearity between them compute (XW1+b1)W2+b2(\mathbf{X}\mathbf{W}_1 + \mathbf{b}_1)\mathbf{W}_2 + \mathbf{b}_2 in the row-batch convention. Which single layer XW+b\mathbf{X}\mathbf{W} + \mathbf{b} gives the same outputs?

  11. Question 11 of 12.

    Write the matrix that rotates the plane a quarter turn clockwise. Enter the 2×22 \times 2 matrix row by row.

    One entry per box, row by row (Tab moves along a row). 0.25, -2, 3/4 and sqrt(2) all work. Enter moves to the next empty box.

  12. Question 12 of 12.

    Run the tests before you submit. This question counts as correct if your latest run passes every check.

    Code it

    A colleague stores a layer's weights in the math convention: W has shape (d_out, d_in), so one input column becomes Wx+b\mathbf{W}\mathbf{x} + \mathbf{b}. Your data is a batch X of shape (batch, d_in), one example per row. Write layer(X, W, b) so that it returns every example's output as a row, shape (batch, d_out), without a Python loop.

    ⌘+Enter runsPython sleeps until you run code
    Write your code where the starter says raise NotImplementedError, then press Run tests. Each check says what it expects.
0 of 12 answered. Unanswered questions count as wrong.