parameters: (layers, name='')
return_statement: return _inject_name(composed_function, name)
docstring: Sequential(layers, name='')
  
      Layer factory function to create a composite that applies a sequence of layers (or any functions) onto an input.
      ``Sequential ([F, G, H])(x)`` means the same as ``H(G(F(x)))``.
  
      The list of functions may also include tuples of functions. In that case, each function
      in a tuple is applied to the input, and the result is a tuple containing the results of
      these function applications. If followed by another function (typ. ``plus`` or ``splice``),
      the tuple items form the arguments to that function.
  
      Intermediate values in the chain can be accessed by name by inserting a ``Label(name=...)`` layer.
  
      Note: An equivalent way of writing ``Sequential ([F, G, H])(x)`` is ``F >> G >> H``.
  
      Example:
       >>> from cntk.layers import *
  
       >>> # sequence classifier. Maps a one-hot word sequence to a scalar probability value.
       >>> # The recurrence is a Fold(), meaning only the final hidden state is produced.
       >>> # The Label() layer allows to access the final hidden layer by name.
       >>> model = Sequential([Embedding(300), Fold(LSTM(500)), Label('hidden'), Dense(1, activation=sigmoid)])
       >>> model.update_signature(Sequence[Tensor[30000]])
       >>> model.hidden.shape
           (500,)
  
       >>> # simple example that squares an input value
       >>> f = Sequential([C.log, lambda x: 2 * x, C.exp])  # the second function is a Python lambda
       >>> f.update_signature(1)
       >>> f([np.array([2])])     # log, times 2, exp is the same as computing the square
           array([[ 4.]], dtype=float32)
  
       >>> # using function tuples to implement a bidirectional LSTM
       >>> bi_lstm = Sequential([(Recurrence(LSTM(250)),                      # first tuple entry: forward pass
       ...                        Recurrence(LSTM(250), go_backwards=True)),  # second: backward pass
       ...                       splice])                                     # splice both on top of each other
  
       >>> # using function tuple to implement a ResNet block
       >>> # The function tuple applies all items to the input, and emits a tuple with the results
       >>> # that then act as the arguments to the next one.
       >>> # Here we say (Convolution(), identity), which generates two arguments to the next function,
       >>> # the first being the convolution, the second being the input passed through.
       >>> # Following that with plus() implements the ResNet formula.
       >>> from cntk.ops import plus, relu
       >>> resnet_layer = Sequential([(Convolution((3,3), 64, activation=None), # first tuple entry
       ...                             identity),                               # second tuple entry is a pass-through
       ...                            plus,                                     # this sums both
       ...                            relu])                                    # activation applied afterwards
  
       >>> # simple function-tuples example with values
       >>> f = Sequential([(lambda x: x * x, identity), splice])  # computes tuple (x^2, x) and splices both values
       >>> f.update_signature(1)
       >>> f([np.array([2])])
           array([[ 4.,  2.]], dtype=float32)
  
      Args:
        layers (list of :class:`~cntk.ops.functions.Function`, equivalent Python functions, tuples of functions, or lists thereof): the list of functions to apply in sequence.
          A tuple aplies each of its items to the input and results in a tuple value.
          An item that is a list will be flattened.
  
      Returns:
          cntk.ops.functions.Function:
          A function that accepts one argument and applies the given ``functions`` one after another.
docstring_summary: Sequential(layers, name='')
docstring_tokens: Sequential ( layers name = )
function: def Sequential(layers, name=''):
      '''
      Sequential(layers, name='')
  
      Layer factory function to create a composite that applies a sequence of layers (or any functions) onto an input.
      ``Sequential ([F, G, H])(x)`` means the same as ``H(G(F(x)))``.
  
      The list of functions may also include tuples of functions. In that case, each function
      in a tuple is applied to the input, and the result is a tuple containing the results of
      these function applications. If followed by another function (typ. ``plus`` or ``splice``),
      the tuple items form the arguments to that function.
  
      Intermediate values in the chain can be accessed by name by inserting a ``Label(name=...)`` layer.
  
      Note: An equivalent way of writing ``Sequential ([F, G, H])(x)`` is ``F >> G >> H``.
  
      Example:
       >>> from cntk.layers import *
  
       >>> # sequence classifier. Maps a one-hot word sequence to a scalar probability value.
       >>> # The recurrence is a Fold(), meaning only the final hidden state is produced.
       >>> # The Label() layer allows to access the final hidden layer by name.
       >>> model = Sequential([Embedding(300), Fold(LSTM(500)), Label('hidden'), Dense(1, activation=sigmoid)])
       >>> model.update_signature(Sequence[Tensor[30000]])
       >>> model.hidden.shape
           (500,)
  
       >>> # simple example that squares an input value
       >>> f = Sequential([C.log, lambda x: 2 * x, C.exp])  # the second function is a Python lambda
       >>> f.update_signature(1)
       >>> f([np.array([2])])     # log, times 2, exp is the same as computing the square
           array([[ 4.]], dtype=float32)
  
       >>> # using function tuples to implement a bidirectional LSTM
       >>> bi_lstm = Sequential([(Recurrence(LSTM(250)),                      # first tuple entry: forward pass
       ...                        Recurrence(LSTM(250), go_backwards=True)),  # second: backward pass
       ...                       splice])                                     # splice both on top of each other
  
       >>> # using function tuple to implement a ResNet block
       >>> # The function tuple applies all items to the input, and emits a tuple with the results
       >>> # that then act as the arguments to the next one.
       >>> # Here we say (Convolution(), identity), which generates two arguments to the next function,
       >>> # the first being the convolution, the second being the input passed through.
       >>> # Following that with plus() implements the ResNet formula.
       >>> from cntk.ops import plus, relu
       >>> resnet_layer = Sequential([(Convolution((3,3), 64, activation=None), # first tuple entry
       ...                             identity),                               # second tuple entry is a pass-through
       ...                            plus,                                     # this sums both
       ...                            relu])                                    # activation applied afterwards
  
       >>> # simple function-tuples example with values
       >>> f = Sequential([(lambda x: x * x, identity), splice])  # computes tuple (x^2, x) and splices both values
       >>> f.update_signature(1)
       >>> f([np.array([2])])
           array([[ 4.,  2.]], dtype=float32)
  
      Args:
        layers (list of :class:`~cntk.ops.functions.Function`, equivalent Python functions, tuples of functions, or lists thereof): the list of functions to apply in sequence.
          A tuple aplies each of its items to the input and results in a tuple value.
          An item that is a list will be flattened.
  
      Returns:
          cntk.ops.functions.Function:
          A function that accepts one argument and applies the given ``functions`` one after another.
      '''
      if not isinstance(layers, list):  # to support nested lists, run every item recursively through Sequential()
          # TODO: Is this confusing w.r.t. tuple which is parallel and list which is sequential?
          return layers
      from functools import reduce
      layers = [Sequential(layer) for layer in layers]  # expand all layers recursively
      composed_function = reduce(lambda f, g: f >> g, layers, identity)
  
      return _inject_name(composed_function, name)
function_tokens: def Sequential ( layers , name = '' ) : if not isinstance ( layers , list ) : # to support nested lists, run every item recursively through Sequential() # TODO: Is this confusing w.r.t. tuple which is parallel and list which is sequential? return layers from functools import reduce layers = [ Sequential ( layer ) for layer in layers ] # expand all layers recursively composed_function = reduce ( lambda f , g : f >> g , layers , identity ) return _inject_name ( composed_function , name )