IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
chirstinaFan opened this issue · 3 comments
chirstinaFan commented
I have some trouble running the train.py, and I guess the problem is here:
def getitem(self, index):
# handle the image redundancy
img_id = index/self.im_div
image = torch.Tensor(self.images[img_id])
caption = self.captions[index]
vocab = self.vocab
And the img_id is not an integer
could you find this problem?
fartashf commented
@chirstinaFan if you fixed the issue, can you give the details for the fix? Thank you.
chirstinaFan commented
img_id = int(index/self.im_div)
And I find another problem. when I try to build vocabulary,there are many mistakes.can you tell me how do you build your vocabulary?
fartashf commented
Interesting. Thanks for reporting the fix.
Can you open another issue for the errors in building the vocabulary and give more details? Thanks.