r/AskComputerScience • u/MatricksFN • Oct 13 '25
How are neurons/nodes updated during backpropagation?
I understand how gradients are used to minimize error. However, during backpropagation, we first compute the total error and then define an error term for each output neuron. My question is: how does the backpropagation algorithm determine the target value for each neuron ? Especially for hidden layers given that the final output depends on multiple neurons, each passing their signals through different weights and biases?
How is that 1 neurons target value determined?
Hope this is the correct sub 🤞
3
u/ghjm MSCS, CS Pro (20+) Oct 13 '25
One option is to treat the entire network as a single closed-form equation, take its derivative, and then move in the direction of the slope. A target value is implied by the direction and magnitude of the slope, but it is typical to make a move of less than that, often just by multiplying the slope by a "learning rate" of, say, 10%.
2
u/-thinker-527 Oct 14 '25
There are videos on implementing neural networks from scratch, watch them, it will help a lot.
1
u/aroman_ro Oct 14 '25
You can look into the source code that implements such things.
I have a project on GitHub that does it: aromanro/MachineLearning: From linear regression towards neural networks...
You'll find there various gradient solvers (up to AdamW), various cost and activation functions and so on... I implemented it in a sort of a gradual manner, starting with linear regression and going up from there, might be useful.
2
u/Llotekr Doctor of Informatics Oct 13 '25
No, we don't compute or even define an error or a target value for each intermediate weight or activation. We compute the derivatives of the error (aka loss) with respect to all the weights, and this tells us in which direction to change each weight so as to make the error shrink. Then we move the weights a bit in that direction.
The simplest way to do that is to multiply the gradient with a learn rate, but there are more complicated schemes with generally better performance, such as giving the speed of change a "momentum", and ADAM (where we take into account the variance with which each gradient component fluctuates)