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: index 250 is out of bounds for axis 0 with size 250 #21

Closed
ghost opened this issue Feb 1, 2018 · 2 comments
Closed

IndexError: index 250 is out of bounds for axis 0 with size 250 #21

ghost opened this issue Feb 1, 2018 · 2 comments

Comments

@ghost
Copy link

ghost commented Feb 1, 2018

Hi,

2018-02-01 3 21 53

When I run the below code I got the IndexError: index 250 is out of bounds for axis 0 with size 250

I can not convert to the ids matrix as described in the tutorial.

My python version is Python 3.5.2

P.S. Thank you so much for the awesome tutorial. The tutorial is really explaining the concepts very well 👍

@ghost
Copy link
Author

ghost commented Feb 1, 2018

Hi,

I added the condition if indexCounter <250: like below to avoid the IndexError: index 250 is out of bounds for axis 0 with size 250 error.

firstFile = np.zeros((maxSeqLength), dtype='int32')
with open(fname) as f:
indexCounter = 0
line=f.readline()
cleanedLine = cleanSentences(line)
split = cleanedLine.split()
for word in split:
try:
if indexCounter <250:
firstFile[indexCounter] = wordsList.index(word)
except ValueError:
firstFile[indexCounter] = 399999 #Vector for unknown words
indexCounter = indexCounter + 1
firstFile

2018-02-01 4 10 41

But this result was different from the output of the tutorial.

Is it okay? :)

@adeshpande3
Copy link
Owner

adeshpande3 commented Feb 3, 2018

Yeah should be okay, it just depends on the order in which the files got extracted. Thanks for bringing this issue up, I'll add the check in the next push

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

1 participant