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
Traning with custom dataset #45
Comments
Step 1 Import lib and load datasetsI use the method from PyTorch's official transfer learning tutorial.
|
Step 2 data loader
In step 2, I got 2 problems.
Second is the value setting of
|
Step3 load pre-trained modelThis step is more like the part frommy_first_few_shot_classifier.ipynb. I trained the model myself using Resnet18
|
Step 4 Training setThis part comes from classical_training.ipynb.
|
Step 5 Start trainingThis part also comes from classical_training.ipynb.
|
Hi @gushengzhao1996, thank you for your kind words and the detailed description of your problem. This is very helpful!
I googled this, and it seems that PyTorch's multiprocessing (used when
This error occurs when a class's population is strictly smaller than |
@ebennequin Thanks for your reply. First problem. Second problem. |
another questionSorry @ebennequin , I have another question about prediction.
2.How to process the unknown data
I think this part from my_first_few_shot_classifier.ipynb is helpful to me. |
It's common practice in Few-Shot Learning to split the classes (and not the examples inside the classes) between train and val. This way, you're actually validating the ability of your model to solve few-shot tasks on novel classes. In your case, you could save ~40 classes for validation. As for your additional questions, I have to say I am unsure what problem you're trying to solve or what experiments you're trying to run. Could you give me some context? |
Sorry @ebennequin , fsl is completely new to me, so some questions may be a basic concept. Basically, what I want to do now, is to predict a bunch of images' classes (novel data without labels). The First is the support set. The second is how to load the novel data for prediction in batch.
|
In FSL we usually train the model on a large base dataset, and then apply it on novel classes for which we only have a few examples per class. As I understand it, in your case the 219 classes are the novel classes. With only 10 examples per class, you most likely won't get very good results by training your network on them. Instead, you could use your 219*10 examples (or a subset of them) as your support set. Instead of training your own model, you could simply use on-the-shelf models, e.g. from this great library. As for loading, as I explained in #17, the only requirement of EasyFSL is that the query images are fed in a tensor of shape
|
Thanks! |
Hi, thank you so much for your amazing work , I am facing the same issue in my training phase I have 4 classes in my dataset with the following n way n shot and n query error : |
Hi. |
Hi, thank you very much for your reply and suggestions , so basically I tried keeping the different settings for n way k shot with your suggested values also (2 or 3) but it still gives me the same error. Sorry Im new in this , but I did not exactly get what do you mean by checking the number samples in each class in validation set? Im bit confused in between splitting the classes and number of samples in each classes in train test val set. Currently in my val set there are 4 classes and each class has 4 samples and train set 4 classes each has 14 samples. Can you please show your dataset structure ? That would be really helpful. Thanks |
'checking the number of samples in each class in the validation set' means: My dataset has a total of 219 classes, each class has 10 images (samples). As I showed, we don't split the class for each set. |
It's also possible that your samples are not correctly loaded by |
While this may be relevant to your use case, this is not the usual Few-Shot Learning setting, in which the model infers at test time on classes that were not seen during training (nor validation). I assume @shraddha291996 is referring to the usual Few-Shot Learning setting, and therefore their train, val and test classes are different. |
yes exactly, Im trying to perform usual FSL setting so for that number of classes should be different for train test val set right and not the samples inside each classes. |
Hi, thanks for your code, it helps me a lot.
But it also got some problems for a newbie like me.
Although I make the code run successfully now, I also make a lot of compromises to some errors.
I combined the code from classical_training.ipynb and my_first_few_shot_classifier.ipynb.
I post all my code step by step and point out the problems I met.
I am running Windows10.
The environment is created by Anaconda.
Cuda10.2, Cudnn 7.0, PyTorch 1.10.1
At last, great thanks for your code again.
Let's discuss this together.
The text was updated successfully, but these errors were encountered: