def layer_from_config(config, custom_objects=None):
 if custom_objects:
  get_custom_objects().update(custom_objects)
 class_name = config['class_name']
 if (class_name == 'Sequential'):
  layer_class = Sequential
 elif (class_name in ['Model', 'Container']):
  layer_class = Model
 else:
  layer_class = get_from_module(class_name, globals(), 'layer', instantiate=False)
 arg_spec = inspect.getargspec(layer_class.from_config)
 if ('custom_objects' in arg_spec.args):
  return layer_class.from_config(config['config'], custom_objects=custom_objects)
 else:
  return layer_class.from_config(config['config'])

def layer_from_config ( config , custom_objects = None ) : if custom_objects : get_custom_objects ( ) . update ( custom_objects ) class_name = config [ 'class_name' ] if ( class_name == 'Sequential' ) : layer_class = Sequential elif ( class_name in [ 'Model' , 'Container' ] ) : layer_class = Model else : layer_class = get_from_module ( class_name , globals ( ) , 'layer' , instantiate = False ) arg_spec = inspect . getargspec ( layer_class . from_config ) if ( 'custom_objects' in arg_spec . args ) : return layer_class . from_config ( config [ 'config' ] , custom_objects = custom_objects ) else : return layer_class . from_config ( config [ 'config' ] )
instantiate a layer from a config dictionary .