# calculating output error dA = perceptron_inputs[-1] - target.reshape(-1, 1) #a scaling factor for the batch size. #you want changes to be an average across all batches #so we divide by m once we've aggregated all changes. m = len(target) for i in reversed(range(len(self.weights))): dZ = dA #simplified for now # calculating change to weights dW = np.dot(perceptron_inputs[i].T, dZ) / m # calculating change to bias db = np.sum(dZ, axis=0, keepdims=True) / m # keeping track of required changes weight_changes.append(dW) bias_changes.append(db) ...