espnet2.gan_tts.vits.transform.unconstrained_rational_quadratic_spline
espnet2.gan_tts.vits.transform.unconstrained_rational_quadratic_spline
espnet2.gan_tts.vits.transform.unconstrained_rational_quadratic_spline(inputs, unnormalized_widths, unnormalized_heights, unnormalized_derivatives, inverse=False, tails='linear', tail_bound=1.0, min_bin_width=0.001, min_bin_height=0.001, min_derivative=0.001)
Unconstrained Rational Quadratic Spline Transformation.
This function implements an unconstrained rational quadratic spline for transformation, which can be used in various applications, such as normalizing flows. The transformation allows for flexible mapping of inputs to outputs while maintaining differentiability.
espnet2.gan_tts.vits.transform.inputs
The input tensor to be transformed.
- Type: torch.Tensor
espnet2.gan_tts.vits.transform.unnormalized_widths
The unnormalized widths for the spline bins.
- Type: torch.Tensor
espnet2.gan_tts.vits.transform.unnormalized_heights
The unnormalized heights for the spline bins.
- Type: torch.Tensor
espnet2.gan_tts.vits.transform.unnormalized_derivatives
The unnormalized derivatives at the spline knots.
- Type: torch.Tensor
espnet2.gan_tts.vits.transform.inverse
If True, performs the inverse transformation.
- Type: bool
espnet2.gan_tts.vits.transform.tails
Specifies the behavior of the tails; default is “linear”.
- Type: str
espnet2.gan_tts.vits.transform.tail_bound
The bounds for the tails of the spline.
- Type: float
espnet2.gan_tts.vits.transform.min_bin_width
The minimum allowed width of the spline bins.
- Type: float
espnet2.gan_tts.vits.transform.min_bin_height
The minimum allowed height of the spline bins.
- Type: float
espnet2.gan_tts.vits.transform.min_derivative
The minimum allowed derivative for the spline.
Type: float
Parameters:
- inputs (torch.Tensor) – The input values to be transformed.
- unnormalized_widths (torch.Tensor) – Unnormalized widths of the spline.
- unnormalized_heights (torch.Tensor) – Unnormalized heights of the spline.
- unnormalized_derivatives (torch.Tensor) – Unnormalized derivatives at the spline knots.
- inverse (bool , optional) – If True, apply the inverse transformation. Defaults to False.
- tails (str , optional) – Specifies the behavior of the tails. Defaults to “linear”.
- tail_bound (float , optional) – Bound for the tails. Defaults to 1.0.
- min_bin_width (float , optional) – Minimum bin width. Defaults to DEFAULT_MIN_BIN_WIDTH.
- min_bin_height (float , optional) – Minimum bin height. Defaults to DEFAULT_MIN_BIN_HEIGHT.
- min_derivative (float , optional) – Minimum derivative. Defaults to DEFAULT_MIN_DERIVATIVE.
Returns: A tuple containing: : - outputs (torch.Tensor): The transformed output values.
- logabsdet (torch.Tensor): The log absolute determinant of the Jacobian of the transformation.
Return type: tuple
Raises:RuntimeError – If the specified tails are not implemented.
Examples
>>> inputs = torch.tensor([0.5, 0.6])
>>> widths = torch.tensor([[0.1, 0.2], [0.1, 0.2]])
>>> heights = torch.tensor([[0.5, 0.5], [0.5, 0.5]])
>>> derivatives = torch.tensor([[0.1, 0.1], [0.1, 0.1]])
>>> outputs, logabsdet = unconstrained_rational_quadratic_spline(
... inputs, widths, heights, derivatives
... )
NOTE
The function assumes that the input tensors are properly shaped and compatible with each other.