helios.model.utils

Attributes

MODEL_REGISTRY

Global instance of the registry for models.

Functions

create_model(→ helios.model.model.Model)

Create the model for the given type.

find_pretrained_file(→ pathlib.Path)

Find the pre-trained file in the given root.

Module Contents

helios.model.utils.MODEL_REGISTRY

Global instance of the registry for models.

Example

import helios.model as hlm

# This automatically registers your model.
@hlm.MODEL_REGISTRY.register
class MyModel:
    ...

# Alternatively you can manually register a model like this:
hlm.MODEL_REGISTRY.register(MyModel)
helios.model.utils.create_model(type_name: str, *args: Any, **kwargs: Any) helios.model.model.Model[source]

Create the model for the given type.

Parameters:
  • type_name – the type of the model to create.

  • args – positional arguments to pass into the model.

  • kwargs – keyword arguments to pass into the model.

Returns:

The model.

helios.model.utils.find_pretrained_file(root: pathlib.Path, name: str) pathlib.Path[source]

Find the pre-trained file in the given root.

The assumption is the following: Given a root /models/cifar and a name resnet-50, then the name of the pre-trained file will contain cifar_resnet-50_ as a prefix. If no file is found, an exception is raised.

Parameters:
  • root – the root where the file is stored.

  • net_name – the save name of the file.

Returns:

The path to the file.

Raises:

RuntimeError – if no pre-trained network was found.