3/26
Part 1 of 4 · Shapes and axesLearn
More axes: a stack of tables
Now take two classes, each with two students and the same three tests.
# class 0: Ana
classes = np.array([[[70, 80, 90],
# Ben
[50, 100, 60]],
# class 1: Dee
[[85, 75, 95],
# Eli
[60, 70, 80]]])
print(classes.shape)
(2, 2, 3)
That's two tables, one per class.
classes[0] (2, 3)test 1test 2test 3Ana708090Ben5010060
classes[1] (2, 3)test 1test 2test 3Dee857595Eli607080
shape(2classes,2students,3tests)
Read a shape from the right. The last number is the columns: 3 tests. The one before it is the rows: 2 students. Anything in front of those two only counts tables: 2 classes.
That's the whole trick for big arrays. A batch of 32 images, each 28 by 28 pixels, is (32, 28, 28): 32 tables of 28 rows and 28 columns.