espnet2.tts.feats_extract.yin.cumulativeMeanNormalizedDifferenceFunction
Less than 1 minute
espnet2.tts.feats_extract.yin.cumulativeMeanNormalizedDifferenceFunction
espnet2.tts.feats_extract.yin.cumulativeMeanNormalizedDifferenceFunction(df, N, eps=1e-08)
Compute cumulative mean normalized difference function (CMND).
This function computes the cumulative mean normalized difference function based on the provided difference function. This corresponds to equation (8) in [1]. The computation accounts for a small epsilon value to avoid division by zero.
- Parameters:
- df (torch.Tensor) – The difference function, expected to be a 2D tensor where the first dimension corresponds to the batch size and the second dimension corresponds to the difference values.
- N (int) – The length of the data, which influences the range of calculations.
- eps (float , optional) – A small constant added to the denominator to prevent division by zero. Defaults to 1e-8.
- Returns: The cumulative mean normalized difference function, : which is a tensor of the same batch size as the input difference function, with an additional leading dimension of ones.
- Return type: torch.Tensor
Examples
>>> df = torch.tensor([[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]])
>>> N = 3
>>> cmnd = cumulativeMeanNormalizedDifferenceFunction(df, N)
>>> print(cmnd)
tensor([[1.0000, 0.3333, 0.5000],
[1.0000, 0.8000, 0.6000]])
NOTE
Ensure that the input difference function df contains valid values, as the calculation assumes that df will not lead to division by zero aside from the safeguard provided by eps.
- Raises:
- ValueError – If the shape of df is not 2D or if N is not
- a positive integer. –