src/convnet_net.js
function() {
        var new_defs = [];
        for(var i=0;i<defs.length;i++) {
          var def = defs[i];
          
          if(def.type==='softmax' || def.type==='svm') {
            // add an fc layer here, there is no reason the user should
            // have to worry about this and we almost always want to
            new_defs.push({type:'fc', num_neurons: def.num_classes});
          }

          if(def.type==='regression') {
            // add an fc layer here, there is no reason the user should
            // have to worry about this and we almost always want to
            new_defs.push({type:'fc', num_neurons: def.num_neurons});
          }

          if((def.type==='fc' || def.type==='conv') 
              && typeof(def.bias_pref) === 'undefined'){
            def.bias_pref = 0.0;
            if(typeof def.activation !== 'undefined' && def.activation === 'relu') {
              def.bias_pref = 0.1; // relus like a bit of positive bias to get gradients early
              // otherwise it's technically possible that a relu unit will never turn on (by chance)
              // and will never get any gradient and never contribute any computation. Dead relu.
            }
          }

          new_defs.push(def);

          if(typeof def.activation !== 'undefined') {
            if(def.activation==='relu') { new_defs.push({type:'relu'}); }
            else if (def.activation==='sigmoid') { new_defs.push({type:'sigmoid'}); }
            else if (def.activation==='tanh') { new_defs.push({type:'tanh'}); }
            else if (def.activation==='maxout') {
              // create maxout activation, and pass along group size, if provided
              var gs = def.group_size !== 'undefined' ? def.group_size : 2;
              new_defs.push({type:'maxout', group_size:gs});
            }
            else { console.log('ERROR unsupported activation ' + def.activation); }
          }
          if(typeof def.drop_prob !== 'undefined' && def.type !== 'dropout') {
            new_defs.push({type:'dropout', drop_prob: def.drop_prob});
          }

        }
        return new_defs;
      }
function() {
        var new_defs = [];
        for(var i=0;i<defs.length;i++) {
          var def = defs[i];
          
          if(def.type==='softmax' || def.type==='svm') {
            // add an fc layer here, there is no reason the user should
            // have to worry about this and we almost always want to
            new_defs.push({type:'fc', num_neurons: def.num_classes});
          }

          if(def.type==='regression') {
            // add an fc layer here, there is no reason the user should
            // have to worry about this and we almost always want to
            new_defs.push({type:'fc', num_neurons: def.num_neurons});
          }

          if((def.type==='fc' || def.type==='conv') 
              && typeof(def.bias_pref) === 'undefined'){
            def.bias_pref = 0.0;
            if(typeof def.activation !== 'undefined' && def.activation === 'relu') {
              def.bias_pref = 0.1; // relus like a bit of positive bias to get gradients early
              // otherwise it's technically possible that a relu unit will never turn on (by chance)
              // and will never get any gradient and never contribute any computation. Dead relu.
            }
          }

          new_defs.push(def);

          if(typeof def.activation !== 'undefined') {
            if(def.activation==='relu') { new_defs.push({type:'relu'}); }
            else if (def.activation==='sigmoid') { new_defs.push({type:'sigmoid'}); }
            else if (def.activation==='tanh') { new_defs.push({type:'tanh'}); }
            else if (def.activation==='maxout') {
              // create maxout activation, and pass along group size, if provided
              var gs = def.group_size !== 'undefined' ? def.group_size : 2;
              new_defs.push({type:'maxout', group_size:gs});
            }
            else { console.log('ERROR unsupported activation ' + def.activation); }
          }
          if(typeof def.drop_prob !== 'undefined' && def.type !== 'dropout') {
            new_defs.push({type:'dropout', drop_prob: def.drop_prob});
          }

        }
        return new_defs;
      }
function ( ) { var new_defs = [ ] ; for ( var i = 0 ; i < defs . length ; i ++ ) { var def = defs [ i ] ; if ( def . type === 'softmax' || def . type === 'svm' ) { // add an fc layer here, there is no reason the user should // have to worry about this and we almost always want to new_defs . push ( { type : 'fc' , num_neurons : def . num_classes } ) ; } if ( def . type === 'regression' ) { // add an fc layer here, there is no reason the user should // have to worry about this and we almost always want to new_defs . push ( { type : 'fc' , num_neurons : def . num_neurons } ) ; } if ( ( def . type === 'fc' || def . type === 'conv' ) && typeof ( def . bias_pref ) === 'undefined' ) { def . bias_pref = 0.0 ; if ( typeof def . activation !== 'undefined' && def . activation === 'relu' ) { def . bias_pref = 0.1 ; // relus like a bit of positive bias to get gradients early // otherwise it's technically possible that a relu unit will never turn on (by chance) // and will never get any gradient and never contribute any computation. Dead relu. } } new_defs . push ( def ) ; if ( typeof def . activation !== 'undefined' ) { if ( def . activation === 'relu' ) { new_defs . push ( { type : 'relu' } ) ; } else if ( def . activation === 'sigmoid' ) { new_defs . push ( { type : 'sigmoid' } ) ; } else if ( def . activation === 'tanh' ) { new_defs . push ( { type : 'tanh' } ) ; } else if ( def . activation === 'maxout' ) { // create maxout activation, and pass along group size, if provided var gs = def . group_size !== 'undefined' ? def . group_size : 2 ; new_defs . push ( { type : 'maxout' , group_size : gs } ) ; } else { console . log ( 'ERROR unsupported activation ' + def . activation ) ; } } if ( typeof def . drop_prob !== 'undefined' && def . type !== 'dropout' ) { new_defs . push ( { type : 'dropout' , drop_prob : def . drop_prob } ) ; } } return new_defs ; }
desugar layer_defs for adding activation, dropout layers etc
desugar layer_defs for adding activation dropout layers etc