Skip to content
All tutors

NumPy Arrays from the Ground Up

Think in arrays: shapes, axes, broadcasting and vectorised maths, with embeddings as the running example.

By Skill Lab Beginner Python for AI New

Your first 3 replies from the tutor are free. Then you can continue the lesson for $4 from your credit.

A taste of a lesson

One question and the answer, as this tutor gives it.

NumPy Arrays from the Ground Up AI tutor following Skill Lab's plan
Student:

I have embeddings with shape (1000, 384). How do I normalise each row?

Tutor:

Compute each row's length, then divide. norms = np.linalg.norm(E, axis=1, keepdims=True) gives shape (1000, 1): one length per row, kept as a column. Then E_norm = E / norms broadcasts that column across all 384 values in each row. Without keepdims you would get shape (1000,), and the division would fail because shapes are compared from the right. As a check, np.linalg.norm(E_norm, axis=1) should be all ones. What shape do you expect that check to return?

Written with AI under Skill Lab's direction as an example. In your lesson the tutor answers your own questions, and like any AI it can be wrong. Right now the AI model is not connected: replies come from a built in test engine on this site.

What you will be able to do

  • Create arrays and explain their shape, dtype and axes
  • Select data with slices, boolean masks and integer indexing
  • Predict when broadcasting works and what shape it produces
  • Replace Python loops with vectorised operations
  • Compute cosine similarities between embedding vectors

Lesson plan

6 lessons. Pick one to start there.

  1. 1 Arrays, shapes and dtypes Create arrays and read their shape, number of dimensions and dtype. Start
  2. 2 Indexing, slicing and masks Select rows, columns and values that meet a condition. Start
  3. 3 Axes and aggregations Use sum, mean, max and argmax along the right axis. Start
  4. 4 Broadcasting Combine arrays of different shapes and predict the result shape. Start
  5. 5 Vectorised thinking Rewrite loops as whole array operations and see the speed difference. Start
  6. 6 Embeddings and similarity Normalise embedding rows and rank items by cosine similarity to a query. Start

Try asking

Tap a question to start a lesson with it.

About this tutor

For beginners who can write Python loops and now meet NumPy in every AI tutorial. You learn what an array is, how shape, dtype and axis work, how indexing and boolean masks select data, how broadcasting combines arrays of different shapes, and why vectorised code is faster and clearer than loops. The running example is a small matrix of embeddings: you normalise rows, compute similarities with a dot product and find the closest items. Along the way you learn the traps: views versus copies, integer overflow and NaN values that spread through results.

Reviews

Students can review a tutor after a paid lesson. Nobody has yet.