示例#1
0
 def from_config(cls, config, custom_objects=None):
     model = cls()
     for conf in config:
         layer = layer_module.deserialize(conf,
                                          custom_objects=custom_objects)
         model.add(layer)
     return model
示例#2
0
def model_from_json(json_string, custom_objects=None):
    """Parses a JSON model configuration file and returns a model instance.

  Arguments:
      json_string: JSON string encoding a model configuration.
      custom_objects: Optional dictionary mapping names
          (strings) to custom classes or functions to be
          considered during deserialization.

  Returns:
      A Keras model instance (uncompiled).
  """
    config = json.loads(json_string)
    return layer_module.deserialize(config, custom_objects=custom_objects)
示例#3
0
def model_from_json(json_string, custom_objects=None):
  """Parses a JSON model configuration file and returns a model instance.

  Arguments:
      json_string: JSON string encoding a model configuration.
      custom_objects: Optional dictionary mapping names
          (strings) to custom classes or functions to be
          considered during deserialization.

  Returns:
      A Keras model instance (uncompiled).
  """
  config = json.loads(json_string)
  return layer_module.deserialize(config, custom_objects=custom_objects)
示例#4
0
def model_from_config(config, custom_objects=None):
    """Instantiates a Keras model from its config.

  Arguments:
      config: Configuration dictionary.
      custom_objects: Optional dictionary mapping names
          (strings) to custom classes or functions to be
          considered during deserialization.

  Returns:
      A Keras model instance (uncompiled).
  """
    if isinstance(config, list):
        raise TypeError('`model_fom_config` expects a dictionary, not a list. '
                        'Maybe you meant to use '
                        '`Sequential.from_config(config)`?')
    return layer_module.deserialize(config, custom_objects=custom_objects)
示例#5
0
def model_from_config(config, custom_objects=None):
  """Instantiates a Keras model from its config.

  Arguments:
      config: Configuration dictionary.
      custom_objects: Optional dictionary mapping names
          (strings) to custom classes or functions to be
          considered during deserialization.

  Returns:
      A Keras model instance (uncompiled).
  """
  if isinstance(config, list):
    raise TypeError('`model_fom_config` expects a dictionary, not a list. '
                    'Maybe you meant to use '
                    '`Sequential.from_config(config)`?')
  return layer_module.deserialize(config, custom_objects=custom_objects)
示例#6
0
def model_from_yaml(yaml_string, custom_objects=None):
    """Parses a yaml model configuration file and returns a model instance.

  Arguments:
      yaml_string: YAML string encoding a model configuration.
      custom_objects: Optional dictionary mapping names
          (strings) to custom classes or functions to be
          considered during deserialization.

  Returns:
      A Keras model instance (uncompiled).

  Raises:
      ImportError: if yaml module is not found.
  """
    if yaml is None:
        raise ImportError('Requires yaml module installed.')
    config = yaml.load(yaml_string)
    return layer_module.deserialize(config, custom_objects=custom_objects)
示例#7
0
def model_from_yaml(yaml_string, custom_objects=None):
  """Parses a yaml model configuration file and returns a model instance.

  Arguments:
      yaml_string: YAML string encoding a model configuration.
      custom_objects: Optional dictionary mapping names
          (strings) to custom classes or functions to be
          considered during deserialization.

  Returns:
      A Keras model instance (uncompiled).

  Raises:
      ImportError: if yaml module is not found.
  """
  if yaml is None:
    raise ImportError('Requires yaml module installed.')
  config = yaml.load(yaml_string)
  return layer_module.deserialize(config, custom_objects=custom_objects)
示例#8
0
 def from_config(cls, config):
     model = cls()
     for conf in config:
         layer = layer_module.deserialize(conf)
         model.add(layer)
     return model
示例#9
0
 def from_config(cls, config, custom_objects=None):
   model = cls()
   for conf in config:
     layer = layer_module.deserialize(conf, custom_objects=custom_objects)
     model.add(layer)
   return model