21/26
Part 4 of 4 · Multiply, reshape, and put it togetherLearn

On a stack, @ works table by table

classes holds two tables. @ multiplies only the last two axes. The axes in front just count tables, and each table is done on its own:

print(classes @ weights)
[[83. 70.]
 [87. 73.]]

Each table on its own is the same @ as before. Switch between the two classes:

classes @ weights, one table at a timeInteractive
classes[0](2, 3)@weights(3,)→(2,)the two 3s meet, get added up, and disappear
weightstest 1test 2test 3
test 1test 2test 3AnaBen
grade
Ben: 0.2×50 + 0.3×100 + 0.5×60 = 70. One row of classes[0] times one column of weights, number by number, added up.

Class 0 is Ana and Ben, 83 and 70. Class 1 is Dee and Eli, 87 and 73.