def fit(self, training_data, validation_data=None):
    'Fit (train) the Neural Network on provided training data. Fitting is\n        carried out using Stochastic Gradient Descent Algorithm.\n\n        Parameters\n        ----------\n        training_data : list of tuple\n            A list of tuples of numpy arrays, ordered as (image, label).\n\n        validation_data : list of tuple, optional\n            Same as `training_data`, if provided, the network will display\n            validation accuracy after each epoch.\n\n        '
    for epoch in range(self.epochs):
        random.shuffle(training_data)
        mini_batches = [training_data[k:(k + self.mini_batch_size)] for k in range(0, len(training_data), self.mini_batch_size)]
        for mini_batch in mini_batches:
            nabla_b = [np.zeros(bias.shape) for bias in self.biases]
            nabla_w = [np.zeros(weight.shape) for weight in self.weights]
            for (x, y) in mini_batch:
                self._forward_prop(x)
                (delta_nabla_b, delta_nabla_w) = self._back_prop(x, y)
                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 - ((self.eta / self.mini_batch_size) * dw)) for (w, dw) in zip(self.weights, nabla_w)]
            self.biases = [(b - ((self.eta / self.mini_batch_size) * db)) for (b, db) in zip(self.biases, nabla_b)]
        if validation_data:
            accuracy = (self.validate(validation_data) / 100.0)
            print('Epoch {0}, accuracy {1} %.'.format((epoch + 1), accuracy))
        else:
            print('Processed epoch {0}.'.format(epoch))
Fit (train) the Neural Network on provided training data. Fitting is
carried out using Stochastic Gradient Descent Algorithm.

Parameters
----------
training_data : list of tuple
    A list of tuples of numpy arrays, ordered as (image, label).

validation_data : list of tuple, optional
    Same as `training_data`, if provided, the network will display
    validation accuracy after each epoch.
def fit(self, training_data, validation_data=None):
    'Fit (train) the Neural Network on provided training data. Fitting is\n        carried out using Stochastic Gradient Descent Algorithm.\n\n        Parameters\n        ----------\n        training_data : list of tuple\n            A list of tuples of numpy arrays, ordered as (image, label).\n\n        validation_data : list of tuple, optional\n            Same as `training_data`, if provided, the network will display\n            validation accuracy after each epoch.\n\n        '
    for epoch in range(self.epochs):
        random.shuffle(training_data)
        mini_batches = [training_data[k:(k + self.mini_batch_size)] for k in range(0, len(training_data), self.mini_batch_size)]
        for mini_batch in mini_batches:
            nabla_b = [np.zeros(bias.shape) for bias in self.biases]
            nabla_w = [np.zeros(weight.shape) for weight in self.weights]
            for (x, y) in mini_batch:
                self._forward_prop(x)
                (delta_nabla_b, delta_nabla_w) = self._back_prop(x, y)
                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 - ((self.eta / self.mini_batch_size) * dw)) for (w, dw) in zip(self.weights, nabla_w)]
            self.biases = [(b - ((self.eta / self.mini_batch_size) * db)) for (b, db) in zip(self.biases, nabla_b)]
        if validation_data:
            accuracy = (self.validate(validation_data) / 100.0)
            print('Epoch {0}, accuracy {1} %.'.format((epoch + 1), accuracy))
        else:
            print('Processed epoch {0}.'.format(epoch))