finallynote that to obtain the gradient ` /th of the training losswe simply need to loop algorithm over all the training examplesas follows algorithm computing the gradient of the training loss inputtraining set {(xi yi )}ni= weight matrices and bias vectors {wl bl } = =thactivation functions {sl } = outputthe gradient of the training loss for do /loop over all training examples ol run algorithm with input (xi yi to compute bl = ci return ni= and ni= for all wl bl example (squared-error and cross-entropy lossthe back-propagation algorithm requires formula for dl in line in particularto execute line we need to specify both loss function and an sl that defines the output layerg( thal sl (zl for instancein the multi-logit classification of inputs into pl categories labeled (pl )the output layer is defined via the softmax function exp(zl sl zl pl = exp(zl, in other wordsg( this probability vector such that its ( + )-st component gy+ ( thg( thxis the estimate or prediction of the true conditional probability ( xcombining the softmax output with the cross-entropy lossas was done in ( )yieldslossf ( ) ( thx)ln ( thxln gy+ ( thp pl -zy+ ln = exp(zk hencewe obtain the vector dl with components ( pl pl dl, zk -zy+ ln = exp(zk gk ( th { note that we can remove node from the final layer of the multi-logit networkbecause ( th(which corresponds to the classcan be eliminatedusing the fact pl that ( th = gk ( thfor numerical comparisonsee exercise as another examplein nonlinear multi-output regression (see example )the output function sl is typically of the form ( )so that sl / diag( ( ) ( pl )combining the output ( thsl (zl with the squared-error loss yieldsloss(yg( th)ky ( th) pl ( ( th)) = henceline in algorithm simplifies todl sl (zl ( thy