/usr/local/lib64/python3.6/site-packages/torch/nn/modules/__pycache__
Edit: /usr/local/lib64/python3.6/site-packages/torch/nn/modules/__pycache__/linear.cpython-36.pyc (10188B)
3
Ege( @ s d dl Z d dlZd dlmZ d dlmZmZ ddlmZ ddlm Z ddl
mZ dd lm
Z
G d
d deZG dd
d
eZG dd deZG dd deZG dd de
eZdS ) N)Tensor) ParameterUninitializedParameter )
functional)init )Module)LazyModuleMixinc s0 e Zd ZdZ fddZeedddZ ZS )Identitya A placeholder identity operator that is argument-insensitive.
Args:
args: any argument (unused)
kwargs: any keyword argument (unused)
Shape:
- Input: :math:`(*)`, where :math:`*` means any number of dimensions.
- Output: :math:`(*)`, same shape as the input.
Examples::
>>> m = nn.Identity(54, unused_argument1=0.1, unused_argument2=False)
>>> input = torch.randn(128, 20)
>>> output = m(input)
>>> print(output.size())
torch.Size([128, 20])
c s t t| j d S )N)superr __init__)selfargskwargs) __class__ C/usr/local/lib64/python3.6/site-packages/torch/nn/modules/linear.pyr
s zIdentity.__init__)inputreturnc C s |S )Nr )r r r r r forward# s zIdentity.forward)__name__
__module____qualname____doc__r
r r
__classcell__r r )r r r s r c sp e Zd ZU dZddgZeee deee
dd fdd
Zdd d
dZeedd
dZ
ed ddZ ZS )Lineara Applies a linear transformation to the incoming data: :math:`y = xA^T + b`
This module supports :ref:`TensorFloat32
`.
Args:
in_features: size of each input sample
out_features: size of each output sample
bias: If set to ``False``, the layer will not learn an additive bias.
Default: ``True``
Shape:
- Input: :math:`(*, H_{in})` where :math:`*` means any number of
dimensions including none and :math:`H_{in} = \text{in\_features}`.
- Output: :math:`(*, H_{out})` where all but the last dimension
are the same shape as the input and :math:`H_{out} = \text{out\_features}`.
Attributes:
weight: the learnable weights of the module of shape
:math:`(\text{out\_features}, \text{in\_features})`. The values are
initialized from :math:`\mathcal{U}(-\sqrt{k}, \sqrt{k})`, where
:math:`k = \frac{1}{\text{in\_features}}`
bias: the learnable bias of the module of shape :math:`(\text{out\_features})`.
If :attr:`bias` is ``True``, the values are initialized from
:math:`\mathcal{U}(-\sqrt{k}, \sqrt{k})` where
:math:`k = \frac{1}{\text{in\_features}}`
Examples::
>>> m = nn.Linear(20, 30)
>>> input = torch.randn(128, 20)
>>> output = m(input)
>>> print(output.size())
torch.Size([128, 30])
in_featuresout_featuresTN)r r biasr c sn ||d}t t| j || _|| _ttj||ff|| _|rVttj|f|| _ n| j
dd | j d S )N)devicedtyper )r r r
r r r torchemptyweightr register_parameterreset_parameters)r r r r r r! factory_kwargs)r r r r
O s
zLinear.__init__)r c C s` t j| jtjdd | jd k r\t j| j\}}|dkrFdtj| nd}t j| j| | d S )N )ar r )r Zkaiming_uniform_r$ mathsqrtr Z_calculate_fan_in_and_fan_outuniform_)r Zfan_in_boundr r r r&