espnet2.gan_tts.vits.transform.piecewise_rational_quadratic_transform
espnet2.gan_tts.vits.transform.piecewise_rational_quadratic_transform
espnet2.gan_tts.vits.transform.piecewise_rational_quadratic_transform(inputs, unnormalized_widths, unnormalized_heights, unnormalized_derivatives, inverse=False, tails=None, tail_bound=1.0, min_bin_width=0.001, min_bin_height=0.001, min_derivative=0.001)
Applies a piecewise rational quadratic transformation to the input data.
This transformation is useful for creating flexible, piecewise-defined functions that can model complex distributions. It utilizes the concept of rational quadratic splines to perform the transformation, allowing for both forward and inverse operations.
espnet2.gan_tts.vits.transform.DEFAULT_MIN_BIN_WIDTH
Default minimum width for bins.
- Type: float
espnet2.gan_tts.vits.transform.DEFAULT_MIN_BIN_HEIGHT
Default minimum height for bins.
- Type: float
espnet2.gan_tts.vits.transform.DEFAULT_MIN_DERIVATIVE
Default minimum derivative value.
Type: float
Parameters:
- inputs (torch.Tensor) – The input tensor to transform.
- unnormalized_widths (torch.Tensor) – Unnormalized widths for the spline bins.
- unnormalized_heights (torch.Tensor) – Unnormalized heights for the spline bins.
- unnormalized_derivatives (torch.Tensor) – Unnormalized derivatives for the spline bins.
- inverse (bool , optional) – If True, applies the inverse transformation. Defaults to False.
- tails (str or None , optional) – Defines the behavior of the tails of the spline. If None, a rational quadratic spline is used. If ‘linear’, linear tails are applied. Defaults to None.
- tail_bound (float , optional) – The boundary for the tails. Defaults to 1.0.
- min_bin_width (float , optional) – Minimum allowable width for bins. Defaults to DEFAULT_MIN_BIN_WIDTH.
- min_bin_height (float , optional) – Minimum allowable height for bins. Defaults to DEFAULT_MIN_BIN_HEIGHT.
- min_derivative (float , optional) – Minimum allowable derivative value. Defaults to DEFAULT_MIN_DERIVATIVE.
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 tensor is outside the domain defined by the spline or if the minimum bin dimensions are not feasible.
Examples
>>> inputs = torch.tensor([0.1, 0.5, 0.9])
>>> unnormalized_widths = torch.tensor([[0.1, 0.2], [0.2, 0.3]])
>>> unnormalized_heights = torch.tensor([[0.5, 0.6], [0.6, 0.7]])
>>> unnormalized_derivatives = torch.tensor([[0.01, 0.02], [0.02, 0.03]])
>>> outputs, logabsdet = piecewise_rational_quadratic_transform(
... inputs, unnormalized_widths, unnormalized_heights,
... unnormalized_derivatives, inverse=False
... )