r"""Modified `ResNet` architecture for ReID from `Mutual Mean-Teaching: Pseudo Label Refinery for Unsupervised Domain Adaptation on Person Re-identification (ICLR 2020) `_. We change stride of :math:`layer4\_group1\_conv2, layer4\_group1\_downsample1` to
| 8 | |
| 9 | |
| 10 | class ReidResNet(ResNet): |
| 11 | r"""Modified `ResNet` architecture for ReID from `Mutual Mean-Teaching: Pseudo Label Refinery for Unsupervised |
| 12 | Domain Adaptation on Person Re-identification (ICLR 2020) <https://arxiv.org/pdf/2001.01526.pdf>`_. We change stride |
| 13 | of :math:`layer4\_group1\_conv2, layer4\_group1\_downsample1` to 1. During forward pass, we will not activate |
| 14 | `self.relu`. Please refer to source code for details. |
| 15 | """ |
| 16 | |
| 17 | def __init__(self, *args, **kwargs): |
| 18 | super(ReidResNet, self).__init__(*args, **kwargs) |
| 19 | self.layer4[0].conv2.stride = (1, 1) |
| 20 | self.layer4[0].downsample[0].stride = (1, 1) |
| 21 | |
| 22 | def forward(self, x): |
| 23 | x = self.conv1(x) |
| 24 | x = self.bn1(x) |
| 25 | # x = self.relu(x) |
| 26 | x = self.maxpool(x) |
| 27 | |
| 28 | x = self.layer1(x) |
| 29 | x = self.layer2(x) |
| 30 | x = self.layer3(x) |
| 31 | x = self.layer4(x) |
| 32 | |
| 33 | return x |
| 34 | |
| 35 | |
| 36 | def _reid_resnet(arch, block, layers, pretrained, progress, **kwargs): |