TF

    [Math] Cartesian Product (or Descartes Product, Product Set)

    Cartesian Product (or Descartes Product) 공집합(empty set, null set)이 아닌 여러 sets를 이용하여 새로운 set을 만드는 연산. Cartesian product는 operand인 여러 집합들의 각 elements를 원소(component, element)로 하는 tuple을 element(원소)로 하는 set을 반환함. 2개의 집합 $A$, $B$의 Cartesian product $A\times B$는 다음과 같음. $$A\times B= \{ (a,b) | a \in A, b\in B\}$$ $n$ 개의 집합 $A_1, A_2, \dots, A_n$의 Cartesian Product는 다음과 같이 정의됨. $$\displaystyle \prod^n_..

    [NumPy] Broadcasting

    ndarray와 scalar를 연산시킬때, scalar를 상대 ndarray와 같은 shape이면서 해당 scalar의 값을 가진 ndarray로 변경시키고나서 이 scalar로부터 만들어진 ndarray와 상대 ndarray를 동작시키는 방식으로 elementwise연산이 수행되는 기능. 주의할 것은 scalar 를 확장시키는 것이 기본이라는 점임. PyTorch나 TensorFlow의 텐서도 같은 방식으로 broadcasting이 수행된다. 이를 정리하면 다음과 같은 Rule에 따른다고 생각할 수 있음. Rules of Broadcasting Rule 1 두 ndarray의 차원의 수(number of dimensions)가 같지 않을 경우, 적은 ndarray의 shape가 leading side쪽..