/usr/local/lib64/python3.6/site-packages/torch/nn/modules/__pycache__
Edit: /usr/local/lib64/python3.6/site-packages/torch/nn/modules/__pycache__/padding.cpython-36.pyc (22217B)
3
EgK @ s0 d dl mZ d dlmZmZmZ ddlmZ ddl m
Z
ddlmZm
Z
mZ ddlmZmZ G d d
d
eZG dd deZG d
d deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd d eZG d!d" d"eZd#S )$ )Module)_pair
_quadruple_ntuple )
functional )Tensor) _size_2_t _size_4_t _size_6_t)SequenceTuplec sX e Zd ZU ddgZeee edd fddZ e
e
ddd Zed
ddZ
ZS )
_ConstantPadNdpaddingvalueN)r returnc s t t| j || _d S )N)superr __init__r )selfr ) __class__ D/usr/local/lib64/python3.6/site-packages/torch/nn/modules/padding.pyr s z_ConstantPadNd.__init__)inputr c C s t j|| jd| jS )NZconstant)Fpadr r )r r r r r forward s z_ConstantPadNd.forward)r c C s dj | j| jS )Nzpadding={}, value={})formatr r )r r r r
extra_repr s z_ConstantPadNd.extra_repr)__name__
__module____qualname__
__constants__floatr r
intr r r r strr
__classcell__r r )r r r
s
r c s6 e Zd ZU dZeeef eed fddZ Z
S )
ConstantPad1da Pads the input tensor boundaries with a constant value.
For `N`-dimensional padding, use :func:`torch.nn.functional.pad()`.
Args:
padding (int, tuple): the size of the padding. If is `int`, uses the same
padding in both boundaries. If a 2-`tuple`, uses
(:math:`\text{padding\_left}`, :math:`\text{padding\_right}`)
Shape:
- Input: :math:`(C, W_{in})` or :math:`(N, C, W_{in})`.
- Output: :math:`(C, W_{out})` or :math:`(N, C, W_{out})`, where
:math:`W_{out} = W_{in} + \text{padding\_left} + \text{padding\_right}`
Examples::
>>> m = nn.ConstantPad1d(2, 3.5)
>>> input = torch.randn(1, 2, 4)
>>> input
tensor([[[-1.0491, -0.7152, -0.0749, 0.8530],
[-1.3287, 1.8966, 0.1466, -0.2771]]])
>>> m(input)
tensor([[[ 3.5000, 3.5000, -1.0491, -0.7152, -0.0749, 0.8530, 3.5000,
3.5000],
[ 3.5000, 3.5000, -1.3287, 1.8966, 0.1466, -0.2771, 3.5000,
3.5000]]])
>>> m = nn.ConstantPad1d(2, 3.5)
>>> input = torch.randn(1, 2, 3)
>>> input
tensor([[[ 1.6616, 1.4523, -1.1255],
[-3.6372, 0.1182, -1.8652]]])
>>> m(input)
tensor([[[ 3.5000, 3.5000, 1.6616, 1.4523, -1.1255, 3.5000, 3.5000],
[ 3.5000, 3.5000, -3.6372, 0.1182, -1.8652, 3.5000, 3.5000]]])
>>> # using different paddings for different sides
>>> m = nn.ConstantPad1d((3, 1), 3.5)
>>> m(input)
tensor([[[ 3.5000, 3.5000, 3.5000, 1.6616, 1.4523, -1.1255, 3.5000],
[ 3.5000, 3.5000, 3.5000, -3.6372, 0.1182, -1.8652, 3.5000]]])
)r r c s t t| j| t|| _d S )N)r r' r r r )r r r )r r r r J s zConstantPad1d.__init__)r r r! __doc__r r$ r r
r# r r&