def layer(op):
 def layer_decorated(self, *args, **kwargs):
  name = kwargs.setdefault('name', self.get_unique_name(op.__name__))
  if (len(self.terminals) == 0):
   raise RuntimeError(('No input variables found for layer %s.' % name))
  elif (len(self.terminals) == 1):
   layer_input = self.terminals[0]
  else:
   layer_input = list(self.terminals)
  layer_output = op(self, layer_input, *args, **kwargs)
  self.layers[name] = layer_output
  self.feed(layer_output)
  return self
 return layer_decorated

def layer ( op ) : def layer_decorated ( self , * args , ** kwargs ) : name = kwargs . setdefault ( 'name' , self . get_unique_name ( op . __name__ ) ) if ( len ( self . terminals ) == 0 ) : raise RuntimeError ( ( 'No input variables found for layer %s.' % name ) ) elif ( len ( self . terminals ) == 1 ) : layer_input = self . terminals [ 0 ] else : layer_input = list ( self . terminals ) layer_output = op ( self , layer_input , * args , ** kwargs ) self . layers [ name ] = layer_output self . feed ( layer_output ) return self return layer_decorated
decorator for composable network layers .