Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void NN::BackProp(){
- ForwardProp();
- for(int i = 0; i < nOutputs; i++){//same size as nOutputs
- deltaOutput[i] = d_activation(netOutput[i]) * currentError[i];//δ = σ(z) · (1 − σ(z)) · (y − t)
- d_biasOutput[i] = deltaOutput[i];//biases are changed
- //derroe/dbj = δj derivative of error in respect to output is delta output slide 67
- for(int j = 0; j < nHiddenNeurons;j++){
- d_weightsOutput[i*nHiddenNeurons+j] = deltaOutput[i] * outHidden[j]; //changing the direvatives of the weights vias biases * hidden outputs
- }
- }
- //check code with arthur
- //working on the nhidden
- for(int x = 0; x < nHiddenNeurons; x++){//x is all hidden neutrons
- deltaHidden[x] = 0.0;
- double sumOutput =0; //suming up (Xiδi· wouti,j)
- for(int i = 0; i < nOutputs; i++){
- //getting all z = netHidden all in respect to nHiddenN dw
- sumOutput += deltaOutput[i] * weightsOutput[x*nOutputs+i];
- //deltaHidden[x] += currentInputs[x] * deltaOutput[i] * weightsOutput[x*nOutputs + i] * d_activation(netOutput[x]);//delta outputs kinda a constant sums itup δ · xi
- //de/wi
- //need += because it adds up other wise it'll be useless
- //deltaHidden[nHiddenNeurons] = d_activation(netHidden[nHiddenNeurons]);//direvative of the error in respect to the hidden weights
- }
- double z = netHidden[x];//z is hidden net for that formula
- deltaHidden[x] = sumOutput * d_activation(z); // (1 − σ(zj))
- d_biasHidden[x] = deltaHidden[x]; //tweaking biases of hidden neurons, propagating backwards
- for(int i = 0; i < nInputs; i++){
- d_weightsHidden[x*nInputs+i] = deltaHidden[x] * currentInputs[i];//changing hiddens weighhts for the inputs (last step of propagation)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement