Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function finalizeTrain():void
  2.         {
  3.             var _this_leaf:int = number_of_samples_for_this_leaf;
  4.             var _this_leaf_sz:int = numLeavesPerFern;
  5.             var _number_of_samples_for_class:int = number_of_samples_for_class;
  6.             var _leaves_counters:int = leaves_counters;
  7.             var _leaves_distributions:int = leaves_distributions;
  8.             var np:int = numPoints;
  9.             var nf:int = numFerns;
  10.             var ptr1:int;
  11.            
  12.             for(var i:int = 0; i < nf; ++i)
  13.             {              
  14.                 var istep2:int = __cint(i * step2);
  15.                
  16.                 var number_of_samples_for_this_fern:Number = 0.0;
  17.                
  18.                 ptr1 = _this_leaf;
  19.                 for(var j:int = 0; j < _this_leaf_sz; ++j)
  20.                 {
  21.                     var jstep1:int = __cint(j * step1);
  22.                     var istep2_jstep1:int = __cint(istep2 + jstep1);
  23.                     var tmp:Number = 0.0;
  24.                     for(var k:int = 0; k < np; ++k)
  25.                     {
  26.                         var nsfc:Number = Memory.readInt(__cint(_number_of_samples_for_class + (k<<2)));
  27.                         var lcs:Number = Memory.readUnsignedShort(__cint(_leaves_counters + ((istep2_jstep1 + k)<<1)));
  28.                         var rat:Number = lcs / nsfc;
  29.                         number_of_samples_for_this_fern += rat;
  30.                         tmp += rat;
  31.                     }
  32.                     Memory.writeDouble(tmp, ptr1);
  33.                     ptr1 = __cint(ptr1 + 8);
  34.                 }
  35.                
  36.                 for(k = 0; k < np; ++k)
  37.                 {
  38.                     nsfc = Memory.readInt(__cint(_number_of_samples_for_class + (k<<2)));
  39.                     tmp = 0.0;
  40.                     for(j = 0; j < _this_leaf_sz; ++j)
  41.                     {
  42.                         istep2_jstep1 = __cint(istep2 + (j * step1) + k);
  43.                        
  44.                         lcs = Memory.readUnsignedShort(__cint(_leaves_counters + (istep2_jstep1<<1)));
  45.                         tmp += lcs / nsfc;
  46.                     }
  47.                    
  48.                     ptr1 = _this_leaf;
  49.                     for(j = 0; j < _this_leaf_sz; ++j)
  50.                     {
  51.                         istep2_jstep1 = __cint(istep2 + (j * step1) + k);
  52.                        
  53.                         lcs = Memory.readUnsignedShort(__cint(_leaves_counters + (istep2_jstep1<<1)));
  54.                        
  55.                         rat = Math.log(
  56.                                         lcs / nsfc / tmp / (Memory.readDouble(ptr1) / number_of_samples_for_this_fern)
  57.                                         );
  58.                         Memory.writeFloat(rat, __cint(_leaves_distributions + (istep2_jstep1<<2)) );
  59.                         //
  60.                         ptr1 = __cint(ptr1 + 8);
  61.                     }
  62.                 }
  63.             }
  64.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement