Vector Outer Product는 Cross Product와 다르다.
- Vector Outer Product: In linear algebra, the outer product of two coordinate vectors is the matrix whose entries are all products of an element in the first vector with an element in the second vector
- Vector Cross Product: Given two linearly independent vectors a and b, the cross product, a × b (read "a cross b"), is a vector that is perpendicular to both a and b. (두 벡터에 직교하는 벡터를 구하는 외적)
Vector Outer Product 수식은 다음과 같다.
$$a \otimes b = ab^{\textbf{T}}=\begin{bmatrix}
a_{1} \\
a_{2} \\
\vdots \\
a_{n}
\end{bmatrix}\begin{bmatrix}
b_{1} & b_{2} & \cdots & b_{n}
\end{bmatrix} = \begin{bmatrix}
a_{1}b_{1} & a_{1}b_{1} & \cdots & a_{1}b_{1} \\
a_{1}b_{1} & a_{1}b_{1} & \cdots & a_{1}b_{1}\\
\vdots & \vdots & \ddots & \vdots \\
a_{1}b_{1} & a_{1}b_{1} & \cdots & a_{1}b_{1}
\end{bmatrix}$$
numpy로 계산해보자.
import numpy as np
x = np.array(['a', 'b', 'c'], dtype=object)
np.outer(x, [1, 2, 3])
>>>>
array([['a', 'aa', 'aaa'],
['b', 'bb', 'bbb'],
['c', 'cc', 'ccc']], dtype=object)
np.outer([1, 2, 3], x)
>>>>
array([['a', 'b', 'c'],
['aa', 'bb', 'cc'],
['aaa', 'bbb', 'ccc']], dtype=object)
728x90
'논문 및 개념 정리' 카테고리의 다른 글
[2021] ROFORMER: ENHANCED TRANSFORMER WITH ROTARYPOSITION EMBEDDING(RoPE) (0) | 2024.06.26 |
---|---|
[transformers] Scaled Dot Product Attention (0) | 2024.06.26 |
[2023] The Wisdom of Hindsight Makes Language Models Better Instruction Followers (1) | 2023.12.01 |
Hold-out vs Cross-validation 차이 (0) | 2023.07.16 |
Propensity Score (0) | 2023.06.28 |