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

List Loss error, IndexError: index 4 is out of bounds for dimension 0 with size 4 #21

Closed
muellerzr opened this issue Jun 2, 2019 · 3 comments

Comments

@muellerzr
Copy link

When I run the model, I get IndexError: index 4 is out of bounds for dimension 0 with size 4. The stack trace points to:

     15     raw_logits, concat_logits, part_logits, _, top_n_prob = net(img)
     16     part_loss = list_loss(part_logits.view(batch_size * PROPOSAL_NUM, -1),
---> 17                                label.unsqueeze(1).repeat(1, PROPOSAL_NUM).view(-1)).view(batch_size, PROPOSAL_NUM)
     18     raw_loss = creterion(raw_logits, label)
     19     concat_loss = creterion(concat_logits, label)

.........................................................................................................................
     84 def list_loss(logits, targets):
     85     temp = F.log_softmax(logits, -1)
---> 86     loss = [-temp[i][targets[i].item()] for i in range(logits.size(0))]
     87     return torch.stack(loss)```

@Totoro-wen
Copy link

Hello, how did you solve this problem!

@muellerzr
Copy link
Author

I do not remember as it was months ago. But my fork
Is https://github.com/muellerzr/fastai_nts_net/blob/master/loss_functions.py

Perhaps that can help! :)

@Totoro-wen
Copy link

I do not remember as it was months ago. But my fork
Is https://github.com/muellerzr/fastai_nts_net/blob/master/loss_functions.py

Perhaps that can help! :)

Thanks!

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