AntreasAntoniou / HowToTrainYourMAMLPytorch

The original code for the paper "How to train your MAML" along with a replication of the original "Model Agnostic Meta Learning" (MAML) paper in Pytorch.
https://arxiv.org/abs/1810.09502
Other
759 stars 137 forks source link

AttributeError: 'list' object has no attribute 'keys' #41

Open rishabh004-ai opened 2 years ago

rishabh004-ai commented 2 years ago
Traceback (most recent call last):
  File "train_maml_system.py", line 14, in <module>
    maml_system = ExperimentBuilder(model=model, data=data, args=args, device=device)
  File "/workspace/assign_3/HowToTrainYourMAMLPytorch/experiment_builder.py", line 53, in __init__
    self.data = data(args=args, current_iter=self.state['current_iter'])
  File "/workspace/assign_3/HowToTrainYourMAMLPytorch/data.py", line 569, in __init__
    self.dataset = FewShotLearningDatasetParallel(args=args)
  File "/workspace/assign_3/HowToTrainYourMAMLPytorch/data.py", line 159, in __init__
    "train": {key: len(self.datasets['train'][key]) for key in list(self.datasets['train'].keys())},
AttributeError: 'list' object has no attribute 'keys'

i am getting this error for mini imagenet dataset

AntreasAntoniou commented 2 years ago

I am really sorry about this. I recently applied some quick refactoring suggested by sourcery. I checked the changed but it seems this one escaped my attention. I'll resolve this shortly.

rishabh004-ai commented 2 years ago

Thanks a lot.

AntreasAntoniou commented 2 years ago

Can you give it a try now?

AntreasAntoniou commented 2 years ago

I am hoping that 86964701651c06e490271365fedb8789a72ef3f0 fixes it.

rishabh004-ai commented 2 years ago

No, I think line 159 in data.py also needs to be changed.

AntreasAntoniou commented 2 years ago

Is this alright now? I triple checked and it runs fine on my local machine.

AlanZhang1995 commented 2 years ago

I think I find the reason. Please check whether your mini_imagenet_full_size.json is correct. It would become {} if you did not put the dataset in correct place at the first time you run the script. Hope this will help!

sherry0451 commented 2 years ago

I have the same problem. Is that right to place file mini_imagenet_full_size.tar.bz2 under the folder 'datasets'? Is there other parameters needed to be modified?

sherry0451 commented 2 years ago

I solved my problem as follows. First, automatic unzip code didn't work for my testing, so I unzip the file in terminal manually. Then I deleted the json file for miniimagenet in folder 'dataset'. Then it works.