Architectures

Utility functions to detect architecture and verify their names in metatrain.

metatrain.utils.architectures.check_architecture_name(name: str) None[source]

Check if the requested architecture is available.

If the architecture is not found an ValueError() is raised. If an architecture with the same name as an experimental or deprecated architecture exist, this architecture is suggested. If no architecture exist the closest architecture is given to help debugging typos.

Parameters:

name (str) – name of the architecture

Raises:

ValueError – if the architecture is not found

Return type:

None

metatrain.utils.architectures.check_architecture_options(name: str, options: Dict) None[source]

Verifies that an options instance only contains valid keys

If the architecture developer does not provide a validation scheme the options will not checked.

Parameters:
  • name (str) – name of the architecture

  • options (Dict) – architecture options to check

Return type:

None

metatrain.utils.architectures.get_architecture_name(path: str | Path) str[source]

Name of an architecture based on path to pointing inside an architecture.

The function should be used to determine the ARCHITECTURE_NAME based on the name of the folder.

Parameters:
  • absolute_architecture_path – absolute path of the architecture directory

  • path (str | Path)

Returns:

architecture name

Raises:

ValueError – if absolute_architecture_path does not point to a valid architecture directory.

Return type:

str

See also

get_architecture_path() to get the relative path within the metatrain project of an architecture name.

metatrain.utils.architectures.import_architecture(name: str)[source]

Import an architecture.

Parameters:

name (str) – name of the architecture

Raises:

ImportError – if the architecture dependencies are not met

metatrain.utils.architectures.get_architecture_path(name: str) Path[source]

Return the relative path to the architecture directory.

Path based on the name within the metatrain project directory.

Parameters:

name (str) – name of the architecture

Returns:

path to the architecture directory

Return type:

Path

See also

get_architecture_name() to get the name based on an absolute path of an architecture.

metatrain.utils.architectures.find_all_architectures() List[str][source]

Find all currently available architectures.

To find the architectures the function searches for the mandatory default-hypers.yaml file in each architecture directory.

Returns:

List of architectures names

Return type:

List[str]

metatrain.utils.architectures.get_default_hypers(name: str) Dict[source]

Dictionary of the default architecture hyperparameters.

Param:

name of the architecture

Returns:

default hyper parameters of the architectures

Parameters:

name (str)

Return type:

Dict