MCPcopy
hub / github.com/tensorlayer/TensorLayer / LayerList

Class LayerList

tensorlayer/layers/core.py:563–708  ·  view source on GitHub ↗

The class :class:`LayerList` is a linear stack of layers. The :class:`LayerList` can be created by passing a list of layer instances. The given layer instances will be automatically connected one by one. Parameters ---------- layers: list of Layer A list of layers.

Source from the content-addressed store, hash-verified

561
562
563class LayerList(Layer):
564 """
565 The class :class:`LayerList` is a linear stack of layers.
566
567 The :class:`LayerList` can be created by passing a list of layer instances.
568 The given layer instances will be automatically connected one by one.
569
570 Parameters
571 ----------
572 layers: list of Layer
573 A list of layers.
574 name : str or None
575 A unique layer name. If None, a unique name will be automatically assigned.
576
577 Methods
578 ---------
579 __init__()
580 Initializing the LayerList.
581 weights()
582 A collection of weights of all the layer instances.
583 build()
584 Build the LayerList. The layer instances will be connected automatically one by one.
585 forward()
586 Forward the computation. The computation will go through all layer instances.
587 """
588
589 def __init__(self, layers, name=None):
590 """
591 Initializing the LayerList given a list of Layer.
592
593 :param layers: list of Layer
594 :param name: str or None
595 """
596
597 super(LayerList, self).__init__(name=name)
598 self.layers = layers
599
600 is_built = True
601 for layer in self.layers:
602 self._trainable_weights.extend(layer.trainable_weights)
603 self._nontrainable_weights.extend(layer.nontrainable_weights)
604 if layer._built is False:
605 is_built = False
606 if layer._built and layer.all_weights is not None:
607 # some layers in the list passed in have already been built
608 # e.g. using input shape to construct layers in dynamic eager
609 if self._all_weights is None:
610 self._all_weights = list()
611 self._all_weights.extend(layer.all_weights)
612 if is_built:
613 self._built = True
614
615 logging.info(
616 "LayerList %s including layers [%s]" % (self.name, ', '.join([layer.name for layer in self.layers]))
617 )
618
619 # check layer name uniqueness in LayerList
620 local_layer_name_set = set()

Callers 6

make_layersFunction · 0.90
__init__Method · 0.90
__getitem__Method · 0.85
test_layerlistMethod · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by 3

test_layerlistMethod · 0.68
__init__Method · 0.68
__init__Method · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…