Library
Python for data work
The NumPy behind data and ML code, one move at a time, with a picture for each: shapes, axes, broadcasting, indexing and matrix products.
Practice questions
6NumPy arrays: shapes, axes and broadcasting
- 1.
sqis a(3, 3)array. What doessq - sq.max(axis=1)do? - 2.What shape does
np.ones((8, 1, 5)) + np.ones((3, 1))produce? - 3.
qis(2, 4, 8, 16)andkis(2, 4, 10, 16): stacks of grids with 16 numbers in each row. Which line dots every row ofqwith every row ofk, grid by grid? - 4.
x = np.arange(6).reshape(2, 3). What isx.reshape(3, 2)[0]? - 5.
pis(4, 3)class probabilities andyis(4,)labels. What isp[:, y].shape? - 6.You mask entries by setting their scores to 0 instead of -inf. What happens after the softmax?