torchoutil.nn.functional.cropping module

crop_dim(
x: Tensor,
target_length: int,
*,
dim: int = -1,
align: Literal['left', 'right', 'center', 'random'] = 'left',
generator: Generator | None | Literal['default'] | int = None,
) Tensor[source]

Generic function to crop a single dimension.

crop_dims(
x: Tensor,
target_lengths: Iterable[int],
*,
dims: Iterable[int] | Literal['auto'] = 'auto',
aligns: Literal['left', 'right', 'center', 'random'] | Iterable[Literal['left', 'right', 'center', 'random']] = 'left',
generator: Generator | None | Literal['default'] | int = None,
) Tensor[source]

Generic function to crop multiple dimensions.