Google ML Bootcamp/1. Neural Networks and Deep Learning(40)
-
16. Vectorizing Logistic Regression 2023.09.08
-
15. More Vectorization Examples
dw를 벡터화할 경우, dw+=x*dz가 되는데, 이는 x가 J에 미치는 영향(기울기)의 평균을 구하는 과정이므로. dw = dw + x(i)dz(i)이면 결국 누적합 + i시점 기울기 이때 벡터끼리 덧셈은 element-wise형태로 이루어지므로 for 문을 없앨 수 있다.
2023.09.08 -
14. Vectorization
벡터화 : 코드에서 for문을 명시적으로 제거하는 기술. import time import numpy as np a = np.random.rand(1000000) b = np.random.rand(1000000) tic = time.time() c = np.dot(a,b) toc = time.time() print(c) print('vectorized version:'+str(1000*(toc-tic))+'ms') c = 0 tic = time.time() for i in range(1000000): c += a[i]*b[i] toc = time.time() print(c) print('For loop :'+str(1000*(toc-tic)) +'ms') 확인해보면 대략 300배 차이나는 것을 확인할 수..
2023.09.08 -
13. Gradient Descent on m Examples
이전에는 단일 훈련 예제에 대하여 L을 최소화 하기 위한 w1,w2,b를 update 하는 과정을 살펴봤다. 이번에는 여러 훈련 예제에 대하여 J를 최소화 하기 위한 과정을 살펴보자. L : Loss function J : Cost function 전체 훈련 세트 : m examples에 대해 loop 반복 dw1,dw2,db는 결국 각 훈련 세트에서 구한 기울기들의 평균으로 구해짐. J는 L의 평균으로 구해짐. 아직 w1,w2,db는 update 안함. 전체 훈련 세트에 대해 dw1,dw2,db를 통한 w1,w2,b를 update 이를 Epoch수 만큼 반복.(이때 W는 update 되었으므로 다시 기울기 하강 수행) 딥러닝 알고리즘 구현 중 for문이 등장하는 것은 바람직하지 않음. 효율성이 매우 떨..
2023.09.08 -
12. Logistic Regression Gradient Descent
목적 : L 을 줄이기 위해 w, b를 조정하는 것. 즉 w1, w2, b가 L에 얼마나 영향을 미치는지 도함수(기울기) 구하기가 핵심. 목표는 Loss를 줄이는 방향으로 w1,w2,b를 조정하는 것. 1. dw1, dw2, db를 구하기.(역전파, 연쇄법칙을 통해) 2. w1
2023.09.08 -
11. Derivatives with a Computation Graph
chain rule(연쇄 법칙)을 설명하기에 가장 직관적인 예시. a변화가 v를 지나 J에 미치는 영향을 도함수(기울기)로 계산하는 과정.(=역전파) 코드상에서 dvar : J와 같이 관심있는 최종 출력 변수의 도함수를 나타냄. da : 3, db : 6, dc : 9 (직접 역전파를 통해 a,b,c가 J에 미치는 영향, 즉 기울기를 구해보기)
2023.09.08