cdist#

class diffsptk.CepstralDistance(full=False, reduction='mean', eps=1e-08)[source]#

See this page for details.

Parameters:
fullbool [scalar]

If True, include the constant term in the distance calculation.

reduction[‘none’, ‘mean’, ‘batchmean’, ‘sum’]

Reduction type.

epsfloat >= 0 [scalar]

A small value to prevent NaN.

forward(c1, c2)[source]#

Calculate cepstral distance between two inputs.

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

Input cepstral coefficients.

c2Tensor [shape=(…, M+1)]

Target cepstral coefficients.

Returns:
distanceTensor [shape=(…,) or scalar]

Cepstral distance.

Examples

>>> c1 = diffsptk.nrand(2, 2)
tensor([[ 0.4296,  1.6517, -0.6022],
        [-1.0464, -0.6088, -0.9274]])
>>> c2 = diffsptk.nrand(2, 2)
tensor([[ 1.6441, -0.6962, -0.2524],
        [ 0.9344,  0.3965,  1.1494]])
>>> cdist = diffsptk.CepstralDistance()
>>> distance = cdist(c1, c2)
>>> distance
tensor(1.6551)

See also

fftcep