it:ai_backpropagation
Table of Contents
AI - backpropagation
see also:
Introduction
- neural network deep learning uses an architecture of layers of neurons through which data is passed to arrive at an output layer
- during training, gradient descent and backpropagation calculus techniques are utilised to nudge the weights and biases for each training item while assessing the accuracy of the output compared to the expected output (the “cost”)
- backpropagation is where the weights and biases are modified in reverse order to achieve the lowest cost
simplified concept
- the output of a neural network depends upon the sum of (inputs * weight parameter + bias parameter)
- at each learning rate “step”, the loss function for those parameters is calculated and compared with the previous loss value to calculate the gradient (rate of change of loss per step)
- the parameters are then changed by subtracting from the previous parameter, the gradient * learning rate, hence the parameters are nudged towards a lower overall loss
very brief calculus process of a very basic neural network
- if the output value is represented as aL and the value of the neuron in the layer preceding this is represented as a(L-1)
- and we represent the weight acting on a(L-1) as wL and the bias as bL and have a non-linear function called sigmoidfunction
- then aL = sigmoidfunction(wL a(L-1) + bL) and to simplify this we can use zL = wL a(L-1) + bL so we can get:
- aL = sigmoidfunction(zL)
- and cost = (output - expected output)2 = (aL - y)2
- to ascertain how much a change in the value of wL results in a change in value of the cost, we can use the chain rule in calculus:
- dCost/dwL = dzL/dwL * daL/dzL * dCost/daL
- now taking the derivative of cost, dCost/daL = 2(aL - y)
- and, daL/dzL = derivative of zL
- and, dzL/dwL = a(L-1)
- thus dCost/dwL = 2(aL - y) * derivative of zL * a(L-1)
- when there are additional neural layers, this needs to be expanded to add each layer effect
- likewise when there are more than one neuron in each layer, this needs to be applied to each neuron in the layer PLUS add weight effects for how a neuron in one layer effects EACH neuron in the next layer, and then the cost is the sum of all the individual neuron costs
- and the model then needs to obtain these for each training example and average them to come up with an average cost when using those weights and biases
- a simple model may have over 10,000 weights and biases to assess
- backpropagation uses the above concept to go backwards through each layer to ascertain delta cost to ascertain the minima of the cost function
- AI_gradient_descent is the iterative process of ascertaining the change in cost with a change in a weight to calculate the change vector (a mvertical matrix of all the weights and bias delta cost values) to find the negative gradient and then change the weights in that direction preferentially targeting those weights which have the greatest effect (ie. delta colst value) and then to speed up the process of converging on this minima
it/ai_backpropagation.txt · Last modified: 2023/08/12 14:42 by gary1