Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does compute query loss in training_step? #33

Open
minocrafft opened this issue Mar 9, 2023 · 0 comments
Open

Why does compute query loss in training_step? #33

minocrafft opened this issue Mar 9, 2023 · 0 comments

Comments

@minocrafft
Copy link

minocrafft commented Mar 9, 2023

First of all, thank you for your research with a good idea.

While analyzing the code of the ctl model, I left an issue because I was curious.

training_step code

        # query in training_step
        contrastive_loss_query, _, _ = self.contrastive_loss(
            features, class_labels, mask=isReal
        )
        contrastive_loss_query = (
            contrastive_loss_query * self.hparams.SOLVER.QUERY_CONTRASTIVE_WEIGHT
        )

        class_labels_real = class_labels[isReal]
        features_real = features[isReal]
        center_loss = self.hparams.SOLVER.CENTER_LOSS_WEIGHT * self.center_loss(
            features_real, class_labels_real
        )
        bn_features = self.bn(features_real)
        cls_score = self.fc_query(bn_features)
        xent_query = self.xent(cls_score, class_labels_real)
        xent_query = xent_query * self.hparams.SOLVER.QUERY_XENT_WEIGHT

From that link, the query data is calculated with contrastive loss, center loss, and xent loss, and then added to the total_loss at the bottom.
As far as I know, query and gallery dataset is used for validation.

Isn't the data loaded into the batch of training_step the data of the train dataset?
Or does *_loss_query have any other meaning?
Did I miss anything?

If anyone has the same problem as me, I would appreciate it if you could reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant