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

caption.py:IndexError: tensors used as indices must be long, byte or bool tensors #175

Open
AndreSun98 opened this issue Jun 5, 2022 · 5 comments

Comments

@AndreSun98
Copy link

When I run caption.py,I got the following error:
Traceback (most recent call last):
File "D:/2021/sjt/code/a-PyTorch-Tutorial-to-Image-Captioning-master/caption.py", line 217, in
seq, alphas = caption_image_beam_search(encoder, decoder, args.img, word_map, args.beam_size)
File "D:/2021/sjt/code/a-PyTorch-Tutorial-to-Image-Captioning-master/caption.py", line 113, in caption_image_beam_search
seqs_alpha = torch.cat([seqs_alpha[prev_word_inds.long()], alpha[prev_word_inds].unsqueeze(1)],
IndexError: tensors used as indices must be long, byte or bool tensors

@zhongchaotie
Copy link

I had the same problem

@vernal0
Copy link

vernal0 commented Jul 10, 2022

I have the same problem. Have you solved it?

@HackInSouth
Copy link

    prev_word_inds = top_k_words / vocab_size

You can try changing the "/" in the above code to "//".

@wenshihao1
Copy link

你好,解决了没

@01620syf
Copy link

我也遇到了同样的问题,请问怎么解决

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

6 participants