跳到内容

Config

LossType = TypeVar('LossType') module-attribute

损失函数的占位符;无约束。

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

模型的正向传播可能产生张量、多个张量或命名张量。

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

具有正向传播的事物的通用类型。

BionemoModelConfig

基类: Generic[ModelType], ABC

模型配置的抽象类。

源代码在 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

配置模型。

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

BionemoTrainableModelConfig

基类: Generic[ModelType, LossType], BionemoModelConfig[ModelType]

可训练模型配置的抽象类。

源代码在 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

返回损失缩减类。

源代码在 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

基类: Protocol[ModelOutput]

模型的轻量级接口:必须具有 forward 方法。

源代码在 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)

模型的预测/前向步骤。

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