lbg#

diffsptk.LBG#

alias of LindeBuzoGrayAlgorithm

class diffsptk.LindeBuzoGrayAlgorithm(order, codebook_size, min_data_per_cluster=1, n_iter=100, eps=1e-05, perturb_factor=1e-05, verbose=False)[source]#

See this page for details. This module is not differentiable.

orderint >= 0 [scalar]

Order of vector.

codebook_sizeint >= 1 [scalar]

Target codebook size, must be power of two.

min_data_per_clusterint >= 1 [scalar]

Minimum number of data points in a cluster.

n_iterint >= 1 [scalar]

Number of iterations.

epsfloat >= 0 [scalar]

Convergence threshold.

perturb_factorfloat > 0 [scalar]

Perturbation factor.

verbosebool [scalar]

If True, print progress.

forward(x)[source]#

Design a codebook.

Parameters:
xTensor [shape=(…, M+1)]

Input vectors.

Returns:
codebookTensor [shape=(K, M+1)]

Codebook.

indicesTensor [shape=(…,)]

Codebook indices.

distanceTensor [scalar]

Distance.

Examples

>>> x = diffsptk.nrand(10, 0)
>>> lbg = diffsptk.LBG(0, 2)
>>> codebook, indices, distance = lbg(x)
>>> codebook
tensor([[-0.5277],
        [ 0.6747]])
>>> indices
tensor([0, 0, 0, 1, 0, 1, 1, 1, 1, 0])
>>> distance
tensor(0.2331)

See also

vq ivq gmm