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

IndexError: too many indices for array #20

Open
maryhasan opened this issue Jan 28, 2019 · 2 comments
Open

IndexError: too many indices for array #20

maryhasan opened this issue Jan 28, 2019 · 2 comments

Comments

@maryhasan
Copy link

Hi, I got the "IndexError: too many indices for array" error while I was running the file finetune_semeval_class-avg_f1. Here is more details:
torchMoji-master/torchmoji/finetuning.py in (.0)
522
523 model.eval()
--> 524 best_loss = np.mean([calc_loss(loss_op, model(Variable(xv)), Variable(yv)).data.cpu().numpy()[0] for xv, yv in val_gen])
525 print("original val loss", best_loss)
526
IndexError: too many indices for array
Please let me know how I can fix it. Thank you!

@graykode
Copy link

graykode commented Jan 28, 2019

Hello mhasan1, I solved this problem
From
best_loss = np.mean([calc_loss(loss_op, model(Variable(xv)), Variable(yv)).data.cpu().numpy()[0] for xv, yv in val_gen])
To
best_loss = np.mean([calc_loss(loss_op, model(Variable(xv)), Variable(yv)).data.cpu().numpy() for xv, yv in val_gen])

@maryhasan
Copy link
Author

Thank you graykode! It's working now!

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

2 participants