Re:문제80. (오늘의 마지막 문제) 책 175 페이지 아래에 있는 Affine 클래스를 생성하고 입력 전파를 흘려 보내시오 ~
작성자11기_박민호작성시간20.08.07조회수13 목록 댓글 0import numpy as np
class Affine:
def __init__(self,W,b):
self.W = W
self.b = b
self.x = None
self.dW = None
self.db = None
def forward(self,x):
self.x = x
out = np.dot(x,self.W) + self.b
return out
def backward(self,dout):
dx = np.dot(dout,self.W.T)
self.dW = np.dot(self.x.T,dout)
self.db = np.sum(dout,axis=0)
return dx
x = np.array([[1,2],[3,4]])
W = np.array([[1,3,5],[2,4,6]])
b = np.array([[1,1,1]])
aff = Affine(W,b)
inp = aff.forward(x)
print(inp)
다음검색