The output of one layer becomes the input to the next.
Back-propagation
Back-propagation
Learning representations by back-propagating errors
David E. Rumelhart, Geoffrey E. Hinton & Ronald J. Williams
We describe a new learning procedure, back-propagation, for networks of neurone-like units. The procedure repeatedly adjusts the weights of the connections in the network so as to minimize a measure of the difference between the actual output vector of the net and the desired output vector. As a result of the weight adjustments, internal ‘hidden’ units which are not part of the input or output come to represent important features of the task domain, and the regularities in the task are captured by the interactions of these units. The ability to create useful new features distinguishes back-propagation from earlier, simpler methods such as the perceptron-convergence procedure.
Representation and learning
A single-layer perceptron can separate only linearly separable classes.
A multilayer network can represent XOR, as demonstrated in Lecture 11.
Learning its hidden-layer parameters requires solving the credit assignment problem: how does each parameter affect the final loss?
Backpropagation in the 1986 paper
The paper used a squared-error objective and sigmoid units.
A forward pass computes activations; a backward pass computes parameter gradients.
Gradient descent uses those gradients to update the parameters.
Hidden units can learn useful internal representations.
Conceptual Idea
Conceptual Idea (continued)
Conceptual Idea (continued)
Backpropagation
Backpropagation is an algorithm for methodically computing the partial derivatives of a neural network’s loss function with respect to each weight and bias parameter.
Backpropagation applies the chain rule of calculus recursively to compute both \(\frac{\partial J}{\partial w_{i,j}^{(l)}}\) and \(\frac{\partial J}{\partial b_j^{(l)}}\) for every layer \(l\), efficiently reusing intermediate quantities from the forward pass.
def forward(self, X): a = Xfor W, b inzip(self.W, self.b): a = sigmoid(a @ W + b)return a.ravel()
Forward (private)
def _forward_full(self, X): a = X activations = [a] zs = []for W, b inzip(self.W, self.b): z = a @ W + b a = sigmoid(z) zs.append(z) activations.append(a)return activations, zs
Training
def train(self, X, y, epochs=30, batch_size=None, verbose=True):"""X: (N, d), y: (N,); batch_size=None uses the full dataset.""" N = X.shape[0] idx = np.arange(N) B = N if batch_size isNoneelseint(batch_size)for ep inrange(1, epochs +1):self.rng.shuffle(idx) base_loss =self.loss(X, y)for start inrange(0, N, B): sl = idx[start:start + B] Xb = X[sl] yb = y[sl].reshape(-1, 1) Bsz = Xb.shape[0] activations, zs =self._forward_full(Xb) A_L = activations[-1]# Each row is a single example's preactivation sensitivity. delta = A_L - yb grads_W = [None] *len(self.W) grads_b = [None] *len(self.b)# Average parameter gradients over examples exactly once. grads_W[-1] = activations[-2].T @ delta / Bsz grads_b[-1] = delta.mean(axis=0)for k inrange(len(self.W) -2, -1, -1): z = zs[k] d_act = sigmoid_prime(z) delta = (delta @self.W[k +1].T) * d_act grads_W[k] = activations[k].T @ delta / Bsz grads_b[k] = delta.mean(axis=0)# All gradients use the weights from the same forward pass.for k inrange(len(self.W)):self.W[k] -=self.lr * grads_W[k]self.b[k] -=self.lr * grads_b[k] new_loss =self.loss(X, y)if verbose:print(f"Epoch {ep:3d} | loss {base_loss:.5f} -> {new_loss:.5f} | lr={self.lr:.4f}")
Automatic differentiation (autodiff) systematically applies the chain rule to compute exact derivatives of functions expressed as computer programs. It propagates derivatives through elementary operations, either forward (from inputs to outputs) or backward (from outputs to inputs), enabling efficient and precise gradient computation essential for optimization and learning algorithms.
Gradient propagation, activation functions, and initialization.
Extend SimplerMLP to SimpleMLP with activation choices, L2, and learning-rate decay.
Softmax, cross-entropy, and regularization.
References
Angermueller, Christof, Tanel Pärnamaa, Leopold Parts, and Oliver Stegle. 2016. “Deep Learning for Computational Biology.”Mol Syst Biol 12 (7): 878. https://doi.org/10.15252/msb.20156651.
Baydin, Atılım Günes, Barak A. Pearlmutter, Alexey Andreyevich Radul, and Jeffrey Mark Siskind. 2017. “Automatic Differentiation in Machine Learning: A Survey.”J. Mach. Learn. Res. 18 (1): 5595–637.
Bicknell, Klinton, Claire Brust, and Burr Settles. 2023. “How Duolingo’s AI Learns What You Need to Learn: The Language-Learning App Tries to Emulate a Great Human Tutor.”IEEE Spectrum 60 (3): 28–33. https://doi.org/10.1109/MSPEC.2023.10061631.
Rumelhart, David E., Geoffrey E. Hinton, and Ronald J. Williams. 1986. “Learning representations by back-propagating errors.”Nature 323 (6088): 533–36. https://doi.org/10.1038/323533a0.
Russell, Stuart, and Peter Norvig. 2020. Artificial Intelligence: A Modern Approach. 4th ed. Pearson. http://aima.cs.berkeley.edu/.