Guest User

Untitled

a guest
Dec 11th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. void NNetwork::propigateActivations(){
  2.  
  3. /*
  4. This is the math I am using
  5. [W1 W2 [I1, I2, B1]
  6. W3 W4
  7. W5 W6]
  8.  
  9. H1 = I1*W1 + I2*W3 + B1*W5
  10. H2 = I1*W2 + I2*W4 + B1*W6
  11. */
  12.  
  13. // Calculate the activations for the hidden layer
  14. for (int i = 0; i < hidUnits - 1; i++) {
  15.  
  16. for (int j = 0; j < inUnits; j++) {
  17. nNetwork->hiddenLayer.x[i] += nNetwork->inputLayer.w[j][i] * nNetwork->inputLayer.x[j];
  18. }
  19. }
  20.  
  21. // Use the the Sigmoid function: on the hidden layer
  22. for(int i = 0; i < hidUnits - 1; i++){
  23. // fast sigmoid algorithm is f(x) = x / (1 + abs(x))
  24. nNetwork->hiddenLayer.x[i] = nNetwork->hiddenLayer.x[i] / (1 + abs(nNetwork->hiddenLayer.x[i]));
  25. }
  26.  
  27.  
  28. // Set bias node for hidden layer to 1.0
  29. nNetwork->hiddenLayer.x[hidUnits - 1] = 1.0;
  30.  
  31. // Calculate the activations for the output layer
  32. for (int i = 0; i < outUnits; i++) {
  33.  
  34. for (int j = 0; j < hidUnits; j++) {
  35. nNetwork->outputLayer.x[i] += nNetwork->hiddenLayer.w[j][i] * nNetwork->hiddenLayer.x[j];
  36. }
  37. }
  38.  
  39. // Use the the Sigmoid function: on the output layer
  40. for(int i = 0; i < outUnits; i++){
  41. // fast sigmoid algorithm is f(x) = x / (1 + abs(x))
  42. nNetwork->outputLayer.x[i] = nNetwork->outputLayer.x[i] / (1 + abs(nNetwork->outputLayer.x[i]));
  43. }
Add Comment
Please, Sign In to add comment