GaussianMixtureModel#

class jolideco.priors.GaussianMixtureModel(means, covariances, weights, precisions_cholesky, meta=None)[source]#

Bases: Module

Gaussian mixture model

means#

Means

Type:

~torch.Tensor

covariances#

Covariances

Type:

~torch.Tensor

weights#

Weights

Type:

~torch.Tensor

precisions_cholesky#

Precision matrices

Type:

~torch.Tensor

meta#

Meta data

Type:

GaussianMixtureModelMeta

Initialize internal Module state, shared by both nn.Module and ScriptModule.

Attributes Summary

covariance_det

Covariance determinant

covariances_numpy

Covariances (~numpy.ndarray)

eigen_images

Eigen images

log_det_cholesky

Precision matrices pytorch

log_det_cholesky_numpy

Compute the log-det of the cholesky decomposition of matrices

log_weights

Log weights (~numpy.ndarray)

log_weights_numpy

Weights (~numpy.ndarray)

means_numpy

Means (~numpy.ndarray)

means_precisions_cholesky

Precision matrices pytorch

n_components

Number of features

n_features

Number of features

patch_shape

Patch shape (tuple)

pixel_weights

Pixel weights

pixel_weights_numpy

Pixel weights

precisions_cholesky_numpy

Precisions Cholesky (~numpy.ndarray)

weights_numpy

Weights (~numpy.ndarray)

Methods Summary

estimate_log_prob(x)

Compute log likelihood for given feature vector

estimate_log_prob_numpy(x)

Compute log likelihood for given feature vector

from_dict(data)

Create from dict

from_numpy(means, covariances, weights[, meta])

Gaussian mixture model

from_registry(name, **kwargs)

Create GMM from registry

from_sklearn_gmm(gmm)

Create from sklearn GMM

is_equal(other)

kl_divergence(other)

Compute KL divergence with respect to another GMM"

plot_eigen_images([ncols, figsize])

Plot images

plot_mean_images([ncols, figsize])

Plot mean images

read(filename[, format])

Read from matlab file

symmetric_kl_divergence(other)

Symmetric KL divergence

to_dict()

To dict

Attributes Documentation

covariance_det#

Covariance determinant

covariances_numpy#

Covariances (~numpy.ndarray)

eigen_images#

Eigen images

log_det_cholesky#

Precision matrices pytorch

log_det_cholesky_numpy#

Compute the log-det of the cholesky decomposition of matrices

log_weights#

Log weights (~numpy.ndarray)

log_weights_numpy#

Weights (~numpy.ndarray)

means_numpy#

Means (~numpy.ndarray)

means_precisions_cholesky#

Precision matrices pytorch

n_components#

Number of features

n_features#

Number of features

patch_shape#

Patch shape (tuple)

pixel_weights#

Pixel weights

pixel_weights_numpy#

Pixel weights

precisions_cholesky_numpy#

Precisions Cholesky (~numpy.ndarray)

weights_numpy#

Weights (~numpy.ndarray)

Methods Documentation

estimate_log_prob(x)[source]#

Compute log likelihood for given feature vector

estimate_log_prob_numpy(x)[source]#

Compute log likelihood for given feature vector

classmethod from_dict(data)[source]#

Create from dict

Parameters:

data (dict) – Data dictionary

Returns:

gmm – Gaussian mixture model

Return type:

~GaussianMixtureModel

classmethod from_numpy(means, covariances, weights, meta=None)[source]#

Gaussian mixture model

Parameters:
  • means (~numpy.ndarray) – Means

  • covariances (~numpy.ndarray) – Covariances

  • weights (~numpy.ndarray) – Weights

  • meta (GaussianMixtureModelMeta) – Meta data

Returns:

gmm – Gaussian mixture model.

Return type:

GaussianMixtureModel

classmethod from_registry(name, **kwargs)[source]#

Create GMM from registry

Parameters:

name (str) – Name of the registered GMM.

Returns:

gmm – Gaussian mixture model.

Return type:

GaussianMixtureModel

classmethod from_sklearn_gmm(gmm)[source]#

Create from sklearn GMM

is_equal(other)[source]#
kl_divergence(other)[source]#

Compute KL divergence with respect to another GMM”

See https://mr-easy.github.io/2020-04-16-kl-divergence-between-2-gaussian-distributions/

Parameters:

other (~GaussianMixtureModel) – Other GMM

Returns:

value – KL divergence

Return type:

float

plot_eigen_images(ncols=20, figsize=None)[source]#

Plot images

plot_mean_images(ncols=20, figsize=None)[source]#

Plot mean images

classmethod read(filename, format='epll-matlab', **kwargs)[source]#

Read from matlab file

Parameters:
  • filename (str or Path) – Filename

  • format ({"epll-matlab", "epll-matlab-16x16", "table"}) – Format

  • **kwargs (dict) – Keyword arguments passed to GaussianMixtureModel

Returns:

gmm – Gaussian mixture model.

Return type:

GaussianMixtureModel

symmetric_kl_divergence(other)[source]#

Symmetric KL divergence

to_dict()[source]#

To dict