Guest User

Untitled

a guest
Jan 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. // Schmidhuber's neural bucket brigade
  2. struct Incomming {
  3. int n;
  4. int *idxArr;
  5. };
  6.  
  7. struct Ctx {
  8. float lamda;
  9.  
  10. float *xtm1;
  11. float **wtm1; // by index i index j
  12.  
  13. float *xtm2;
  14. float **wtm2; // by index i index j
  15.  
  16. Incomming **incomming; // by index j
  17. };
  18.  
  19. // calc c_ij for t
  20. float ctm0(Ctx *ctx, int i, int j) {
  21. return ctx->xtm1[i]*ctx->wtm1[i][j];
  22. }
  23.  
  24. // calc c_ij for t-1
  25. float ctm1(Ctx *ctx, int i, int j) {
  26. return ctx->xtm2[i]*ctx->wtm2[i][j];
  27. }
  28.  
  29.  
  30. float deltaW(Ctx *ctx, int i, int j) {
  31. float cDivSum = 0.0f;
  32.  
  33. Incomming *incommingByJ = ctx->incomming[j];
  34.  
  35. for( int k = 0; k < incommingByJ->n; k++ ) {
  36. int i2 = incommingByJ->idxArr[k];
  37.  
  38. cDivSum += ctm1(ctx, i2, j);
  39. }
  40.  
  41. float res = (ctm1(ctx, i, j) / cDivSum);
  42.  
  43. // TODO< multiply by sum of kwins >
  44.  
  45. res += (-ctx->lamda*ctm0(ctx, i, j));
  46.  
  47. // TODO< add ext >
  48.  
  49. return res;
  50. }
Add Comment
Please, Sign In to add comment