ertk.pytorch.utils.frame_tensor

ertk.pytorch.utils.frame_tensor(x: Tensor, frame_size: int, frame_shift: int, pad: bool = False, axis: int = 0) Tensor

Frames an array over a given axis with optional padding and copying.

Parameters:
x: torch.Tensor

Array to frame.

frame_size: int

Width of frame.

frame_shift: int

Amount each window is moved for subsequent frames.

pad: bool

If the frames don’t neatly fit the axis length, this indicated whether to pad or cut the remaining length. Default is False which means any remaining length is cut. If pad=True then any remaining length is padded with zeros and an additional frame is produced. If frames neatly fit into the axis length then this option has no effect.

axis: int

Axis to frame over. Default is 0.

Returns:
frames: torch.Tensor

The resulting frames.