A. VECTORS:
- A vector is a mathematical object that represents a quantity with both magnitude and direction
-
Magnitude $\Vert v \Vert$ : a length or size of vector, given a vector $\vec{v}$ = [$v_{1}$, $v_{2}$,… , $v_{n}$], we have:
$\Vert v \Vert$ = $\sqrt {v_{1}^{2} + v_{2}^{2} … + v_{n}^{2}}$
-
Direction : The relative orientation of a vector in space.
- Dot Product (Inner Product = IP) : an operation that combines two vectors to yield a scalar.
- For 2 vectors $\vec{u}$ = [$u_{1}$, $u_{2}$,… , $u_{n}$] and $\vec{v}$ = [$v_{1}$, $v_{2}$,… , $v_{n}$]:
- The dot product is used to measure the angle between vectors, if dot product = 0, then 2 vectors are perpendicular and their angle is $90^{o}$ or $270^{o}$.
- In numpy, np.dot($\vec{u}$, $\vec{v}$)
-
Magnitude $\Vert v \Vert$ = $\sqrt{IP \ of \ itself}$ = $\sqrt{\vec{v} \cdot \vec{v}}$.
-
Extention 1 : If we consider two vectors as 1-D matrices, the inner product looks like matrix multiplication. However, when using np.dot() with matrices, the result is another matrix rather than a scalar.
- Extension 2 : IP can be used to calculate the angle $\alpha$ between 2 vectors:
- Extention 3 : Length $Pro^{u}_{v}$ of projection(Hình chiếu) of vector $\vec{u}$ on vector $\vec{v}$:
-
Softmax: a function used to transform a vector into another vector, which has the sum of all elements is 1, making it like a probability distribution. The formula for softmax for a vector $\vec{z}$ = [$z_{1}$, $z_{2}$,… , $z_{n}$]:
\[softmax(z_{i}) = \frac{e^{z_{i}}}{\sum_{j=1}^{n} {e^{z_{j}}}}\]- For example : z = [2, 1, 0.1]
Calculate $e^{z_{i}}$ : $e^{2}$ = 7.39, $e^{1}$ = 2.72, $e^{0.1}$ = 1.11
Sum: 7.39 + 2.72 + 1.11 = 11.22
softmax($z_{1}$) = 7.39/11.22 = 0.66
softmax($z_{2}$) = 7.39/11.22 = 0.24
softmax($z_{3}$) = 7.39/11.22 = 0.10After softmax(z) = [0.66, 0.24, 0.10], with the sum = 1.
- For example : z = [2, 1, 0.1]
B. VECTOR SPACE $\mathbb R^{n}$ :
- A vector space (also a linear space, ko gian tuyến tính) is a collection of objects called vectors.
-
$\mathbb{R^{n}}$ is a symbol of a vector space of n-dimentional vectors that must be linear independent. And $n$ is called space dimension.
-
FIVE typical features of Vector Addition:
- Closed (kín): $\vec{s}$ = $\vec{u}$ + $\vec{v}$
if 2 vectors $\vec{u}$ & $\vec{v}$ belongs to the vector space $\mathbb{R}$, their sum vector $\vec{s}$ must lie in the vector space $\mathbb{R}$. - Commutative (giao hoán): $\vec{u}$ + $\vec{v}$ = $\vec{v}$ + $\vec{u}$
- Associative (kết hợp): ($\vec{u}$ + $\vec{v}$) + $\vec{w}$ = $\vec{u}$ + ($\vec{v}$ + $\vec{w}$)
- Existence of Additive Identity vector $\vec{0}$ to have $\vec{u}$ + $\vec{0}$ = $\vec{u}$
- Existence of Additive Inverses vector $\vec{x}$ to have $\vec{u}$ + $\vec{x}$ = $\vec{0}$, so $\vec{x}$ = $\vec{-u}$
- Closed (kín): $\vec{s}$ = $\vec{u}$ + $\vec{v}$
-
FIVE typical features of Scalar Multiplication:
- Closed (kín): $\vec{s}$ = $c \cdot \vec{u}$
if vector $\vec{u}$ belongs to the vector space $\mathbb{R}$, the scaled vector $\vec{s}$ must also lie in the vector space $\mathbb{R}$. - Commutative with scalar (giao hoán với hệ số) : $\vec{u} \cdot c$ = $c \cdot \vec{u}$
- Associative with scalar (kết hợp với hệ số) : $a \cdot (b \cdot \vec{u})$ = $(b \cdot a) \cdot \vec{u}$
- Distributive over Vector Addition (phân phối với hệ số) : $c\cdot$($\vec{u}$ + $\vec{v}$) = $c \cdot \vec{u}$ + $c \cdot \vec{v}$
- Distributive over Scalar Addition (phân phối với vectơ) : $(a + b) \cdot \vec{u}$ = $a \cdot \vec{u}$ + $b \cdot \vec{u}$
- Closed (kín): $\vec{s}$ = $c \cdot \vec{u}$