src/convnet_magicnet.js
function(data) {
      // forward prop the best networks
      // and accumulate probabilities at last layer into a an output Vol

      var eval_candidates = [];
      var nv = 0;
      if(this.evaluated_candidates.length === 0) {
        // not sure what to do here, first batch of nets hasnt evaluated yet
        // lets just predict with current candidates.
        nv = this.candidates.length;
        eval_candidates = this.candidates;
      } else {
        // forward prop the best networks from evaluated_candidates
        nv = Math.min(this.ensemble_size, this.evaluated_candidates.length);
        eval_candidates = this.evaluated_candidates
      }

      // forward nets of all candidates and average the predictions
      var xout, n;
      for(var j=0;j<nv;j++) {
        var net = eval_candidates[j].net;
        var x = net.forward(data);
        if(j===0) { 
          xout = x; 
          n = x.w.length; 
        } else {
          // add it on
          for(var d=0;d<n;d++) {
            xout.w[d] += x.w[d];
          }
        }
      }
      // produce average
      for(var d=0;d<n;d++) {
        xout.w[d] /= nv;
      }
      return xout;
    }
function(data) {
      // forward prop the best networks
      // and accumulate probabilities at last layer into a an output Vol

      var eval_candidates = [];
      var nv = 0;
      if(this.evaluated_candidates.length === 0) {
        // not sure what to do here, first batch of nets hasnt evaluated yet
        // lets just predict with current candidates.
        nv = this.candidates.length;
        eval_candidates = this.candidates;
      } else {
        // forward prop the best networks from evaluated_candidates
        nv = Math.min(this.ensemble_size, this.evaluated_candidates.length);
        eval_candidates = this.evaluated_candidates
      }

      // forward nets of all candidates and average the predictions
      var xout, n;
      for(var j=0;j<nv;j++) {
        var net = eval_candidates[j].net;
        var x = net.forward(data);
        if(j===0) { 
          xout = x; 
          n = x.w.length; 
        } else {
          // add it on
          for(var d=0;d<n;d++) {
            xout.w[d] += x.w[d];
          }
        }
      }
      // produce average
      for(var d=0;d<n;d++) {
        xout.w[d] /= nv;
      }
      return xout;
    }
function ( data ) { // forward prop the best networks // and accumulate probabilities at last layer into a an output Vol var eval_candidates = [ ] ; var nv = 0 ; if ( this . evaluated_candidates . length === 0 ) { // not sure what to do here, first batch of nets hasnt evaluated yet // lets just predict with current candidates. nv = this . candidates . length ; eval_candidates = this . candidates ; } else { // forward prop the best networks from evaluated_candidates nv = Math . min ( this . ensemble_size , this . evaluated_candidates . length ) ; eval_candidates = this . evaluated_candidates } // forward nets of all candidates and average the predictions var xout , n ; for ( var j = 0 ; j < nv ; j ++ ) { var net = eval_candidates [ j ] . net ; var x = net . forward ( data ) ; if ( j === 0 ) { xout = x ; n = x . w . length ; } else { // add it on for ( var d = 0 ; d < n ; d ++ ) { xout . w [ d ] += x . w [ d ] ; } } } // produce average for ( var d = 0 ; d < n ; d ++ ) { xout . w [ d ] /= nv ; } return xout ; }
returns prediction scores for given test data point, as Vol uses an averaged prediction from the best ensemble_size models x is a Vol.
returns prediction scores for given test data point as Vol uses an averaged prediction from the best ensemble_size models x is a Vol .