espnet2.layers.time_warp.time_warp
Less than 1 minute
espnet2.layers.time_warp.time_warp
espnet2.layers.time_warp.time_warp(x: Tensor, window: int = 80, mode: str = 'bicubic')
Time warp module.
This module provides functions and classes for performing time warping on tensor data using PyTorch’s interpolation capabilities.
The time_warp function applies a time warping effect to the input tensor x based on the specified window size and interpolation mode. The TimeWarp class encapsulates this functionality, allowing for easy integration into neural network models.
espnet2.layers.time_warp.DEFAULT_TIME_WARP_MODE
The default interpolation mode, set to
- Type: str
"bicubic".
- Parameters:
- x (torch.Tensor) – Input tensor of shape (Batch, Time, Freq).
- window (int) – Time warp parameter that defines the range of the warp.
- 80. (Default is)
- mode (str) – Interpolation mode to be used for warping. Default is
- DEFAULT_TIME_WARP_MODE.
- Returns: The time-warped tensor of the same shape as the input.
- Return type: torch.Tensor
- Raises:ValueError – If the input tensor does not have at least 3 dimensions.
Examples
>>> import torch
>>> x = torch.rand(2, 100, 64) # (Batch, Time, Freq)
>>> warped_x = time_warp(x, window=50, mode='linear')
>>> time_warp_layer = TimeWarp(window=50, mode='linear')
>>> output, lengths = time_warp_layer(x)
NOTE
Bicubic interpolation supports tensors with 4 or more dimensions.