katerakelly/pytorch-maml

How to solve "IndexError: too many indices for array"?

fuzihaofzh opened this issue · 3 comments

I have encountered the problem "IndexError: too many indices for array". Is it related to the dataset I use? I just download this file (https://github.com/brendenlake/omniglot/blob/master/python/images_evaluation.zip) and put it under data. The log is as follows:

./train-omniglot-5way-1shot.sh
tee: ../logs/maml-omniglot-5way-1shot-TEST: No such file or directory
exp maml-omniglot-5way-1shot-TEST
dataset omniglot
num_cls 5
num_inst 1
batch 1
m_batch 32
num_updates 15000
num_inner_updates 5
lr 1e-1
meta_lr 1e-3
gpu 0
Setting GPU to 0
init weights
init weights
init weights
Traceback (most recent call last):
  File "maml.py", line 230, in <module>
    main()
  File "/home/maple/programs/miniconda2/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/maple/programs/miniconda2/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/maple/programs/miniconda2/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/maple/programs/miniconda2/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "maml.py", line 227, in main
    learner.train(exp)
  File "maml.py", line 151, in train
    mt_loss, mt_acc, mv_loss, mv_acc = self.test()
  File "maml.py", line 113, in test
    tloss, tacc = evaluate(test_net, train_loader)
  File "/home/maple/pytorch-maml/src/score.py", line 30, in evaluate
    loss += l.data.cpu().numpy()[0]
IndexError: too many indices for array

@szitha It works! Thanks for your help.

Perfect!!