
06 · Contraction with einsum
Part IV, Block 3 of Tensors for Machine Learning. One rule that looks compact in code and has a very simple meaning:
If an index disappears after
->, NumPy sums over it. If the index remains, it survives in the output.
Recommendation and search systems rank items by the dot product between a user vector and every item vector — one user against millions of items, many times per second. That contraction is the ranking signal. Sum over the wrong axis and every user gets wrong results.
Study here, then run the real thing: notebook 06 on Colab · the handbook · Kahoot 2
Built from the workshop’s own material by Ravi Kalia and Sebastian Laverde Chunza, CC BY 4.0.
Your path through this unit
Step 1 of 3
Initial review
Take a first look at each topic and tick Got it once you have the general idea.