본문 바로가기
AI Tech - Naver Boostcamp/1. Python & AI Math

1. What is vector?

by Pinocchio 2021. 8. 3.

1. What is Vector?

Created: August 3, 2021 10:56 AM
Reviewed: No

  1. Hadamard product (= elementwise product = 성분곱)

x=[x1,x2,...,xd]\bm x = [x_1, x_2, ... , x_d]

y=[y1,y2,...yd]\bm y = [y_1, y_2, ... y_d]

xy=[x1y1,x2y2,...xdyd]\bm x \odot \bm y = [ x_1y_1, x_2y_2, ... x_dy_d ]

In Numpy, elementwise product equals *****

  1. norm

norm is equal to the distance from the origin (0, 0).

1) L1normL_1-norm

L1norm=x1=i=1dxiL_1-norm = ||\bm x||_1 = \sum_{\substack{i=1}}^{d}|\bm x_i|

= sum(변화량의 절댓값)

ex. Robust Training, Lasso Regression

Regularization: This speeds up the dimensionality reduction and removes unimportant parts. Unlike L2L_2-norm, the influence of an unnecessary variable can be made 0.

x:x1=1{ \bm x : ||\bm x ||_1 = 1 }

2) L2normL_2-norm

L2norm=x2=i=1dxi2L_2-norm = ||\bm x||_2 = \sqrt {\sum_{\substack{i=1}}^{d} |\bm x_i|^2 }

= Euclidean distance ( 유클리드 거리 )

In Numpy, It is equal to numpy.linalg.norm

ex. Laplace approximation, Ridge Regression

Regularization: L2L_2-norm makes the influence of insignificant variables close to zero.

x:x2=1{ \bm x : ||\bm x ||_2 = 1 }

  1. The distance between vectors

The distance between vectors = The distance between two points of vectors

벡터 사이의 거리 = 두 점 사이의 거리

d=yx=xyd = || \bm y - \bm x || = || \bm x - \bm y ||

  1. The angle between two vectors

Calculating the angle is only possible with L2L_2-norm.
The dot product is the value adjusted to fit the length of the orthographic projection to y||\bm y||.
The dot product can be used to measure the similarity of two vectors.

각도를 계산하는 것은 L2L_2-norm에서만 가능하다.
내적은 정사영의 길이를 y||\bm y||에 맞게 조정한 값이다.
내적은 두 벡터의 similarity를 측정할 때 사용 가능하다.

cosθ=x22+y22xy222x2y2=2<x1,y1>2x2y2=<x1,y1>x2y2cos \theta = {|| \bm x ||_2^2 + || \bm y ||_2^2 - || \bm x - \bm y ||_2^2 \over 2|| \bm x ||_2|| \bm y ||_2} = { 2<\bm x_1, \bm y_1 > \over 2|| \bm x ||_2|| \bm y ||_2} = { <\bm x_1, \bm y_1 > \over || \bm x ||_2|| \bm y ||_2}

  • Dot product = inner product = 내적

<x1,y1>=i=1dxiyi <\bm x_1, \bm y_1>=\sum_{\substack{i=1}}^{d}\bm x_i\bm y_i

Numpy: np.inner

'AI Tech - Naver Boostcamp > 1. Python & AI Math' 카테고리의 다른 글

3. Gradient Descent (Basic)  (0) 2021.08.09
2. What is matrix?  (0) 2021.08.09

댓글