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

Custom dataset #10

Closed
ja16005 opened this issue May 8, 2020 · 4 comments
Closed

Custom dataset #10

ja16005 opened this issue May 8, 2020 · 4 comments

Comments

@ja16005
Copy link

ja16005 commented May 8, 2020

Hi.
I was trying out few shot on custom dataset, My custom data has 17 categories and 6 images per category. created a class similar to MiniImageNet and used in it validation, i.e valset. But it is throwing me an error in line 114 as
loss = F.cross_entropy(logits, label)
File "/home/search_env/lib/python3.6/site-packages/torch/nn/functional.py", line 2056, in cross_entropy
return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction)
File "/home/search_env/lib/python3.6/site-packages/torch/nn/functional.py", line 1869, in nll_loss
.format(input.size(0), target.size(0)))
ValueError: Expected input batch_size (5) to match target batch_size (75).

Am I missing something? Kindly guide

@yinboc
Copy link
Owner

yinboc commented May 8, 2020

I am not sure what the exact problem is, replacing mini with custom dataset should work. It seems the batch_size of logits and label did not match, could you check their shape?

@ja16005
Copy link
Author

ja16005 commented May 8, 2020

yes, the shapes are different ..
Shape of logits torch.Size([5, 5])
Shape of label torch.Size([75])

Are there any constraints for the custom dataset for the code to run? Should I tweak any parameters accordingly?
I used the following parameters
shot=5
query=15
train way=30
test way=5
I have used mini during training and custom dataset for validation which has 17 classes and 6 images per class.

@ja16005
Copy link
Author

ja16005 commented May 8, 2020

I referred to the paper and modified query=3 and shot=3 as per my custom training support. Now the code is working fine.

Thanks for the quick response! :)

@yinboc
Copy link
Owner

yinboc commented May 8, 2020

I remember there should not be constraints for custom dataset. You may check the intermediate shapes to see what the exact problem is. The shape of logits should be [n_way * n_query, n_way], and shape of label should be [n_way * n_query].

@ja16005 ja16005 closed this as completed May 13, 2020
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