unpad
- colibri.optics.functional.unpad(x, pad)[source]
Unpad a tensor.
Note
pad is a list of the same length as the number of dimensions of the tensor x
each element of the pad list is a integer, specifying the amount of padding to remove on each side of the corresponding dimension in x.
- Parameters:
x (torch.Tensor) – Tensor to unpad
int (pad) – padding to remove
pad (list)
- Returns:
Unpadded tensor
- Return type:
x (torch.Tensor)
Example
>>> x = torch.tensor([[0, 0, 0, 0],[0, 1, 2, 0],[0, 3, 4, 0],[0, 0, 0, 0]]) >>> unpad(x, [1, 1]) tensor([[1, 2], [3, 4]])