ssspy.bss.cacgmm#

Algorithms#

class ssspy.bss.cacgmm.CACGMM(n_sources=None, flooring_fn=functools.partial(<function max_flooring>, eps=1e-10), callbacks=None, normalization=True, permutation_alignment=True, record_loss=True, reference_id=0, rng=None, **kwargs)#

Complex angular central Gaussian mixture model (cACGMM) [1].

Parameters:
  • n_sources (int, optional) – Number of sources to be separated. If None is given, n_sources is determined by number of channels in input spectrogram. Default: None.

  • flooring_fn (callable, optional) – A flooring function for numerical stability. This function is expected to return the same shape tensor as the input. If you explicitly set flooring_fn=None, the identity function (lambda x: x) is used.

  • callbacks (callable or list[callable], optional) – Callback functions. Each function is called before separation and at each iteration. Default: None.

  • normalization (bool) – If True is given, normalization is applied to covariance in cACG.

  • permutation_alignment (bool) – If permutation_alignment=True, a permutation solver is used to align estimated spectrograms. Default: True.

  • record_loss (bool) – Record the loss at each iteration of the update algorithm if record_loss=True. Default: True.

  • reference_id (int) – Reference channel to extract separated signals. Default: 0.

  • rng (numpy.random.Generator, optioinal) – Random number generator. This is mainly used to randomly initialize parameters of cACGMM. If None is given, np.random.default_rng() is used. Default: None.

__call__(input, n_iter=100, initial_call=True, **kwargs)#

Separate a frequency-domain multichannel signal.

Parameters:
  • input (numpy.ndarray) – The mixture signal in frequency-domain. The shape is (n_channels, n_bins, n_frames).

  • n_iter (int) – The number of iterations of demixing filter updates. Default: 100.

  • initial_call (bool) – If True, perform callbacks (and computation of loss if necessary) before iterations.

Return type:

ndarray

Returns:

numpy.ndarray of the separated signal in frequency-domain. The shape is (n_channels, n_bins, n_frames).

compute_loss()#

Compute loss of cACGMM \(\mathcal{L}\).

\(\mathcal{L}\) is defined as follows: :rtype: float

\[\mathcal{L} = -\frac{1}{J}\sum_{i,j}\log\left( \sum_{n}\frac{\alpha_{in}}{\det\boldsymbol{B}_{in}} \frac{1}{(\boldsymbol{z}_{ij}^{\mathsf{H}}\boldsymbol{B}_{in}^{-1}\boldsymbol{z}_{ij})^{M}} \right).\]
normalize_covariance()#

Normalize covariance of cACG. :rtype: None

\[\boldsymbol{B}_{in} \leftarrow\frac{\boldsymbol{B}_{in}}{\mathrm{tr}(\boldsymbol{B}_{in})}\]
separate(input, posterior=None)#

Separate input using posterior probabilities.

In this method, self.posterior is not updated.

Parameters:
  • input (numpy.ndarray) – The mixture signal in frequency-domain. The shape is (n_channels, n_bins, n_frames).

  • posterior (numpy.ndarray, optional) – Posterior probability. If not specified, posterior is computed by current parameters.

Return type:

ndarray

Returns:

numpy.ndarray of the separated signal in frequency-domain. The shape is (n_sources, n_bins, n_frames).

solve_permutation(flooring_fn='self')#

Align posteriors and separated spectrograms.

Parameters:

flooring_fn (callable or str, optional) – A flooring function for numerical stability. This function is expected to return the same shape tensor as the input. If you explicitly set flooring_fn=None, the identity function (lambda x: x) is used. If self is given as str, self.flooring_fn is used. Default: self.

Return type:

None

update_once(flooring_fn='self')#

Perform E and M step once.

In update_posterior, posterior probabilities are updated, which corresponds to E step. In update_parameters, parameters of cACGMM are updated, which corresponds to M step.

Parameters:

flooring_fn (callable or str, optional) – A flooring function for numerical stability. This function is expected to return the same shape tensor as the input. If you explicitly set flooring_fn=None, the identity function (lambda x: x) is used. If self is given as str, self.flooring_fn is used. Default: self.

Return type:

None

update_parameters(flooring_fn='self')#

Update parameters of mixture of complex angular central Gaussian distributions.

This method corresponds to M step in EM algorithm for cACGMM.

Parameters:

flooring_fn (callable or str, optional) – A flooring function for numerical stability. This function is expected to return the same shape tensor as the input. If you explicitly set flooring_fn=None, the identity function (lambda x: x) is used. If self is given as str, self.flooring_fn is used. Default: self.

Return type:

None

update_posterior(flooring_fn='self')#

Update posteriors.

This method corresponds to E step in EM algorithm for cACGMM.

Parameters:

flooring_fn (callable or str, optional) – A flooring function for numerical stability. This function is expected to return the same shape tensor as the input. If you explicitly set flooring_fn=None, the identity function (lambda x: x) is used. If self is given as str, self.flooring_fn is used. Default: self.

Return type:

None