def forward(self, x, with_feature=False): x = self.features(x) f_list, x = unpack_feature(x) x = self.avgpool(x) x = x.view(x.size(0), -1) f_list.append(x) x = self.classifier(x) return pack_feature(f_list, x, with_feature)
def forward(self, x, with_feature=False): features = self.features(x) out = F.relu(features, inplace=True) out = F.adaptive_avg_pool2d(out, (1, 1)) out = torch.flatten(out, 1) out = self.classifier(out) f_list, out = unpack_feature(out) return pack_feature(f_list, out, with_feature)
def forward(self, x, with_feature=True): f_list, x = unpack_feature(x) identity = x out = self.conv1(x) out = self.bn1(out) out = self.relu(out) out = self.conv2(out) out = self.bn2(out) if self.downsample is not None: identity = self.downsample(x) out += identity out = self.relu(out) return pack_feature(f_list, out, with_feature)
def forward(self, x, with_feature=False): x = self.conv1(x) x = self.bn1(x) x = self.relu(x) x = self.maxpool(x) x = self.layer1(x) x = self.layer2(x) x = self.layer3(x) x = self.layer4(x) f_list, x = unpack_feature(x) x = self.avgpool(x) x = x.reshape(x.size(0), -1) f_list.append(x) x = self.fc(x) return pack_feature(f_list, x, with_feature)