Skip to content

Config

LossType = TypeVar('LossType') module-attribute

Stand-in for a loss function; no constraints.

ModelOutput = TypeVar('ModelOutput', Tensor, list[Tensor], tuple[Tensor], dict[str, Tensor], covariant=True) module-attribute

A Model's forward pass may produce a tensor, multiple tensors, or named tensors.

ModelType = TypeVar('ModelType', bound=Model) module-attribute

Generic type for things that have a forward pass.

BionemoModelConfig

Bases: Generic[ModelType], ABC

An abstract class for model configuration.

Source code in bionemo/core/model/config.py
54
55
56
57
58
59
60
class BionemoModelConfig(Generic[ModelType], ABC):
    """An abstract class for model configuration."""

    @abstractmethod
    def configure_model(self, *args, **kwargs) -> Model:
        """Configures the model."""
        raise NotImplementedError()

configure_model(*args, **kwargs) abstractmethod

Configures the model.

Source code in bionemo/core/model/config.py
57
58
59
60
@abstractmethod
def configure_model(self, *args, **kwargs) -> Model:
    """Configures the model."""
    raise NotImplementedError()

BionemoTrainableModelConfig

Bases: Generic[ModelType, LossType], BionemoModelConfig[ModelType]

An abstract class for trainable model configuration.

Source code in bionemo/core/model/config.py
63
64
65
66
67
68
69
class BionemoTrainableModelConfig(Generic[ModelType, LossType], BionemoModelConfig[ModelType]):
    """An abstract class for trainable model configuration."""

    @abstractmethod
    def get_loss_reduction_class(self) -> Type[LossType]:
        """Returns the loss reduction class."""
        raise NotImplementedError()

get_loss_reduction_class() abstractmethod

Returns the loss reduction class.

Source code in bionemo/core/model/config.py
66
67
68
69
@abstractmethod
def get_loss_reduction_class(self) -> Type[LossType]:
    """Returns the loss reduction class."""
    raise NotImplementedError()

Model

Bases: Protocol[ModelOutput]

Lightweight interface for a model: must have a forward method.

Source code in bionemo/core/model/config.py
41
42
43
44
45
46
class Model(Protocol[ModelOutput]):
    """Lightweight interface for a model: must have a forward method."""

    def forward(self, *args, **kwargs) -> ModelOutput:
        """Prediction / forward-step for a model."""
        ...

forward(*args, **kwargs)

Prediction / forward-step for a model.

Source code in bionemo/core/model/config.py
44
45
46
def forward(self, *args, **kwargs) -> ModelOutput:
    """Prediction / forward-step for a model."""
    ...