You are training a neural network for a supervised learning task and need to update its weights based on prediction error.
What is the role of backpropagation in training neural networks?