In [1]:
import numpy as np

In [22]:
class Network:
    def __init__(self, num_neurons, output_weights=None):
        self.num_neurons = num_neurons
        self.bias = [np.random.rand(y,1) for y in num_neurons[1:]]
        self.weights = [np.random.rand(y,x) for x,y in zip(num_neurons[:-1], num_neurons[1:])]
    def propForward(self, inputs):
        for b, w in zip(self.bias, self.weights):
            print(inputs)
            inputs=1./(1.+np.exp(-w.dot(inputs)-b))
            print(inputs)
    def training(self, inputs, eta):
        nabla_b = [np.zeros(b.shape) for b in self.bias]
        nabla_w = [np.zeros(w.shape) for w in self.weights]
        
        delta_nabla_b, delta_nabla_w = #Back Propagation
        
        nabla_b = [nb+dnb for nb, dnb in zip(nabla_b, delta_nabla_b)]
        nabla_w = [nw+dnw for nw, dnw in zip(nabla_w, delta_nabla_w)]
        
        self.weights = [w-(eta)*nw for w, nw in zip(self.weights, nabla_w)]
        self.bias = [b-(eta)*nb for b, nb in zip(self.bias, nabla_b)]
    def backProp(self, inputs,answer):
        nabla_b = [np.zeros(b.shape) for b in self.bias]
        nabla_w = [np.zeros(w.shape) for w in self.weights]

In [25]:
n1 = Network([2,4, 10])
n1.propForward([1,0])


[1, 0]
[[ 0.76904192  0.83533665  0.72305925  0.72981125]
 [ 0.76189571  0.82978769  0.71501749  0.72189015]
 [ 0.79815842  0.85764256  0.75613447  0.76234512]
 [ 0.68926645  0.7716611   0.63494038  0.64277938]]
[[ 0.76904192  0.83533665  0.72305925  0.72981125]
 [ 0.76189571  0.82978769  0.71501749  0.72189015]
 [ 0.79815842  0.85764256  0.75613447  0.76234512]
 [ 0.68926645  0.7716611   0.63494038  0.64277938]]
[[ 0.90464751  0.91477341  0.89699352  0.89815126]
 [ 0.92395113  0.93350586  0.91661707  0.91773223]
 [ 0.85035379  0.86222956  0.84184867  0.84311113]
 [ 0.93945282  0.94881927  0.93207337  0.93320537]
 [ 0.93926454  0.94803486  0.93240931  0.93345816]
 [ 0.74338331  0.75892489  0.73252333  0.73412163]
 [ 0.80028809  0.82000571  0.78604299  0.78816289]
 [ 0.85172071  0.86828695  0.83947765  0.84131412]
 [ 0.69918257  0.71165091  0.69049565  0.69177333]
 [ 0.88104753  0.89836111  0.86787094  0.86986677]]

In [ ]: