Backpropagation code.