Skip to content

Distribution

DiscretePriorDistribution

Bases: PriorDistribution

An abstract base class representing a discrete prior distribution.

Source code in bionemo/moco/distributions/prior/distribution.py
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class DiscretePriorDistribution(PriorDistribution):
    """An abstract base class representing a discrete prior distribution."""

    def __init__(self, num_classes: int, prior_dist: Tensor):
        """Initializes a DiscretePriorDistribution instance.

        Args:
        num_classes (int): The number of classes in the discrete distribution.
        prior_dist (Tensor): The prior distribution over the classes.

        Returns:
        None
        """
        self.num_classes = num_classes
        self.prior_dist = prior_dist

    def get_num_classes(self) -> int:
        """Getter for num_classes."""
        return self.num_classes

    def get_prior_dist(self) -> Tensor:
        """Getter for prior_dist."""
        return self.prior_dist

__init__(num_classes, prior_dist)

Initializes a DiscretePriorDistribution instance.

Args: num_classes (int): The number of classes in the discrete distribution. prior_dist (Tensor): The prior distribution over the classes.

Returns: None

Source code in bionemo/moco/distributions/prior/distribution.py
45
46
47
48
49
50
51
52
53
54
55
56
def __init__(self, num_classes: int, prior_dist: Tensor):
    """Initializes a DiscretePriorDistribution instance.

    Args:
    num_classes (int): The number of classes in the discrete distribution.
    prior_dist (Tensor): The prior distribution over the classes.

    Returns:
    None
    """
    self.num_classes = num_classes
    self.prior_dist = prior_dist

get_num_classes()

Getter for num_classes.

Source code in bionemo/moco/distributions/prior/distribution.py
58
59
60
def get_num_classes(self) -> int:
    """Getter for num_classes."""
    return self.num_classes

get_prior_dist()

Getter for prior_dist.

Source code in bionemo/moco/distributions/prior/distribution.py
62
63
64
def get_prior_dist(self) -> Tensor:
    """Getter for prior_dist."""
    return self.prior_dist

PriorDistribution

Bases: ABC

An abstract base class representing a prior distribution.

Source code in bionemo/moco/distributions/prior/distribution.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class PriorDistribution(ABC):
    """An abstract base class representing a prior distribution."""

    @abstractmethod
    def sample(self, shape: Tuple, mask: Optional[Tensor] = None, device: Union[str, torch.device] = "cpu") -> Tensor:
        """Generates a specified number of samples from the time distribution.

        Args:
        shape (Tuple): The shape of the samples to generate.
        mask (Optional[Tensor], optional): A tensor indicating which samples should be masked. Defaults to None.
        device (str, optional): The device on which to generate the samples. Defaults to "cpu".

        Returns:
            Float: A tensor of samples.
        """
        pass

sample(shape, mask=None, device='cpu') abstractmethod

Generates a specified number of samples from the time distribution.

Args: shape (Tuple): The shape of the samples to generate. mask (Optional[Tensor], optional): A tensor indicating which samples should be masked. Defaults to None. device (str, optional): The device on which to generate the samples. Defaults to "cpu".

Returns:

Name Type Description
Float Tensor

A tensor of samples.

Source code in bionemo/moco/distributions/prior/distribution.py
27
28
29
30
31
32
33
34
35
36
37
38
39
@abstractmethod
def sample(self, shape: Tuple, mask: Optional[Tensor] = None, device: Union[str, torch.device] = "cpu") -> Tensor:
    """Generates a specified number of samples from the time distribution.

    Args:
    shape (Tuple): The shape of the samples to generate.
    mask (Optional[Tensor], optional): A tensor indicating which samples should be masked. Defaults to None.
    device (str, optional): The device on which to generate the samples. Defaults to "cpu".

    Returns:
        Float: A tensor of samples.
    """
    pass