&quot“ get_labels”但是对于迷你象征?
我目前正在进行几次学习教程的练习,并遇到了一个使用Omniglot数据集的练习。 this 。我希望复制它,但使用Miniimagenet数据集。这个代码块是我一直面临问题的地方。
N_WAY = 5
N_SHOT = 5
N_QUERY = 10
N_EVALUATION_TASKS = 100
test_set.get_labels = lambda: [
instance[1] for instance in test_set._flat_character_images
]
test_sampler = TaskSampler(
test_set, n_way=N_WAY, n_shot=N_SHOT, n_query=N_QUERY, n_tasks=N_EVALUATION_TASKS
)
test_loader = DataLoader(
test_set,
batch_sampler=test_sampler,
num_workers=12,
pin_memory=True,
collate_fn=test_sampler.episodic_collate_fn,
)
我应该在此修改什么:
test_set.get_labels = lambda: [
instance[1] for instance in test_set._flat_character_images
]
为了允许它运行?
这是错误代码:
AttributeError Traceback (most recent call last)
<ipython-input-7-15761ef243cd> in <module>
9 ]
10 test_sampler = TaskSampler(
---> 11 test_set, n_way=N_WAY, n_shot=N_SHOT, n_query=N_QUERY, n_tasks=N_EVALUATION_TASKS
12 )
13
D:\anaconda3\envs\FSL\lib\site-packages\easyfsl\samplers\task_sampler.py in __init__(self, dataset, n_way, n_shot, n_query, n_tasks)
39
40 self.items_per_label = {}
---> 41 for item, label in enumerate(dataset.get_labels()):
42 if label in self.items_per_label.keys():
43 self.items_per_label[label].append(item)
<ipython-input-7-15761ef243cd> in <lambda>()
6 # The sampler needs a dataset with a "get_labels" method. Check the code if you have any doubt!
7 test_set.get_labels = lambda: [
----> 8 instance[1] for instance in test_set._flat_images
9 ]
10 test_sampler = TaskSampler(
D:\anaconda3\envs\FSL\lib\site-packages\torch\utils\data\dataset.py in __getattr__(self, attribute_name)
81 return function
82 else:
---> 83 raise AttributeError
84
85 @classmethod
AttributeError:
I am currently doing some practice on Few-shot learning tutorials and came across one which uses the Omniglot dataset.This. I wish to replicate it but using the miniImageNet dataset. This block of code is where I have been facing issues.
N_WAY = 5
N_SHOT = 5
N_QUERY = 10
N_EVALUATION_TASKS = 100
test_set.get_labels = lambda: [
instance[1] for instance in test_set._flat_character_images
]
test_sampler = TaskSampler(
test_set, n_way=N_WAY, n_shot=N_SHOT, n_query=N_QUERY, n_tasks=N_EVALUATION_TASKS
)
test_loader = DataLoader(
test_set,
batch_sampler=test_sampler,
num_workers=12,
pin_memory=True,
collate_fn=test_sampler.episodic_collate_fn,
)
What should I modify in this:
test_set.get_labels = lambda: [
instance[1] for instance in test_set._flat_character_images
]
In order to allow it to run?
This is the error code:
AttributeError Traceback (most recent call last)
<ipython-input-7-15761ef243cd> in <module>
9 ]
10 test_sampler = TaskSampler(
---> 11 test_set, n_way=N_WAY, n_shot=N_SHOT, n_query=N_QUERY, n_tasks=N_EVALUATION_TASKS
12 )
13
D:\anaconda3\envs\FSL\lib\site-packages\easyfsl\samplers\task_sampler.py in __init__(self, dataset, n_way, n_shot, n_query, n_tasks)
39
40 self.items_per_label = {}
---> 41 for item, label in enumerate(dataset.get_labels()):
42 if label in self.items_per_label.keys():
43 self.items_per_label[label].append(item)
<ipython-input-7-15761ef243cd> in <lambda>()
6 # The sampler needs a dataset with a "get_labels" method. Check the code if you have any doubt!
7 test_set.get_labels = lambda: [
----> 8 instance[1] for instance in test_set._flat_images
9 ]
10 test_sampler = TaskSampler(
D:\anaconda3\envs\FSL\lib\site-packages\torch\utils\data\dataset.py in __getattr__(self, attribute_name)
81 return function
82 else:
---> 83 raise AttributeError
84
85 @classmethod
AttributeError:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论