graphnet.models.model module

Base class(es) for building models.

class graphnet.models.model.Model(*args, **kwargs)[source]

Bases: Logger, Configurable, LightningModule, ABC

Base class for all components in graphnet.

Construct Logger.

Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

object

verbose_print = True
save(path)[source]

Save entire model to path.

Return type:

None

Parameters:

path (str)

classmethod load(path)[source]

Load entire model from path.

Return type:

Model

Parameters:

path (str)

save_state_dict(path)[source]

Save model state_dict to path.

Return type:

None

Parameters:

path (str)

load_state_dict(path, **kargs)[source]

Load model state_dict from path.

Return type:

Model

Parameters:
  • path (str | Dict)

  • kargs (Any | None)

classmethod from_config(source, trust, load_modules)[source]

Construct Model instance from source configuration.

Parameters:
  • trust (bool, default: False) – Whether to trust the ModelConfig file enough to eval(…) any lambda function expressions contained.

  • load_modules (Optional[List[str]], default: None) – List of modules used in the definition of the model which, as a consequence, need to be loaded into the global namespace. Defaults to loading torch.

  • source (ModelConfig | str)

Raises:

ValueError – If the ModelConfig contains lambda functions but trust = False.

Return type:

Model

set_verbose_print_recursively(verbose_print)[source]

Set verbose_print recursively for all Model modules.

Return type:

None

Parameters:

verbose_print (bool)

extra_repr()[source]

Provide a more detailed description of the object print.

Returns:

A string representation containing detailed information about the object.

Return type:

str

extra_repr_recursive(dictionary, indent)[source]

Recursively format a dictionary for extra_repr.

Return type:

str

Parameters:
  • dictionary (dict)

  • indent (int)