Scheaven
2021-09-18 291deeb1fcf45dbf39a24aa72a213ff3fd6b3405
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
U
h—_‡ ã@sZdZddlZddlmZddlTddlmZmZddlmZe     ¡Gdd    „d    ej
ƒƒZ dS)
z9
@author:  liaoxingyu
@contact: sherlockliao01@gmail.com
éN)Únn)Ú*)Úweights_init_kaimingÚweights_init_classifieré)ÚREID_HEADS_REGISTRYcs&eZdZ‡fdd„Zddd„Z‡ZS)ÚAttrHeadc    s®tƒ ¡|jjj}|jjj}|jjj}|jjj}|jjj    }|jjj
}|dkrXt ƒ|_ n¨|dkrnt  d¡|_ n’|dkr„t  d¡|_ n||dkr–tƒ|_ nj|dkr¨tƒ|_ nX|dkrºtƒ|_ nF|dkrÌtƒ|_ n4|d    kràt  ¡|_ n |d
kròtƒ|_ nt|›d ƒ‚|d krt j||d d|_n\|dkr8t|||ƒ|_nB|dkrRt|||ƒ|_n(|dkrlt|||ƒ|_nt|›d ƒ‚t  |¡g}t j|Ž|_|j t ¡|j t!¡dS)NÚ fastavgpoolÚavgpoolrÚmaxpoolÚgempoolPÚgempoolÚ
avgmaxpoolÚ clipavgpoolÚidentityÚflattenz is not supported!ÚlinearF)ÚbiasÚ
arcSoftmaxÚ circleSoftmaxÚ    amSoftmax)"ÚsuperÚ__init__ÚMODELÚBACKBONEÚFEAT_DIMÚHEADSÚ NUM_CLASSESÚ
POOL_LAYERÚ    CLS_LAYERÚ WITH_BNNECKÚNORMÚFastGlobalAvgPool2dÚ
pool_layerrÚAdaptiveAvgPool2dÚAdaptiveMaxPool2dÚGeneralizedMeanPoolingPÚGeneralizedMeanPoolingÚAdaptiveAvgMaxPool2dÚClipGlobalAvgPool2dÚIdentityÚFlattenÚKeyErrorÚLinearÚ
classifierÚ
ArcSoftmaxÚ CircleSoftmaxÚ    AMSoftmaxÚ BatchNorm1dÚ
SequentialÚ
bottleneckÚapplyrr)    ÚselfÚcfgÚfeat_dimÚ num_classesÚ    pool_typeÚcls_typeÚ with_bnneckÚ    norm_typer4©Ú    __class__©ú./modeling/heads/attr_head.pyrsN
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
   zAttrHead.__init__NcCsf| |¡}|d}|jjj}|dkr0| |¡}n | ||¡}| |¡}|jrTd|iSt |¡}|SdS)z1
        See :class:`ReIDHeads.forward`.
        ).rrr-Ú cls_outputsN)r#r.r?Ú__name__r4ÚtrainingÚtorchÚsigmoid)r6ÚfeaturesÚtargetsÚ global_featZclassifier_namerBr@r@rAÚforward8s
 
 
ÿ
zAttrHead.forward)N)rCÚ
__module__Ú __qualname__rrJÚ __classcell__r@r@r>rArs 'r) Ú__doc__rErÚlayersÚutils.weight_initrrÚbuildrÚregisterÚModulerr@r@r@rAÚ<module>s