import numpy as np import random class Network(): def __init__(self, sizes): """ :param sizes: each element in sizes represents the number of neurons in each layer. e.g. [2,3,1] represents a 2*3*1 network :return: nothing """ self.num_layers = len(sizes) self.sizes = sizes self.biases = [np.random.randn(y, 1) for y in sizes[1:]] self.weights = [np.random.randn(y, x) for x, y in zip(sizes[:-1], sizes[1:])] def feedforward(self, a): """Return the output of the network if "a" is input.""" for b, w in zip(self.biases, self.weights): a = sigmoid_vec(np.dot(w, a)+b) return a def update_all_weights_and_bias_using_one_mini_batch(self, mini_batch, eta):