in rmac_features.py [0:0]
def forward(self, x):
x = self.model.conv1(x)
x = self.model.bn1(x)
x = self.model.relu(x)
counter = 1
if counter == self.n:
return x
x = self.model.maxpool(x)
for block in [
self.model.layer1,
self.model.layer2,
self.model.layer3,
self.model.layer4,
]:
for layer in block._modules.values():
residual = x
x = layer.conv1(x)
x = layer.bn1(x)
x = layer.relu(x)
counter += 1
if counter == self.n:
break
x = layer.conv2(x)
x = layer.bn2(x)
if layer.downsample is not None:
residual = layer.downsample(residual)
x += residual
x = layer.relu(x)
counter += 1
if counter == self.n:
break
return x