blackfeather-wang / ISDA-for-Deep-Networks

An efficient implicit semantic augmentation method, complementary to existing non-semantic techniques.
582 stars 93 forks source link

What's the difference between cifar-ISDA and imagenet-ISDA #17

Closed dengfenglai321 closed 3 years ago

dengfenglai321 commented 3 years ago

cifar-ISDA:

    def forward(self, model, fc, x, target_x, ratio):
        features = model(x)
        y = fc(features)
        self.estimator.update_CV(features.detach(), target_x)
        isda_aug_y = self.isda_aug(fc, features, y, target_x, self.estimator.CoVariance.detach(), ratio)
        loss = self.cross_entropy(isda_aug_y, target_x)
        return loss, y

imagenet-ISDA:

    def forward(self, model, x, target_x, ratio):
        y, features = model(x, isda=True)
        # y = fc(features)
        self.estimator.update_CV(features.detach(), target_x)
        isda_aug_y = self.isda_aug(model.module.fc, features, y, target_x, self.estimator.CoVariance.detach(), ratio)
        loss = self.cross_entropy(isda_aug_y, target_x)
        return loss, y

why there is difference? To apply ISDA to other models, the final fully connected layer does not needs to be explicitly defined in imagenet? right? It's a little bit like centerLoss needs to return x and feature, right?