HowToTrainYourMAMLPytorch icon indicating copy to clipboard operation
HowToTrainYourMAMLPytorch copied to clipboard

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

Open rishabh004-ai opened this issue 2 years ago • 9 comments

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

rishabh004-ai avatar Nov 15 '21 16:11 rishabh004-ai

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.

AntreasAntoniou avatar Nov 15 '21 17:11 AntreasAntoniou

Thanks a lot.

rishabh004-ai avatar Nov 15 '21 17:11 rishabh004-ai

Can you give it a try now?

AntreasAntoniou avatar Nov 15 '21 17:11 AntreasAntoniou

I am hoping that 86964701651c06e490271365fedb8789a72ef3f0 fixes it.

AntreasAntoniou avatar Nov 15 '21 17:11 AntreasAntoniou

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

rishabh004-ai avatar Nov 15 '21 17:11 rishabh004-ai

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

AntreasAntoniou avatar Feb 02 '22 20:02 AntreasAntoniou

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!

AlanZhang1995 avatar Feb 16 '22 19:02 AlanZhang1995

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 avatar Aug 26 '22 06:08 sherry0451

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.

sherry0451 avatar Aug 26 '22 08:08 sherry0451