The dot product measures how much two vectors point in the same direction — and in neural networks, it is the operation that decides which side of a boundary a data point falls on.
Definition
For two vectors and , the dot product is:
This is also called the inner product or scalar product.
Geometric interpretation
The dot product has an equivalent geometric form:
where is the angle between the two vectors and denotes the Euclidean length (norm).
The sign of determines the sign of the dot product:
| Condition | Angle | Dot product |
|---|---|---|
| Vectors point in the same direction | Positive | |
| Vectors are perpendicular | Zero | |
| Vectors point in opposite directions | Negative |
Signed distance to a hyperplane
This is where the dot product becomes central to classification. Consider a hyperplane passing through the origin, defined by a normal vector . For any point :
where is the signed perpendicular distance from to the hyperplane. Points on the same side as have ; points on the opposite side have ; points on the hyperplane have .
When (unit vector), the dot product equals the signed distance directly. In general, the dot product gives the distance scaled by .
Role in the perceptron
The perceptron computes . The dot product measures the signed distance from to the decision boundary . The sign function then maps this distance to a class label:
- Positive distance (same side as ) class
- Negative distance (opposite side) class
The bias shifts the hyperplane away from the origin, but the dot product still does the core geometric work.
Related
- perceptron — uses the dot product as its core computation
- decision boundary — the hyperplane whose signed distance the dot product measures
Active Recall
Why does the sign of tell you which side of the hyperplane (through the origin) a point is on?
. The sign depends on : if , the point is on the same side as (positive); if , it’s on the opposite side (negative); if , the point lies exactly on the hyperplane.
Given , what does the hyperplane look like, and what does compute for any point ?
The hyperplane is the vertical line (the -axis). The dot product , which is simply the horizontal coordinate — i.e., the signed distance from the point to the -axis.
When does the dot product equal the exact perpendicular distance (without any scaling factor)?
When the weight vector has unit length, . In that case, , so the dot product is the signed perpendicular distance directly.
How are the two formulas for the dot product — and — used differently in practice?
The algebraic form is how we compute the dot product (just multiply and add). The geometric form is how we interpret it (it tells us about angles and distances). Both give the same number; the algebraic form is for calculation, the geometric form is for understanding.