def forward(self, x, with_feature=True): f_list, x = unpack_feature(x) if self.use_res_connect: ret = x + self.conv(x) else: ret = self.conv(x) return pack_feature(f_list, ret, with_feature)
def forward(self, x, with_feature=False): x = self.features(x) f_list, x = unpack_feature(x) x = x.mean([2, 3]) 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) f_list, features = unpack_feature(features) out = F.relu(features, inplace=True) out = F.adaptive_avg_pool2d(out, (1, 1)).view(features.size(0), -1) f_list.append(out) out = self.classifier(out) return pack_feature(f_list, out, with_feature)
def forward(self, x, with_feature=True): f_list, x_last = unpack_feature(x) x = F.relu(self.bn1(self.conv1(x_last))) x = self.bn2(self.conv2(x)) x += self.shortcut(x_last) x = F.relu(x) return pack_feature(f_list, x, with_feature)
def forward(self, x, with_feature=True): f_list, x = unpack_feature(x) if not self.equalInOut: x = self.relu1(self.bn1(x)) else: out = self.relu1(self.bn1(x)) out = self.relu2(self.bn2(self.conv1(out if self.equalInOut else x))) if self.droprate > 0: out = F.dropout(out, p=self.droprate, training=self.training) out = self.conv2(out) out = torch.add(x if self.equalInOut else self.convShortcut(x), out) return pack_feature(f_list, out, with_feature)
def forward(self, x, with_feature=False): out = self.conv1(x) out = self.block1(out) out = self.block2(out) out = self.block3(out) f_list, out = unpack_feature(out) out = self.relu(self.bn1(out)) out = F.avg_pool2d(out, 8) out = out.view(-1, self.nChannels) f_list.append(out) out = self.fc(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 = F.relu(self.bn1(self.conv1(x))) # x = pack_feature(*unpack_feature(x)) x = self.layer1(x) x = self.layer2(x) x = self.layer3(x) f_list, x = unpack_feature(x) x = F.avg_pool2d(x, x.size()[3]) x = x.view(x.size(0), -1) f_list.append(x) x = self.linear(x) return pack_feature(f_list, x, 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)