nussl/ml/unfold/gaussian_mixture.py
def _e_step(X, means, covariance):
        """
        Takes the expectation of X. Returns the log probability of X under each
        Gaussian in the mixture model.
        
        Args:
            X (torch.Tensor): Data, shape (n_batch, n_samples, n_features)
            means (torch.Tensor): Means, shape (n_batch, n_components, n_features)
            covariance (torch.Tensor): (n_batch, n_components, n_features, n_features)
        """
        n_batch, n_samples, n_features = X.shape
        _, n_components, _ = means.shape

        X = X.view(n_batch, n_samples, 1, n_features)
        means = means.view(n_batch, 1, n_components, n_features)
        covariance = covariance.view(
            n_batch, 1, n_components, n_features, n_features)

        mvn = gpytorch.distributions.MultivariateNormal(
            means, covariance_matrix=covariance
        )
        log_prob = mvn.log_prob(X)
        prob = torch.exp(log_prob) + 1e-8
        resp = nn.functional.normalize(prob, p=1, dim=-1)
        return resp, log_prob

        Takes the expectation of X. Returns the log probability of X under each
        Gaussian in the mixture model.
        
        Args:
            X (torch.Tensor): Data, shape (n_batch, n_samples, n_features)
            means (torch.Tensor): Means, shape (n_batch, n_components, n_features)
            covariance (torch.Tensor): (n_batch, n_components, n_features, n_features)
        
Takes the expectation of X. Returns the log probability of X under each
Gaussian in the mixture model.
Takes the expectation of X . Returns the log probability of X under each Gaussian in the mixture model .
def _e_step(X, means, covariance):
        n_batch, n_samples, n_features = X.shape
        _, n_components, _ = means.shape
        X = X.view(n_batch, n_samples, 1, n_features)
        means = means.view(n_batch, 1, n_components, n_features)
        covariance = covariance.view(
            n_batch, 1, n_components, n_features, n_features)
        mvn = gpytorch.distributions.MultivariateNormal(
            means, covariance_matrix=covariance
        )
        log_prob = mvn.log_prob(X)
        prob = torch.exp(log_prob) + 1e-8
        resp = nn.functional.normalize(prob, p=1, dim=-1)
        return resp, log_prob
def _e_step ( X , means , covariance ) : n_batch , n_samples , n_features = X . shape _ , n_components , _ = means . shape X = X . view ( n_batch , n_samples , 1 , n_features ) means = means . view ( n_batch , 1 , n_components , n_features ) covariance = covariance . view ( n_batch , 1 , n_components , n_features , n_features ) mvn = gpytorch . distributions . MultivariateNormal ( means , covariance_matrix = covariance ) log_prob = mvn . log_prob ( X ) prob = torch . exp ( log_prob ) + 1e-8 resp = nn . functional . normalize ( prob , p = 1 , dim = - 1 ) return resp , log_prob
Takes the expectation of X.
Takes the expectation of X .
"""
        Takes the expectation of X. Returns the log probability of X under each
        Gaussian in the mixture model.
        
        Args:
            X (torch.Tensor): Data, shape (n_batch, n_samples, n_features)
            means (torch.Tensor): Means, shape (n_batch, n_components, n_features)
            covariance (torch.Tensor): (n_batch, n_components, n_features, n_features)
        """
X
Data, shape (n_batch, n_samples, n_features)
Data shape ( n_batch n_samples n_features )
means
Means, shape (n_batch, n_components, n_features)
Means shape ( n_batch n_components n_features )
covariance
None