espnet2.gan_tts.vits.transform.rational_quadratic_spline
About 1 min
espnet2.gan_tts.vits.transform.rational_quadratic_spline
espnet2.gan_tts.vits.transform.rational_quadratic_spline(inputs, unnormalized_widths, unnormalized_heights, unnormalized_derivatives, inverse=False, left=0.0, right=1.0, bottom=0.0, top=1.0, min_bin_width=0.001, min_bin_height=0.001, min_derivative=0.001)
Applies a rational quadratic spline transformation to the inputs.
This function computes the rational quadratic spline transformation for a given set of inputs based on specified widths, heights, and derivatives. The transformation can be performed in both forward and inverse directions based on the inverse parameter.
- Parameters:
- inputs (torch.Tensor) – The input tensor to be transformed.
- unnormalized_widths (torch.Tensor) – The unnormalized widths of the bins.
- unnormalized_heights (torch.Tensor) – The unnormalized heights of the bins.
- unnormalized_derivatives (torch.Tensor) – The unnormalized derivatives at the bin edges.
- inverse (bool , optional) – If True, performs the inverse transformation. Defaults to False.
- left (float , optional) – The left boundary of the input range. Defaults to 0.0.
- right (float , optional) – The right boundary of the input range. Defaults to 1.0.
- bottom (float , optional) – The bottom boundary of the output range. Defaults to 0.0.
- top (float , optional) – The top boundary of the output range. Defaults to 1.0.
- min_bin_width (float , optional) – The minimum allowed width for the bins. Defaults to 1e-3.
- min_bin_height (float , optional) – The minimum allowed height for the bins. Defaults to 1e-3.
- min_derivative (float , optional) – The minimum allowed derivative value. Defaults to 1e-3.
- Returns: A tuple containing: : - outputs (torch.Tensor): The transformed output tensor.
- logabsdet (torch.Tensor): The log absolute determinant of the transformation.
- Return type: tuple
- Raises:ValueError – If the input is not within the specified domain or if the minimal bin width or height is too large for the number of bins.
Examples
>>> inputs = torch.tensor([0.1, 0.5, 0.9])
>>> widths = torch.tensor([[0.1, 0.2], [0.1, 0.2], [0.1, 0.2]])
>>> heights = torch.tensor([[0.3, 0.4], [0.3, 0.4], [0.3, 0.4]])
>>> derivatives = torch.tensor([[0.1, 0.1], [0.1, 0.1], [0.1, 0.1]])
>>> outputs, logabsdet = rational_quadratic_spline(inputs, widths,
... heights, derivatives)
>>> print(outputs)
>>> print(logabsdet)
NOTE
The implementation relies on the properties of rational quadratic splines, which can be beneficial in various applications such as normalizing flows in generative models.