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

The code only works on num_queries=1 #5

Open
IRNLPCoder opened this issue Jun 9, 2020 · 1 comment
Open

The code only works on num_queries=1 #5

IRNLPCoder opened this issue Jun 9, 2020 · 1 comment

Comments

@IRNLPCoder
Copy link

IRNLPCoder commented Jun 9, 2020

DPGN/main.py

Line 316 in b940111

query_node_pred_loss = [

self.pred_loss(query_node_pred_generation, query_label.long()).mean()

For example, 5 way 1 shot, num_queries=1,
query_node_pred_generation has shape of [batch_size, 5, 5]
query_label has shape of [batch_size, 5]

5 way 1 shot, num_queries=2,
query_node_pred_generation have shape of [batch_size, 10, 5]
query_label has shape of [batch_size, 10]

In query_node_pred_generation, which dimension is the class (i.e., N ways)?

@zilunzhang
Copy link
Collaborator

DPGN/main.py

Line 316 in b940111

query_node_pred_loss = [

self.pred_loss(query_node_pred_generation, query_label.long()).mean()

For example, 5 way 1 shot, num_queries=1,
query_node_pred_generation has shape of [batch_size, 5, 5]
query_label has shape of [batch_size, 5]

5 way 1 shot, num_queries=2,
query_node_pred_generation have shape of [batch_size, 10, 5]
query_label has shape of [batch_size, 10]

In query_node_pred_generation, which dimension is the class (i.e., N ways)?

Dear Jing Li,

It is very unfortunate that the codebase is designed only for the setting of num_queries = 1 in the beginning.

We are sorry that the implementation of auxiliary loss (query_node_pred_loss) confuses many readers. Therefore, we decided to propose a modified version that follows most people's intuition. The accuracy for the result of 5-way 1-shot, resnet12, mini-imagenet is still around 67.70±0.52 (almost the same as reported accuracy on the paper, 67.77).

Please replace the content at line 316-319 of main.py by the code below:

        query_node_pred_loss = []
        for query_node_pred_generation in query_node_pred_generations_:
            temp_query_node_pred_generation = query_node_pred_generation.contiguous().view(-1, query_node_pred_generation.shape[-1])
            temp_query_label = query_label.long().contiguous().view(-1, )
            temp_loss = self.pred_loss(temp_query_node_pred_generation, temp_query_label).mean()
            query_node_pred_loss.append(temp_loss)

Also, some configs need to be revised:

config['num_loss_generation'] = 7
train_opt['dec_lr'] = 18000

Let us know if you have any other confusion when using the DPGN.

Yours,
DPGN Team

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

2 participants