takes a list of layer definitions and creates the network layer objects
341974
function(defs) {

      // few checks
      assert(defs.length >= 2, 'Error! At least one input layer and one loss layer are required.');
      assert(defs[0].type === 'input', 'Error! First layer must be the input layer, to declare size of inputs');

      // desugar layer_defs for adding activation, dropout layers etc
      var desugar = 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;
      }
      defs = desugar(defs);

      // create the layers
      this.layers = [];
      for(var i=0;i<defs.length;i++) {
        var def = defs[i];
        if(i>0) {
          var prev = this.layers[i-1];
          def.in_sx = prev.out_sx;
          def.in_sy = prev.out_sy;
          def.in_depth = prev.out_depth;
        }

        switch(def.type) {
          case 'fc': this.layers.push(new global.FullyConnLayer(def)); break;
          case 'lrn': this.layers.push(new global.LocalResponseNormalizationLayer(def)); break;
          case 'dropout': this.layers.push(new global.DropoutLayer(def)); break;
          case 'input': this.layers.push(new global.InputLayer(def)); break;
          case 'softmax': this.layers.push(new global.SoftmaxLayer(def)); break;
          case 'regression': this.layers.push(new global.RegressionLayer(def)); break;
          case 'conv': this.layers.push(new global.ConvLayer(def)); break;
          case 'pool': this.layers.push(new global.PoolLayer(def)); break;
          case 'relu': this.layers.push(new global.ReluLayer(def)); break;
          case 'sigmoid': this.layers.push(new global.SigmoidLayer(def)); break;
          case 'tanh': this.layers.push(new global.TanhLayer(def)); break;
          case 'maxout': this.layers.push(new global.MaxoutLayer(def)); break;
          case 'svm': this.layers.push(new global.SVMLayer(def)); break;
          default: console.log('ERROR: UNRECOGNIZED LAYER TYPE: ' + def.type);
        }
      }
    }
391066
def addSRNLayers(self, inc, hidc, outc):
        
        self.addThreeLayers(inc, hidc, outc)
1169857
def network_create(self, name, **kwargs):
        '''
        
        '''
        nt_ks = self.compute_conn
        kwargs['label'] = name
        kwargs = self._sanatize_network_params(kwargs)
        net = nt_ks.networks.create(**kwargs)
        return net.__dict__
863612
def _get_pooling_layers(self, start_node_id, end_node_id):
        """"""
        layer_list = []
        node_list = [start_node_id]
        assert self._depth_first_search(end_node_id, layer_list, node_list)
        ret = []
        for layer_id in layer_list:
            layer = self.layer_list[layer_id]
            if is_layer(layer, "Pooling"):
                ret.append(layer)
            elif is_layer(layer, "Conv") and layer.stride != 1:
                ret.append(layer)
        return ret
449559
function Layer(name, fn) {
  this.length = fn.length;
  this.name = name;
  this.fn = fn;
}
864397
def to_json(self):
        ''' 
        '''

        skip_list = []
        for u, v, connection_type in self.skip_connections:
            skip_list.append({"from": u, "to": v, "type": connection_type})
        return {"node_list": self.layers, "skip_list": skip_list}
1104917
def build_network(self,
                      images,
                      phase_train=True,
                      nclass=1001,
                      image_depth=3,
                      data_type=tf.float32,
                      data_format="NCHW",
                      use_tf_layers=True,
                      fp16_vars=False):
        """"""
        if data_format == "NCHW":
            images = tf.transpose(images, [0, 3, 1, 2])
        var_type = tf.float32
        if data_type == tf.float16 and fp16_vars:
            var_type = tf.float16
        network = convnet_builder.ConvNetBuilder(
            images, image_depth, phase_train, use_tf_layers, data_format,
            data_type, var_type)
        with tf.variable_scope(
                "cg", custom_getter=network.get_custom_getter()):
            self.add_inference(network)
            # Add the final fully-connected class layer
            logits = (network.affine(nclass, activation="linear")
                      if not self.skip_final_affine_layer() else
                      network.top_layer)
            aux_logits = None
            if network.aux_top_layer is not None:
                with network.switch_to_aux_top_layer():
                    aux_logits = network.affine(
                        nclass, activation="linear", stddev=0.001)
        if data_type == tf.float16:
            # TODO(reedwm): Determine if we should do this cast here.
            logits = tf.cast(logits, tf.float32)
            if aux_logits is not None:
                aux_logits = tf.cast(aux_logits, tf.float32)
        return logits, aux_logits
1230584
def create(img_rows, img_cols, img_channels, num_classes):
    
    def instantiate(**_):
        return Net(img_rows, img_cols, img_channels, num_classes)
    return ModelFactory.generic(instantiate)
341993
def get_layers(self, class_: Type[L], became: bool=True) -> List[L]:
        

        out = self._index.get(class_, [])

        if became:
            out += self._transformed.get(class_, [])

        return out
1238630
def add_layers(self, *layers):
		
		for layer in layers:
			if layer.name() in self.__layers.keys():
				raise ValueError('Layer "%s" already exists' % layer.name())
			self.__layers[layer.name()] = layer
664792
def convert_feature_layers_to_dict(feature_layers):
    """"""
    features_by_layer = {}
    for feature_layer in feature_layers:
        layer_name = feature_layer['name']
        features = feature_layer['features']
        features_by_layer[layer_name] = features
    return features_by_layer
1337188
def _instantiate_layers(self):
    """"""

    # Here we are entering the module's variable scope to name our submodules
    # correctly (not to create variables). As such it's safe to not check
    # whether we're in the same graph. This is important if we're constructing
    # the module in one graph and connecting it in another (e.g. with `defun`
    # the module is created in some default graph, and connected to a capturing
    # graph in order to turn it into a graph function).
    with self._enter_variable_scope(check_same_graph=False):
      self._layers = tuple(conv.Conv2D(name="conv_2d_{}".format(i),  # pylint: disable=g-complex-comprehension
                                       output_channels=self._output_channels[i],
                                       kernel_shape=self._kernel_shapes[i],
                                       stride=self._strides[i],
                                       rate=self._rates[i],
                                       padding=self._paddings[i],
                                       use_bias=self._use_bias[i],
                                       initializers=self._initializers,
                                       partitioners=self._partitioners,
                                       regularizers=self._regularizers,
                                       data_format=self._data_format)
                           for i in xrange(self._num_layers))
406324
def create(input_block: ModelFactory, rnn_type: str, output_dim: int,
           rnn_layers: typing.List[int], rnn_dropout: float=0.0, bidirectional: bool=False,
           linear_layers: typing.List[int]=None, linear_dropout: float=0.0):
    
    if linear_layers is None:
        linear_layers = []

    def instantiate(**_):
        return MultilayerRnnSequenceClassification(
            input_block=input_block.instantiate(), rnn_type=rnn_type, output_dim=output_dim,
            rnn_layers=rnn_layers, rnn_dropout=rnn_dropout, bidirectional=bidirectional,
            linear_layers=linear_layers, linear_dropout=linear_dropout
        )

    return ModelFactory.generic(instantiate)
864111
def create_head(nf:int, nc:int, lin_ftrs:Optional[Collection[int]]=None, ps:Floats=0.5,
                concat_pool:bool=True, bn_final:bool=False):
    ""
    lin_ftrs = [nf, 512, nc] if lin_ftrs is None else [nf] + lin_ftrs + [nc]
    ps = listify(ps)
    if len(ps) == 1: ps = [ps[0]/2] * (len(lin_ftrs)-2) + ps
    actns = [nn.ReLU(inplace=True)] * (len(lin_ftrs)-2) + [None]
    pool = AdaptiveConcatPool2d() if concat_pool else nn.AdaptiveAvgPool2d(1)
    layers = [pool, Flatten()]
    for ni,no,p,actn in zip(lin_ftrs[:-1], lin_ftrs[1:], ps, actns):
        layers += bn_drop_lin(ni, no, True, p, actn)
    if bn_final: layers.append(nn.BatchNorm1d(lin_ftrs[-1], momentum=0.01))
    return nn.Sequential(*layers)
674473
private static Enumeration<NetworkInterface> cloneInterfaces(List<NetworkInterface> interfaces) {
       return Collections.enumeration(new ArrayList<>(interfaces));
   }
1010193
def _create_variables_no_pretrain(self, n_features):
        
        self.encoding_w_ = []
        self.encoding_b_ = []

        for l, layer in enumerate(self.layers):

            w_name = 'enc-w-{}'.format(l)
            b_name = 'enc-b-{}'.format(l)

            if l == 0:
                w_shape = [n_features, self.layers[l]]
            else:
                w_shape = [self.layers[l - 1], self.layers[l]]

            w_init = tf.truncated_normal(shape=w_shape, stddev=0.1)
            W = tf.Variable(w_init, name=w_name)
            tf.summary.histogram(w_name, W)
            self.encoding_w_.append(W)

            b_init = tf.constant(0.1, shape=[self.layers[l]])
            b = tf.Variable(b_init, name=b_name)
            tf.summary.histogram(b_name, b)
            self.encoding_b_.append(b)
663995
def layers(self):
        """"""
        if self._layers is None:
            self.__init()
        lyrs = []
        for lyr in self._layers:
            url = self._url + "/%s" % lyr['id']
            lyr['object'] = MobileServiceLayer(url=url,
                                               securityHandler=self._securityHandler,
                                               proxy_url=self._proxy_url,
                                               proxy_port=self._proxy_port,
                                               initialize=False)
        return self._layers