How to Pad the Input Tensor Boundaries with Zero in PyTorch
In this article, we will discuss how to pad the input tensor boundaries with zero in Python using PyTorch.
This method has accepted the size of padding as input and returns a new tensor with boundaries. The boundaries may be the same or different from all sides (left, right, top, bottom). we can increase the height and width of a padded tensor by using top+bottom and left+right respectively. The below syntax is used to pad the input tensor boundaries with zero.
- pad (int, tuple): This is size of padding. The size of padding is an integer or a tuple.
Return: This method returns a new tensor with boundaries.
In this example, we will see how to pad the input tensor boundaries with zero.
In this example, we will see how to add unique padding sizes to all sides.
My Personal Notes arrow_drop_up
Please Login to comment...