squeeze¶
- dragon.vm.torch.- squeeze(
 input,
 dim=None,
 out=None
 )[source]¶
- Remove the dimensions of input with size 1. - The argument - dimcould be negative or None:- x = torch.ones(1, 2, 2, 1) # Remove all matched dimensions if ``axis`` is None # Otherwise, only the specified axes will be removed print(torch.squeeze(x).shape) # (1, 2, 2, 1) -> (2, 2) print(torch.squeeze(x, dim=0).shape) # (1, 2, 2, 1) -> (2, 2, 1) # A negative dimension is the last-k dimension print(torch.squeeze(x, dim=3).shape) # (1, 2, 2, 1) -> (1, 2, 2) print(torch.squeeze(x, dim=-1).shape) # Equivalent # Also, ``axis`` could be a sequence of integers print(torch.squeeze(x, dim=[0, 3]).shape) # (1, 2, 2, 1) -> (2, 2) - Parameters:
- input (dragon.vm.torch.Tensor) – The input tensor.
- dim (Union[int, Sequence[int]], optional) – The dimension(s) to remove.
- out (dragon.vm.torch.Tensor, optional) – The output tensor.
 
 - Returns:
- dragon.vm.torch.Tensor – The new tensor. 
 
