add_pad
- colibri.optics.functional.add_pad(x, pad)[source]
Add zero padding to a tensor.
Note
pad object 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 add on each side of the corresponding dimension in x.
- Parameters:
x (torch.Tensor) – Tensor to pad
list (pad) – padding to ad
pad (list)
- Returns:
Padded tensor
- Return type:
x (torch.Tensor)
Example
>>> x = torch.tensor([[1, 2], [3, 4]]) >>> add_pad(x, [1, 1]) tensor([[0, 0, 0, 0], [0, 1, 2, 0], [0, 3, 4, 0], [0, 0, 0, 0]])