[머신러닝/딥러닝] numpy로 구현하는 Affine
Affine class Affine: #파라미터 정의 def __init__(self, w, b): #if Input x = 6, 5 self.params = [w, b] #w, b = 5, 5 self.grads = [np.zeros_like(w), np.zeros_like(b)] self.x = None #순전파 def forward(self, x): w, b = self.params out = np.matmul(x, w) + b #=> b는 broadcast (1, 5) -> (5 by 5) self.x = x return out #역전파 def backward(self, dout): w, b = self.params dx = np.matmul(dout, w.T) dw = np.matmul(self..
2024. 2. 16.