/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__/container.cpython-36.pyc (27970B)
3 Egf@sddlZddlmZmZddlmZddlZddlZddl m Z ddl m Z ddl mZmZmZmZmZmZmZmZmZmZmZerddlmZed e d ZGd d d e ZGd dde ZGddde ZGddde ZGddde Z Gddde Z!dS)N) OrderedDictabc)islice)Module)_copy_to_script_wrapper) AnyDictIterableIteratorMappingOptional TYPE_CHECKINGoverloadTupleTypeVarUnion) ParameterT)boundcs$eZdZeddfdd ZZS) ContainerN)kwargsreturnc s>tt|jtjdx |jD]\}}|j||q"WdS)Nzmnn.Container is deprecated. All of it's functionality is now implemented in nn.Module. Subclass that instead.)superr__init__warningswarnitems add_module)selfrkeyvalue) __class__F/usr/local/lib64/python3.6/site-packages/torch/nn/modules/container.pyrs zContainer.__init__)__name__ __module__ __qualname__rr __classcell__r#r#)r"r$rsrcseZdZUdZeeefeeddddZ edddddZ fd dZ e d d d Z e e de fd d dZeeddddZe eefddddZe ed ddZe fddZe eed ddZddZZS) SequentialaA sequential container. Modules will be added to it in the order they are passed in the constructor. Alternatively, an ``OrderedDict`` of modules can be passed in. The ``forward()`` method of ``Sequential`` accepts any input and forwards it to the first module it contains. It then "chains" outputs to inputs sequentially for each subsequent module, finally returning the output of the last module. The value a ``Sequential`` provides over manually calling a sequence of modules is that it allows treating the whole container as a single module, such that performing a transformation on the ``Sequential`` applies to each of the modules it stores (which are each a registered submodule of the ``Sequential``). What's the difference between a ``Sequential`` and a :class:`torch.nn.ModuleList`? A ``ModuleList`` is exactly what it sounds like--a list for storing ``Module`` s! On the other hand, the layers in a ``Sequential`` are connected in a cascading way. Example:: # Using Sequential to create a small model. When `model` is run, # input will first be passed to `Conv2d(1,20,5)`. The output of # `Conv2d(1,20,5)` will be used as the input to the first # `ReLU`; the output of the first `ReLU` will become the input # for `Conv2d(20,64,5)`. Finally, the output of # `Conv2d(20,64,5)` will be used as input to the second `ReLU` model = nn.Sequential( nn.Conv2d(1,20,5), nn.ReLU(), nn.Conv2d(20,64,5), nn.ReLU() ) # Using Sequential with OrderedDict. This is functionally the # same as the above code model = nn.Sequential(OrderedDict([ ('conv1', nn.Conv2d(1,20,5)), ('relu1', nn.ReLU()), ('conv2', nn.Conv2d(20,64,5)), ('relu2', nn.ReLU()) ])) N)argsrcGsdS)Nr#)rr*r#r#r$rLszSequential.__init__zOrderedDict[str, Module])argrcCsdS)Nr#)rr+r#r#r$rPscsztt|jt|dkrPt|dtrPxL|djD]\}}|j||q6Wn&x$t|D]\}}|jt ||qZWdS)Nrr) rr)rlen isinstancerrr enumeratestr)rr*r moduleidx)r"r#r$rTs )rcCsRt|}tj|}| |ko&|kns:tdj|||;}tt||dS)z#Get the idx-th item of the iteratorzindex {} is out of rangeN)r,operatorindex IndexErrorformatnextr)riteratorr1sizer#r#r$_get_item_by_idx]s  zSequential._get_item_by_idxcCs<t|tr&|jtt|jj|S|j|jj|SdS)N) r-slicer"rlist_modulesrr9values)rr1r#r#r$ __getitem__fs zSequential.__getitem__)r1r0rcCs|j|jj|}t|||S)N)r9r<keyssetattr)rr1r0r r#r#r$ __setitem__mszSequential.__setitem__)r1rcCsRt|tr2xBt|jj|D]}t||qWn|j|jj|}t||dS)N)r-r:r;r<r?delattrr9)rr1r r#r#r$ __delitem__qs  zSequential.__delitem__cCs t|jS)N)r,r<)rr#r#r$__len__yszSequential.__len__cs tt|j}dd|D}|S)NcSsg|]}|js|qSr#)isdigit).0r r#r#r$ sz&Sequential.__dir__..)rr)__dir__)rr?)r"r#r$rH}szSequential.__dir__cCst|jjS)N)iterr<r=)rr#r#r$__iter__szSequential.__iter__cCsx|D] }||}qW|S)Nr#)rinputr0r#r#r$forwards  zSequential.forward)r%r&r'__doc__r r/rr<rrrr9rrr>intrAr:rCrDrHr rJrLr(r#r#)r"r$r)s$ +   r)cseZdZUdZeeefd!ee eddfdd Z ddZ e e edd d Ze edd d d Zee efddddZe e dddZe eedddZe eddddZe fddZe eddddZeddddZe edddd ZZS)" ModuleListaHolds submodules in a list. :class:`~torch.nn.ModuleList` can be indexed like a regular Python list, but modules it contains are properly registered, and will be visible by all :class:`~torch.nn.Module` methods. Args: modules (iterable, optional): an iterable of modules to add Example:: class MyModule(nn.Module): def __init__(self): super(MyModule, self).__init__() self.linears = nn.ModuleList([nn.Linear(10, 10) for i in range(10)]) def forward(self, x): # ModuleList can act as an iterable, or be indexed using ints for i, l in enumerate(self.linears): x = self.linears[i // 2](x) + l(x) return x N)modulesrcs"tt|j|dk r||7}dS)N)rrOr)rrP)r"r#r$rszModuleList.__init__cCsVtj|}t| |ko&t|kns:tdj||dkrN|t|7}t|S)z.Get the absolute index for the list of moduleszindex {} is out of ranger)r2r3r,r4r5r/)rr1r#r#r$_get_abs_string_indexs  " z ModuleList._get_abs_string_index)r1rcCs6t|tr"|jt|jj|S|j|j|SdS)N)r-r:r"r;r<r=rQ)rr1r#r#r$r>s zModuleList.__getitem__)r1r0rcCs|j|}t|t||S)N)rQr@r/)rr1r0r#r#r$rAs zModuleList.__setitem__cCs|t|tr6x:tt|j|D]}t|t|qWnt||j|ddtt|jD}tt t ||jj |_dS)NcSsg|] }t|qSr#)r/)rFir#r#r$rGsz*ModuleList.__delitem__..) r-r:ranger,r<rBr/rQrr;zipr=)rr1kZ str_indicesr#r#r$rCs  zModuleList.__delitem__)rcCs t|jS)N)r,r<)rr#r#r$rDszModuleList.__len__cCst|jjS)N)rIr<r=)rr#r#r$rJszModuleList.__iter__cCs |j|S)N)extend)rrPr#r#r$__iadd__szModuleList.__iadd__cs tt|j}dd|D}|S)NcSsg|]}|js|qSr#)rE)rFr r#r#r$rGsz&ModuleList.__dir__..)rrOrH)rr?)r"r#r$rHszModuleList.__dir__)r3r0rcCsJx6tt|j|dD] }|jt|d|jt|<qW||jt|<dS)zInsert a given module before a given index in the list. Args: index (int): index to insert. module (nn.Module): module to insert rN)rSr,r<r/)rr3r0rRr#r#r$inserts zModuleList.insert)r0rcCs|jtt|||S)zwAppends a given module to the end of the list. Args: module (nn.Module): module to append )rr/r,)rr0r#r#r$appendszModuleList.appendcCsTt|tjstdt|jt|}x(t|D]\}}|jt |||q0W|S)zAppends modules from a Python iterable to the end of the list. Args: modules (iterable): iterable of modules to append z=ModuleList.extend should be called with an iterable, but got ) r-container_abcsr TypeErrortyper%r,r.rr/)rrPoffsetrRr0r#r#r$rVs zModuleList.extend)N)r%r&r'rMr r/rr<r r rrQrrNr>rArr:rCrDr rJrWrHrYrZrVr(r#r#)r"r$rOs"      rOcs6eZdZUdZeeefd!ee eefddfdd Z e eedddZ eedd d d Z eddd d Ze edddZe eedddZe eedddZddddZeedddZe eedddZe eeeefdddZe eedddZe eefdddd ZZS)" ModuleDicta2Holds submodules in a dictionary. :class:`~torch.nn.ModuleDict` can be indexed like a regular Python dictionary, but modules it contains are properly registered, and will be visible by all :class:`~torch.nn.Module` methods. :class:`~torch.nn.ModuleDict` is an **ordered** dictionary that respects * the order of insertion, and * in :meth:`~torch.nn.ModuleDict.update`, the order of the merged ``OrderedDict``, ``dict`` (started from Python 3.6) or another :class:`~torch.nn.ModuleDict` (the argument to :meth:`~torch.nn.ModuleDict.update`). Note that :meth:`~torch.nn.ModuleDict.update` with other unordered mapping types (e.g., Python's plain ``dict`` before Python version 3.6) does not preserve the order of the merged mapping. Args: modules (iterable, optional): a mapping (dictionary) of (string: module) or an iterable of key-value pairs of type (string, module) Example:: class MyModule(nn.Module): def __init__(self): super(MyModule, self).__init__() self.choices = nn.ModuleDict({ 'conv': nn.Conv2d(10, 10, 3), 'pool': nn.MaxPool2d(3) }) self.activations = nn.ModuleDict([ ['lrelu', nn.LeakyReLU()], ['prelu', nn.PReLU()] ]) def forward(self, x, choice, act): x = self.choices[choice](x) x = self.activations[act](x) return x N)rPrcs$tt|j|dk r |j|dS)N)rr_rupdate)rrP)r"r#r$r2szModuleDict.__init__)r rcCs |j|S)N)r<)rr r#r#r$r>7szModuleDict.__getitem__)r r0rcCs|j||dS)N)r)rr r0r#r#r$rA;szModuleDict.__setitem__cCs |j|=dS)N)r<)rr r#r#r$rC>szModuleDict.__delitem__)rcCs t|jS)N)r,r<)rr#r#r$rDAszModuleDict.__len__cCs t|jS)N)rIr<)rr#r#r$rJEszModuleDict.__iter__cCs ||jkS)N)r<)rr r#r#r$ __contains__IszModuleDict.__contains__cCs|jjdS)z.Remove all items from the ModuleDict. N)r<clear)rr#r#r$rbMszModuleDict.clearcCs||}||=|S)zRemove key from the ModuleDict and return its module. Args: key (string): key to pop from the ModuleDict r#)rr vr#r#r$popRszModuleDict.popcCs |jjS)z3Return an iterable of the ModuleDict keys. )r<r?)rr#r#r$r?\szModuleDict.keyscCs |jjS)z>Return an iterable of the ModuleDict key/value pairs. )r<r)rr#r#r$rbszModuleDict.itemscCs |jjS)z5Return an iterable of the ModuleDict values. )r<r=)rr#r#r$r=hszModuleDict.valuescCst|tjstdt|jt|tttjfrPx|j D]\}}|||<q:Wnx~t |D]r\}}t|tjstdt |dt|jt |dkst dt |dt t |d|d||d<qZWd S) a!Update the :class:`~torch.nn.ModuleDict` with the key-value pairs from a mapping or an iterable, overwriting existing keys. .. note:: If :attr:`modules` is an ``OrderedDict``, a :class:`~torch.nn.ModuleDict`, or an iterable of key-value pairs, the order of new elements in it is preserved. Args: modules (iterable): a mapping (dictionary) from string to :class:`~torch.nn.Module`, or an iterable of key-value pairs of type (string, :class:`~torch.nn.Module`) zPModuleDict.update should be called with an iterable of key/value pairs, but got z$ModuleDict update sequence element #z should be Iterable; isz has length z; 2 is requiredrrN)r-r[r r\r]r%rr_r rr.r/r, ValueError)rrPr r0jmr#r#r$r`ns   zModuleDict.update)N)r%r&r'rMr r/rr<r r rrr>rArCrNrDr rJboolrarbrdr r?rrr=r`r(r#r#)r"r$r_s, * " r_cs4eZdZUdZeedfd+eedddfdd Z fddZ d d Z e e dd d d Ze eeeddd Zdd Ze dddddZeeddfdd Ze dddZeddddZedddddZfddZddd d!d"Zedddd#d$Zedd%d&Zd'd(Zfd)d*ZZS), ParameterLista:Holds parameters in a list. :class:`~torch.nn.ParameterList` can be indexed like a regular Python list, but parameters it contains are properly registered, and will be visible by all :class:`~torch.nn.Module` methods. Args: parameters (iterable, optional): an iterable of :class:`~torch.nn.Parameter` to add Example:: class MyModule(nn.Module): def __init__(self): super(MyModule, self).__init__() self.params = nn.ParameterList([nn.Parameter(torch.randn(10, 10)) for i in range(10)]) def forward(self, x): # ParameterList can act as an iterable, or be indexed using ints for i, p in enumerate(self.params): x = self.params[i // 2].mm(x) + p.mm(x) return x rN) parametersrcs(tt|jd|_|dk r$||7}dS)NT)rrjr _initialized)rrk)r"r#r$rszParameterList.__init__cs"d|d<tt|j|d|_dS)NFrlT)rrj __setstate__rl)rstate)r"r#r$rmszParameterList.__setstate__cCsVtj|}t| |ko&t|kns:tdj||dkrN|t|7}t|S)z.Get the absolute index for the list of moduleszindex {} is out of ranger)r2r3r,r4r5r/)rr1r#r#r$rQs  " z#ParameterList._get_abs_string_index)r1rcCsdS)Nr#)rr1r#r#r$r>szParameterList.__getitem__)rr1rcCsdS)Nr#)rr1r#r#r$r>scCs>t|tr"|jt|jj|S|j|}|jt|SdS)N)r-r:r"r; _parametersr=rQr/)rr1r#r#r$r>s  )r1paramrcCs|j|}|jt||S)N)rQregister_parameterr/)rr1rpr#r#r$rAs zParameterList.__setitem__)r r!rcsHt|ddr2t|| r2t|tjj r2tjdtt |j ||dS)NrlFz5Setting attributes on ParameterList is not supported.) getattrhasattrr-torchnnrrrrrj __setattr__)rr r!)r"r#r$rvs  zParameterList.__setattr__)rcCs t|jS)N)r,ro)rr#r#r$rDszParameterList.__len__cCst|jjS)N)rIror=)rr#r#r$rJszParameterList.__iter__cCs |j|S)N)rV)rrkr#r#r$rWszParameterList.__iadd__cs tt|j}dd|D}|S)NcSsg|]}|js|qSr#)rE)rFr r#r#r$rGsz)ParameterList.__dir__..)rrjrH)rr?)r"r#r$rHszParameterList.__dir__) parameterrcCs|jtt|||S)zAppends a given parameter at the end of the list. Args: parameter (nn.Parameter): parameter to append )rqr/r,)rrwr#r#r$rZszParameterList.appendcCsTt|tjstdt|jt|}x(t|D]\}}|jt |||q0W|S)zAppends parameters from a Python iterable to the end of the list. Args: parameters (iterable): iterable of parameters to append z@ParameterList.extend should be called with an iterable, but got ) r-r[r r\r]r%r,r.rqr/)rrkr^rRrpr#r#r$rVs zParameterList.extendcCsg}xt|jjD]f\}}djdd|jD}|js:dn dj|j}djtj|||}|j dt |d|qWd j|}|S) Nxcss|]}t|VqdS)N)r/)rFr8r#r#r$ sz+ParameterList.extra_repr..z (GPU {})z'Parameter containing: [{} of size {}{}]z (z):  ) rorjoinr8is_cudar5 get_devicerttypenamerZr/)r child_linesrUpsize_str device_strparastrtmpstrr#r#r$ extra_reprs zParameterList.extra_reprcCs tddS)Nz#ParameterList should not be called.) RuntimeError)rrKr#r#r$__call__ szParameterList.__call__cstjdtt|jS)Nznn.ParameterList is being used with DataParallel but this is not supported. This list will appear empty for the models replicated on each GPU except the original one.)rrrrj_replicate_for_data_parallel)r)r"r#r$rs z*ParameterList._replicate_for_data_parallel)N)r%r&r'rMr r/ror r rrmrQrrNr>rr:rArrvrDr rJrWrHrZrVrrrr(r#r#)r"r$rjs*       rjcs^eZdZUdZeedfd-eeedfddfdd Z fddZ edd d d Z eddd d dZ edd ddZ eeddfdd ZedddZeedddZeed ddZddddZedd ddZeeddd Zeeedfdd!d"Zeddd#d$Zeedfddd%d&Zedd'd(Zd)d*Zfd+d,Z Z!S). ParameterDicta^Holds parameters in a dictionary. ParameterDict can be indexed like a regular Python dictionary, but parameters it contains are properly registered, and will be visible by all Module methods. :class:`~torch.nn.ParameterDict` is an **ordered** dictionary that respects * the order of insertion, and * in :meth:`~torch.nn.ParameterDict.update`, the order of the merged ``OrderedDict`` or another :class:`~torch.nn.ParameterDict` (the argument to :meth:`~torch.nn.ParameterDict.update`). Note that :meth:`~torch.nn.ParameterDict.update` with other unordered mapping types (e.g., Python's plain ``dict``) does not preserve the order of the merged mapping. Args: parameters (iterable, optional): a mapping (dictionary) of (string : :class:`~torch.nn.Parameter`) or an iterable of key-value pairs of type (string, :class:`~torch.nn.Parameter`) Example:: class MyModule(nn.Module): def __init__(self): super(MyModule, self).__init__() self.params = nn.ParameterDict({ 'left': nn.Parameter(torch.randn(5, 10)), 'right': nn.Parameter(torch.randn(5, 10)) }) def forward(self, x, choice): x = self.params[choice].mm(x) return x rN)rkrcs*tt|jd|_|dk r&|j|dS)NT)rrrrlr`)rrk)r"r#r$r>szParameterDict.__init__cs"d|d<tt|j|d|_dS)NFrlT)rrrmrl)rrn)r"r#r$rmDszParameterDict.__setstate__)r rcCs |j|S)N)ro)rr r#r#r$r>IszParameterDict.__getitem__)r rwrcCs|j||dS)N)rq)rr rwr#r#r$rALszParameterDict.__setitem__cCs |j|=dS)N)ro)rr r#r#r$rCOszParameterDict.__delitem__)r r!rcsHt|ddr2t|| r2t|tjj r2tjdtt |j ||dS)NrlFz5Setting attributes on ParameterDict is not supported.) rrrsr-rtrurrrrrrv)rr r!)r"r#r$rvRs  zParameterDict.__setattr__)rcCs t|jS)N)r,ro)rr#r#r$rDXszParameterDict.__len__cCst|jjS)N)rIror?)rr#r#r$rJ[szParameterDict.__iter__cCs ||jkS)N)ro)rr r#r#r$ra^szParameterDict.__contains__cCs|jjdS)z1Remove all items from the ParameterDict. N)rorb)rr#r#r$rbaszParameterDict.clearcCs||}||=|S)zRemove key from the ParameterDict and return its parameter. Args: key (string): key to pop from the ParameterDict r#)rr rcr#r#r$rdfszParameterDict.popcCs |jjS)z6Return an iterable of the ParameterDict keys. )ror?)rr#r#r$r?pszParameterDict.keyscCs |jjS)zAReturn an iterable of the ParameterDict key/value pairs. )ror)rr#r#r$ruszParameterDict.itemscCs |jjS)z8Return an iterable of the ParameterDict values. )ror=)rr#r#r$r=zszParameterDict.valuescCst|tjstdt|jt|ttfrLx|jD]\}}|||<q6Wnt|tj r|xt |jD]\}}|||<qfWnx~t |D]r\}}t|tjstdt |dt|jt |dkstdt |dt t |d|d||d<qWd S) aCUpdate the :class:`~torch.nn.ParameterDict` with the key-value pairs from a mapping or an iterable, overwriting existing keys. .. note:: If :attr:`parameters` is an ``OrderedDict``, a :class:`~torch.nn.ParameterDict`, or an iterable of key-value pairs, the order of new elements in it is preserved. Args: parameters (iterable): a mapping (dictionary) from string to :class:`~torch.nn.Parameter`, or an iterable of key-value pairs of type (string, :class:`~torch.nn.Parameter`) zTParametersDict.update should be called with an iterable of key/value pairs, but got z'ParameterDict update sequence element #z should be Iterable; isrez has length z; 2 is requiredrrN)r-r[r r\r]r%rrrr sortedr.r/r,rf)rrkr rwrgrr#r#r$r`s&    zParameterDict.updatecCsg}xp|jjD]b\}}djdd|jD}|js:dn dj|j}djtj|||}|j d|d|qWd j|}|S) Nrxcss|]}t|VqdS)N)r/)rFr8r#r#r$rysz+ParameterDict.extra_repr..rzz (GPU {})z'Parameter containing: [{} of size {}{}]z (z): r{) rorr|r8r}r5r~rtrrZ)rrrUrrrrrr#r#r$rs zParameterDict.extra_reprcCs tddS)Nz#ParameterDict should not be called.)r)rrKr#r#r$rszParameterDict.__call__cstjdtt|jS)Nznn.ParameterDict is being used with DataParallel but this is not supported. This dict will appear empty for the models replicated on each GPU except the original one.)rrrrr)r)r"r#r$rs z*ParameterDict._replicate_for_data_parallel)N)"r%r&r'rMr r/ror r rrmr>rArCrrvrNrDr rJrirarbrdr r?rrr=r`rrrr(r#r#)r"r$rs( $ "  % r)"r collectionsrrr[ itertoolsrr2rtr0rZtorch._jit_internalrtypingrr r r r r rrrrrZtorch.nnrrrr)rOr_rjrr#r#r#r$s$   4   ts