human
5.6 Affine / Softmax 계층 구현하기

행렬의 내적은 기하학에서는 Affine Transformation이라고 합니다! -> 어파인 변환을 수행하는 처리를 Affine 계층이라고 구현합니다"
Please write code following the instructions in jupyter notebook style.
 ... Give me a code to 5?
assistant
#Here is code to 5.

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