Registry#
- class torch_ecg.utils.Registry(name: str)[source]#
Bases:
objectRegistry for managing and building modules.
A registry is used to map strings (module names) to classes, and provides a unified interface to instantiate modules from configurations.
- Parameters:
name (str) – Name of the registry.
Examples
>>> BACKBONES = Registry("backbones") >>> @BACKBONES.register() ... class ResNet(nn.Module): ... def __init__(self, depth): ... self.depth = depth >>> # Build from string >>> model = BACKBONES.build("ResNet", depth=50) >>> # Build from config dict >>> model = BACKBONES.build({"name": "ResNet", "depth": 101})
- build(config: str | Dict[str, Any], **kwargs: Any) Any[source]#
Build a module from a configuration.
- Parameters:
- Returns:
The instantiated module.
- Return type:
Any