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

Questions about using the given dataset for training(such as miniImagenet) and using my own dataset for testing! #54

Closed
MasterWinston opened this issue Oct 4, 2022 · 5 comments

Comments

@MasterWinston
Copy link

Hello, as described in the title, how do I handle my own dataset after training with the miniImagenet dataset you have given ? For example,my dataset has 4 classes and each class has about 100 images,
Do I need to process my dataset into the following format?

MyDataset_folder/
├── images/
│ ├── images_1.jpg
│ ├── ...
│ └── images_n.jpg
├── train.csv *
├── test.csv *
└── val.csv *

Or do I need to put all my datasets into the miniImagenet dataset and create a new test.csv to replace the original test.csv in the miniImagenet dataset?

Or other methods?

Look forward to your reply, thank you!

@wZuck
Copy link
Member

wZuck commented Oct 4, 2022

Yes, you need to process your dataset in such a format and set the data_root to the folder. Notice that the format of your *.csv should be the same as miniimagenet. When training/testing on your dataset, you should make sure your dataset can handle your setting.(for example, if there are only 4 classes in your dataset, you should set way_num <=4)

Another solution is to modify the core/data/dataset.py to read your dataset.

@MasterWinston
Copy link
Author

其实我是想试试先用miniImagenet训练得到一个不错的model,然后再用这个model在自己的数据集上测试。

另外我刚跑run_test.py代码报了如下错误:
Traceback (most recent call last):
File "E:/Desktop/fewshot/LibFewShot/run_test.py", line 27, in
main(0, config)
File "E:/Desktop/fewshot/LibFewShot/run_test.py", line 22, in main
test.test_loop()
File "E:\Desktop\fewshot\LibFewShot\core\test.py", line 61, in test_loop
_, accuracies = self._validate(epoch_idx)
File "E:\Desktop\fewshot\LibFewShot\core\test.py", line 104, in _validate
prefetcher = data_prefetcher(self.test_loader)
File "E:\Desktop\fewshot\LibFewShot\core\utils\utils.py", line 303, in init
self.preload()
File "E:\Desktop\fewshot\LibFewShot\core\utils\utils.py", line 313, in preload
self.next_data = [data.cuda(non_blocking=True) for data in self.next_data]
File "E:\Desktop\fewshot\LibFewShot\core\utils\utils.py", line 313, in
self.next_data = [data.cuda(non_blocking=True) for data in self.next_data]
AttributeError: 'list' object has no attribute 'cuda'

请问这是什么原因呢?
ps:run_trainer.py已成功跑完。

@wZuck
Copy link
Member

wZuck commented Oct 4, 2022

请重新pull一下代码,这个问题前几天修复了一下

@MasterWinston
Copy link
Author

您好,我又有新问题了:)。
我想知道MAML方法外层循环中的θ参数更新时对应的代码位置。我能找到的只有MAML.py里的set_forward_adaptation函数,它似乎是在每个episode后对内层参数的更新,得到多个θ' 。我并没有找到根据多个θ'来对θ进行更新的代码块。

Hope your reply!
Thanks!

@yangcedrus
Copy link
Contributor

MAML的过程内循环更新θ',外循环通过θ'更新θ。

其中内循环通过手动更新的方式进行的原因是如果内循环使用pytorch的optimizer进行更新,pytorch不可避免地会进行梯度释放等操作,难以处理。但是外循环θ的更新,可以直接使用pytorch的optimizer进行更新,这一步和其他的方法并没有什么不同,因此封装在了trainer.py中。

因此maml.py中并没有外循环更新的代码。

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

3 participants