Exercises
These exercises check the shape habits from the chapter. Work them without a framework.
A vector has 9 entries. What is its shape size?
Compute it first, then check your number.
A matrix has 7 rows and 4 columns. Enter its shape as a vector.
Compute it first, then check your number.
An input batch has shape (32, 12). Rows are examples. What is the batch size?
Compute it first, then check your number.
An input batch has shape (32, 12). Columns are features. How many features does each example have?
Compute it first, then check your number.
Let X have shape (6, 5) and W have shape (5, 2). Enter the shape of XW.
Compute it first, then check your number.
Let X have shape (6, 5) and W have shape (4, 2). Enter 1 if XW is valid, or 0 if it is not.
Compute it first, then check your number.
A tensor has shape (3, 7, 16) and means (batch, positions, features). How many features does each position have?
Compute it first, then check your number.
Can shape (2, 6) be reshaped into (3, 4) without changing the number of entries? Enter 1 for yes or 0 for no.
Compute it first, then check your number.
X has shape (9, 5) and b has shape (5). What is the shape of X + b?
Compute it first, then check your number.
A layer maps 12 input features to 6 output features. What shape should W have in (input_features, output_features) order?
Compute it first, then check your number.