#NEWLINE# def add( self , layer ) : #NEWLINE# #INDENT# 'Adds a layer instance on top of the layer stack.\n\n        # Arguments\n            layer: layer instance.\n        ' #NEWLINE# if ( not self . outputs ) : #NEWLINE# #INDENT# if ( len ( layer . inbound_nodes ) == 0 ) : #NEWLINE# #INDENT# if ( not hasattr ( layer , 'batch_input_shape' ) ) : #NEWLINE# #INDENT# raise Exception ( 'The first layer in a Sequential model must get an `input_shape` or `batch_input_shape` argument.' ) #NEWLINE# #UNINDENT# batch_input_shape = layer . batch_input_shape #NEWLINE# if hasattr ( layer , 'input_dtype' ) : #NEWLINE# #INDENT# input_dtype = layer . input_dtype #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# input_dtype = None #NEWLINE# #UNINDENT# layer . create_input_layer ( batch_input_shape , input_dtype ) #NEWLINE# #UNINDENT# if ( len ( layer . inbound_nodes ) != 1 ) : #NEWLINE# #INDENT# raise Exception ( ( ( ( ( 'A layer added to a Sequential model must not already be connected somewhere else. Model received layer ' + layer . name ) + ' which has ' ) + str ( len ( layer . inbound_nodes ) ) ) + ' pre-existing inbound connections.' ) ) #NEWLINE# #UNINDENT# if ( len ( layer . inbound_nodes [ 0 ] . output_tensors ) != 1 ) : #NEWLINE# #INDENT# raise Exception ( 'All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.' ) #NEWLINE# #UNINDENT# self . outputs = [ layer . inbound_nodes [ 0 ] . output_tensors [ 0 ] ] #NEWLINE# self . inputs = get_source_inputs ( self . outputs [ 0 ] ) #NEWLINE# Node ( outbound_layer = self , inbound_layers = [ ] , node_indices = [ ] , tensor_indices = [ ] , input_tensors = self . inputs , output_tensors = self . outputs , input_masks = [ None for _ in self . inputs ] , output_masks = [ None ] , input_shapes = [ x . _keras_shape for x in self . inputs ] , output_shapes = [ self . outputs [ 0 ] . _keras_shape ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# output_tensor = layer ( self . outputs [ 0 ] ) #NEWLINE# if ( type ( output_tensor ) is list ) : #NEWLINE# #INDENT# raise Exception ( 'All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.' ) #NEWLINE# #UNINDENT# self . outputs = [ output_tensor ] #NEWLINE# self . inbound_nodes [ 0 ] . output_tensors = self . outputs #NEWLINE# self . inbound_nodes [ 0 ] . output_shapes = [ self . outputs [ 0 ] . _keras_shape ] #NEWLINE# #UNINDENT# self . layers . append ( layer ) #NEWLINE# self . built = False