18. Broadcasting in Python

2023. 9. 8. 23:03Google ML Bootcamp/1. Neural Networks and Deep Learning

python matrix operation.

 

더하기,빼기,곱하기, 나누기(+ - * / ) : element-wise.

**중요 곱하기조차 행렬곱이 아닌 element-wise로 진행됨, np.dot(a,b)의 경우 행렬곱으로 진행**

- but (3,4) shape matrix + (1,4) shape matrix = (3,4) shape matrix

- 이때는 (1,4)를 행방향으로 복사하여 (3,4) matrix로 만든 후 element-wise 연산을 수행한다고 생각.

- (3,4) shape matrix + (3,1) shape matrix = (3,4) shape matrix

- 이때는 (3,1)를 열방향으로 복사하여 (3,4) matrix로 만든 후 element-wise 연산을 수행한다고 생각.

 

행과 열 중 하나는 1이여아 작동하는 브로드캐스팅의 원리.