NumPy
NumPy is a Python library (a box of ready-made tools) for working with big lists of numbers very fast. An embedding, which is a list of numbers for the meaning of a sentence, is just a NumPy array. In this lesson you make arrays, do math on a million numbers at once, and compare two embeddings.
New words
- Array
- A row or grid of numbers that all have the same type.
- Shape
- The size of an array: how many rows and columns it has.
- Vectorised math
- Doing one operation on every item of an array at once, with no loop.
- Axis
- A direction in a table: axis 0 goes down, and axis 1 goes across.
- Broadcasting
- The rule NumPy uses to repeat a smaller array so it fits a bigger one.
- Dot product
- Multiply the matching items of two arrays, then add up the results.
- Cosine similarity
- A score from -1 to 1 that shows how alike two arrays are.
What you will learn
- Why do AI engineers use NumPy?
- How do you make arrays?
- What are shape and dtype?
- How do you pick items from an array?
- What is vectorised math?
- What are aggregates and axes?
- What is broadcasting?
- What are dot product and cosine similarity?
- Try it: a grid of numbers
- Common mistakes
- Explain it to a friend
- Key takeaways
10 quiz questions at the end.
The full lesson, with interactive demos and the quiz, opens after you sign in with Google. It is free.