model_config¶
Config classes for the graphnet.models module.
- class graphnet.utilities.config.model_config.ModelConfig(*, class_name, arguments)[source]¶
Bases:
BaseConfig
Configuration for all `Model`s.
Construct ModelConfig.
Can be used for model configuration as code, thereby making model construction more transparent and reproducible. Note that this does not save any trainable weights, meaning this is only a configuration for the model’s hyperparameters. Any model instantiated from a ModelConfig or file will be randomly initialised, and thus should be trained.
Examples
In one session, do:
>>> model = Model(...) >>> model.config.dump() arguments: - (...): (...) class_name: Model >>> model.config.dump("model.yml")
In another session, you can then do: >>> model = Model.from_config(“model.yml”)
- Parameters:
class_name (str)
arguments (Dict[str, Any])
-
class_name:
str
¶
-
arguments:
Dict
[str
,Any
]¶
- as_dict()[source]¶
Represent ModelConfig as a dict.
This builds on BaseModel.dict() but wraps the output in a single-key dictionary to make it unambiguous to identify model arguments that are themselves models.
- Return type:
Dict
[str
,Dict
[str
,Any
]]
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- graphnet.utilities.config.model_config.save_model_config(init_fn)[source]¶
Save the arguments to __init__ functions as a member ModelConfig.
- Return type:
Callable
- Parameters:
init_fn (Callable)
- class graphnet.utilities.config.model_config.ModelConfigSaverMeta[source]¶
Bases:
type
Metaclass for saving ModelConfig to Model instances.
- class graphnet.utilities.config.model_config.ModelConfigSaverABC(name, bases, namespace, **kwargs)[source]¶
Bases:
ModelConfigSaverMeta
,ABCMeta
Common interface between ModelConfigSaver and ABC Metaclasses.