/usr/local/lib64/python3.6/site-packages/torch/nn/modules/__pycache__
NameSizeModeActions
activation.cpython-36.pyc476350644editdlrm
adaptive.cpython-36.pyc97250644editdlrm
batchnorm.cpython-36.pyc310390644editdlrm
channelshuffle.cpython-36.pyc19010644editdlrm
container.cpython-36.pyc279700644editdlrm
conv.cpython-36.pyc577890644editdlrm
distance.cpython-36.pyc36840644editdlrm
dropout.cpython-36.pyc103100644editdlrm
flatten.cpython-36.pyc58130644editdlrm
fold.cpython-36.pyc128070644editdlrm
instancenorm.cpython-36.pyc188080644editdlrm
lazy.cpython-36.pyc116900644editdlrm
linear.cpython-36.pyc101880644editdlrm
loss.cpython-36.pyc914650644editdlrm
module.cpython-36.pyc665300644editdlrm
normalization.cpython-36.pyc113600644editdlrm
padding.cpython-36.pyc222170644editdlrm
pixelshuffle.cpython-36.pyc43980644editdlrm
pooling.cpython-36.pyc532030644editdlrm
rnn.cpython-36.pyc446530644editdlrm
sparse.cpython-36.pyc209560644editdlrm
transformer.cpython-36.pyc207370644editdlrm
upsampling.cpython-36.pyc107800644editdlrm
utils.cpython-36.pyc25280644editdlrm
_functions.cpython-36.pyc54410644editdlrm
__init__.cpython-36.pyc52360644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/nn/modules/__pycache__/normalization.cpython-36.pyc (11360B)
3 ûEgþ)ã@sÆddlZddlZddlmZddlmZddlmZddl m Z ddl m Z dd lm Z mZdd lmZmZmZGd d „d eƒZGd d„deƒZeeeeefZGdd„deƒZGdd„deƒZdS)éN)Ú Parameteré)ÚModule)Ú CrossMapLRN2dé)Ú functional)Úinit)ÚTensorÚSize)ÚUnionÚListÚTuplecsfeZdZUdZddddgZeee e deeeed d œ‡fd d „ Z e e d œdd„Z dd„Z‡ZS)ÚLocalResponseNormauApplies local response normalization over an input signal composed of several input planes, where channels occupy the second dimension. Applies normalization across channels. .. math:: b_{c} = a_{c}\left(k + \frac{\alpha}{n} \sum_{c'=\max(0, c-n/2)}^{\min(N-1,c+n/2)}a_{c'}^2\right)^{-\beta} Args: size: amount of neighbouring channels used for normalization alpha: multiplicative factor. Default: 0.0001 beta: exponent. Default: 0.75 k: additive factor. Default: 1 Shape: - Input: :math:`(N, C, *)` - Output: :math:`(N, C, *)` (same shape as input) Examples:: >>> lrn = nn.LocalResponseNorm(2) >>> signal_2d = torch.randn(32, 5, 24, 24) >>> signal_4d = torch.randn(16, 5, 7, 7, 7, 7) >>> output_2d = lrn(signal_2d) >>> output_4d = lrn(signal_4d) ÚsizeÚalphaÚbetaÚkç-Cëâ6?çè?çð?N)rrrrÚreturncs*tt|ƒjƒ||_||_||_||_dS)N)ÚsuperrÚ__init__rrrr)Úselfrrrr)Ú __class__©úJ/usr/local/lib64/python3.6/site-packages/torch/nn/modules/normalization.pyr/s zLocalResponseNorm.__init__)ÚinputrcCstj||j|j|j|jƒS)N)ÚFZlocal_response_normrrrr)rrrrrÚforward6szLocalResponseNorm.forwardcCsdjf|jŽS)Nz){size}, alpha={alpha}, beta={beta}, k={k})ÚformatÚ__dict__)rrrrÚ extra_repr:szLocalResponseNorm.extra_repr)rrr)Ú__name__Ú __module__Ú __qualname__Ú__doc__Ú __constants__ÚintrÚfloatrrrrr rr"Ú __classcell__rr)rrr s  rcs\eZdZUeeeedeeeeddœ‡fdd„ Z e e dœd d „Z e d œd d „Z ‡ZS)rç-Cëâ6?çè?rN)rrrrrcs*tt|ƒjƒ||_||_||_||_dS)N)rrrrrrr)rrrrr)rrrrDs zCrossMapLRN2d.__init__)rrcCstj||j|j|j|jƒS)N)Ú_cross_map_lrn2dÚapplyrrrr)rrrrrrKszCrossMapLRN2d.forward)rcCsdjf|jŽS)Nz){size}, alpha={alpha}, beta={beta}, k={k})r r!)rrrrr"OszCrossMapLRN2d.extra_repr)r+r,r)r#r$r%r(rr)rrrrr rÚstrr"r*rr)rrr>s rcszeZdZUdZdddgZeedfe e  de ee dd œ‡fd d „ Z dd œd d„Zeedœdd„Zed œdd„Z‡ZS)Ú LayerNormaõ Applies Layer Normalization over a mini-batch of inputs as described in the paper `Layer Normalization `__ .. math:: y = \frac{x - \mathrm{E}[x]}{ \sqrt{\mathrm{Var}[x] + \epsilon}} * \gamma + \beta The mean and standard-deviation are calculated over the last `D` dimensions, where `D` is the dimension of :attr:`normalized_shape`. For example, if :attr:`normalized_shape` is ``(3, 5)`` (a 2-dimensional shape), the mean and standard-deviation are computed over the last 2 dimensions of the input (i.e. ``input.mean((-2, -1))``). :math:`\gamma` and :math:`\beta` are learnable affine transform parameters of :attr:`normalized_shape` if :attr:`elementwise_affine` is ``True``. The standard-deviation is calculated via the biased estimator, equivalent to `torch.var(input, unbiased=False)`. .. note:: Unlike Batch Normalization and Instance Normalization, which applies scalar scale and bias for each entire channel/plane with the :attr:`affine` option, Layer Normalization applies per-element scale and bias with :attr:`elementwise_affine`. This layer uses statistics computed from input data in both training and evaluation modes. Args: normalized_shape (int or list or torch.Size): input shape from an expected input of size .. math:: [* \times \text{normalized\_shape}[0] \times \text{normalized\_shape}[1] \times \ldots \times \text{normalized\_shape}[-1]] If a single integer is used, it is treated as a singleton list, and this module will normalize over the last dimension which is expected to be of that specific size. eps: a value added to the denominator for numerical stability. Default: 1e-5 elementwise_affine: a boolean value that when set to ``True``, this module has learnable per-element affine parameters initialized to ones (for weights) and zeros (for biases). Default: ``True``. Attributes: weight: the learnable weights of the module of shape :math:`\text{normalized\_shape}` when :attr:`elementwise_affine` is set to ``True``. The values are initialized to 1. bias: the learnable bias of the module of shape :math:`\text{normalized\_shape}` when :attr:`elementwise_affine` is set to ``True``. The values are initialized to 0. Shape: - Input: :math:`(N, *)` - Output: :math:`(N, *)` (same shape as input) Examples:: >>> # NLP Example >>> batch, sentence_length, embedding_dim = 20, 5, 10 >>> embedding = torch.randn(batch, sentence_length, embedding_dim) >>> layer_norm = nn.LayerNorm(embedding_dim) >>> # Activate module >>> layer_norm(embedding) >>> >>> # Image Example >>> N, C, H, W = 20, 5, 10, 10 >>> input = torch.randn(N, C, H, W) >>> # Normalize over the last three dimensions (i.e. the channel and spatial dimensions) >>> # as shown in the image below >>> layer_norm = nn.LayerNorm([C, H, W]) >>> output = layer_norm(input) .. image:: ../_static/img/nn/layer_norm.jpg :scale: 50 % Únormalized_shapeÚepsÚelementwise_affine.çñh㈵øä>TN)r1r2r3rcs˜||dœ}tt|ƒjƒt|tjƒr*|f}t|ƒ|_||_||_ |j rtt t j |jf|Žƒ|_ t t j |jf|Žƒ|_n|jddƒ|jddƒ|jƒdS)N)ÚdeviceÚdtypeÚweightÚbias)rr0rÚ isinstanceÚnumbersÚIntegralÚtupler1r2r3rÚtorchÚemptyr7r8Úregister_parameterÚreset_parameters)rr1r2r3r5r6Úfactory_kwargs)rrrr¤s     zLayerNorm.__init__)rcCs"|jrtj|jƒtj|jƒdS)N)r3rÚones_r7Úzeros_r8)rrrrr@·s zLayerNorm.reset_parameters)rrcCstj||j|j|j|jƒS)N)rZ layer_normr1r7r8r2)rrrrrr¼szLayerNorm.forwardcCsdjf|jŽS)NzF{normalized_shape}, eps={eps}, elementwise_affine={elementwise_affine})r r!)rrrrr"ÀszLayerNorm.extra_repr)r4TNN)r#r$r%r&r'r r(r1r)r2Úboolr3Ú_shape_trr@r rr/r"r*rr)rrr0Vs H  r0cszeZdZUdZddddgZeee e  deeee dd œ‡fd d „ Z dd œd d„Z eedœdd„Zed œdd„Z‡ZS)Ú GroupNorma]Applies Group Normalization over a mini-batch of inputs as described in the paper `Group Normalization `__ .. math:: y = \frac{x - \mathrm{E}[x]}{ \sqrt{\mathrm{Var}[x] + \epsilon}} * \gamma + \beta The input channels are separated into :attr:`num_groups` groups, each containing ``num_channels / num_groups`` channels. The mean and standard-deviation are calculated separately over the each group. :math:`\gamma` and :math:`\beta` are learnable per-channel affine transform parameter vectors of size :attr:`num_channels` if :attr:`affine` is ``True``. The standard-deviation is calculated via the biased estimator, equivalent to `torch.var(input, unbiased=False)`. This layer uses statistics computed from input data in both training and evaluation modes. Args: num_groups (int): number of groups to separate the channels into num_channels (int): number of channels expected in input eps: a value added to the denominator for numerical stability. Default: 1e-5 affine: a boolean value that when set to ``True``, this module has learnable per-channel affine parameters initialized to ones (for weights) and zeros (for biases). Default: ``True``. Shape: - Input: :math:`(N, C, *)` where :math:`C=\text{num\_channels}` - Output: :math:`(N, C, *)` (same shape as input) Examples:: >>> input = torch.randn(20, 6, 10, 10) >>> # Separate 6 channels into 3 groups >>> m = nn.GroupNorm(3, 6) >>> # Separate 6 channels into 6 groups (equivalent with InstanceNorm) >>> m = nn.GroupNorm(6, 6) >>> # Put all 6 channels into a single group (equivalent with LayerNorm) >>> m = nn.GroupNorm(1, 6) >>> # Activating the module >>> output = m(input) Ú num_groupsÚ num_channelsr2Úaffineçñh㈵øä>TN)rGrHr2rIrcs„||dœ}tt|ƒjƒ||_||_||_||_|jr`ttj |f|Žƒ|_ ttj |f|Žƒ|_ n|j ddƒ|j ddƒ|j ƒdS)N)r5r6r7r8)rrFrrGrHr2rIrr=r>r7r8r?r@)rrGrHr2rIr5r6rA)rrrrõs   zGroupNorm.__init__)rcCs"|jrtj|jƒtj|jƒdS)N)rIrrBr7rCr8)rrrrr@s zGroupNorm.reset_parameters)rrcCstj||j|j|j|jƒS)N)rZ group_normrGr7r8r2)rrrrrr szGroupNorm.forwardcCsdjf|jŽS)Nz8{num_groups}, {num_channels}, eps={eps}, affine={affine})r r!)rrrrr"szGroupNorm.extra_repr)rJTNN)r#r$r%r&r'r(rGrHr)r2rDrIrr@r rr/r"r*rr)rrrFÅs ) rF)r=r:Ztorch.nn.parameterrÚmodulerZ _functionsrr-Úrrrr r Útypingr r r rr(rEr0rFrrrrÚs     1o