import numpy as np

class Neural:
    def __init__(self,input_size,hidden_size,output_size,weight_init_std=0.01):
        self.params={}
        self.params['W1'] = weight_init_std * np.random.randn(input_size , hidden_size)
        self.params['b1'] = np.zeros(hidden_size)
        self.params['W2'] = weight_init_std * np.random.randn(hidden_size,output_size)
        self.params['b2'] = np.zeros(output_size)

        

@@ -12,16 +12,45 @@
 y as np%0D
+%0Afrom . import function as f%0D
 %0A%0D%0Aclass
@@ -240,11 +240,9 @@
 size
- , 
+,
 hidd
@@ -447,14 +447,1093 @@
 %0D%0A%0D%0A    
-    
+def predict(self,x):%0D%0A        W1,W2 = self.params%5B'W1'%5D,self.params%5B'W2'%5D%0D%0A        b1,b2 = self.params%5B'b1'%5D,self.params%5B'b2'%5D%0D%0A%0D%0A        a1 = np.dot(x,W1) + b1%0D%0A        z1 = f.sigmoid(a1)%0D%0A        a2 = np.dot(z1,W2) + b2%0D%0A        y = f.softmax(a2)%0D%0A%0D%0A        return y%0D%0A%0D%0A    def gradient(self,x,t):%0D%0A        W1,W2 = self.params%5B'W1'%5D,self.params%5B'W2'%5D%0D%0A        b1,b2 = self.params%5B'b1'%5D,self.params%5B'b2'%5D%0D%0A        grads = %7B%7D%0D%0A%0D%0A        batch_num = x.shape%5B0%5D%0D%0A%0D%0A        a1 = np.dot(x,W1) + b1%0D%0A        z1 = f.sigmoid(a1)%0D%0A        a2 = np.dot(z1,W2) + b2%0D%0A        y = f.softmax(a2)%0D%0A%0D%0A        dy = (y - t) / batch_num%0D%0A        grads%5B'W2'%5D = np.dot(z1.T,dy)%0D%0A        grads%5B'b2'%5D = np.sum(dy,axis=0)%0D%0A%0D%0A        da1 = np.dot(dy,W2.T)%0D%0A        dz1 = f.sigmoid_grad(a1) * da1%0D%0A        grads%5B'W1'%5D = np.dot(x.T,dz1)%0D%0A        grads%5B'b1'%5D = np.sum(dz1,axis=0)%0D%0A%0D%0A        return grads%0D%0A%0D%0A    def accuracy(self,x,t):%0D%0A        y = self.predict(x)%0D%0A        y = np.argmax(y,axis=1)%0D%0A        t = np.argmax(t,axis=1)%0D%0A%0D%0A        accuracy = np.sum(y == t) / float(x.shape%5B0%5D)%0D%0A        return accuracy
 %0D%0A

fix neural.py