Vectors
Treat a vector as an ordered list, compute a weighted score with a dot product in Python, add and scale vectors, and see what a Euclidean norm measures.
Suppose a tiny model describes a study session with two numbers: hours spent reading and exercises attempted. One session might be [2, 3]. The order matters: [3, 2] describes a different session.
This ordered collection is a vector. We'll call it x. In this example x₁ = 2 and x₂ = 3; the subscripts select entries. These are chosen teaching numbers, not a claim about how learning should be scored.
Give the entries different weights
Choose a second vector w = [4, 1]. Multiply corresponding entries and add the products:
$$w \cdot x = 4\times2 + 1\times3 = 11$$
The dot symbol names the dot product. Each weight says how strongly its input contributes to this particular score.
Predict: Keep w fixed. Which change adds more to the score: one more reading hour, or one more attempted exercise?
We can calculate the score without a special library:
Both lists have two entries here. In general, check equal lengths: Python's zip stops at the shorter list, which could silently leave out an input.
Change the whole vector
Adding [1, 2] to x means adding corresponding entries: [2 + 1, 3 + 2] = [3, 5]. Multiplying x by the scalar 2 scales every entry, producing [4, 6]. A scalar is a single number.
Now double x but keep w fixed. Predict the new score before expanding the dot product.
If you draw [2, 3] as an arrow from (0, 0) to (2, 3), its ordinary Euclidean length is √(2² + 3²) = √13. This is its norm, written ‖x‖. In our study-session data, however, hours and counts have different units. A geometric length is a calculation we chose, not automatically a meaningful measure of effort.
Optional visual: In Desmos, enter (2t,3t). Keep the displayed t range from 0 to 1. Then enter (4t,6t) with the same range. Both segments follow the same direction; one is twice as long.
For the conventional notation you will see in papers, read the vector examples in Deep Learning, §2.1. Notice that vectors are often printed as columns. The entries and their order remain the same.
- A vector is an ordered collection of numbers. Entry order matters.
- Add vectors entry by entry; multiply by a scalar by scaling every entry.
- A dot product multiplies matching entries and adds: [4, 1] · [2, 3] = 11.
- The Euclidean norm of [2, 3] is √13. Its usefulness depends on what the entries and units represent.
- Check equal lengths before using Python's zip for a dot product; zip stops at the shorter input.