Pytorch Chatbot Tutorial problem: How can I solve List Index Out of Range
I’m new to pytorch and have been following the many tutorials available.
But, When I did The CHATBOT TUTORIAL is not work.
Like the figure below

What should I do and what is causing this?
python nlp pytorch chatbot
add a comment |
I’m new to pytorch and have been following the many tutorials available.
But, When I did The CHATBOT TUTORIAL is not work.
Like the figure below

What should I do and what is causing this?
python nlp pytorch chatbot
1
Please do not put your error messages in the image, but rather paste the text to the actual post instead.
– dennlinger
Nov 11 at 13:01
add a comment |
I’m new to pytorch and have been following the many tutorials available.
But, When I did The CHATBOT TUTORIAL is not work.
Like the figure below

What should I do and what is causing this?
python nlp pytorch chatbot
I’m new to pytorch and have been following the many tutorials available.
But, When I did The CHATBOT TUTORIAL is not work.
Like the figure below

What should I do and what is causing this?
python nlp pytorch chatbot
python nlp pytorch chatbot
edited Dec 18 at 16:05
Cœur
17.4k9102143
17.4k9102143
asked Nov 11 at 9:43
眠咖啡
1
1
1
Please do not put your error messages in the image, but rather paste the text to the actual post instead.
– dennlinger
Nov 11 at 13:01
add a comment |
1
Please do not put your error messages in the image, but rather paste the text to the actual post instead.
– dennlinger
Nov 11 at 13:01
1
1
Please do not put your error messages in the image, but rather paste the text to the actual post instead.
– dennlinger
Nov 11 at 13:01
Please do not put your error messages in the image, but rather paste the text to the actual post instead.
– dennlinger
Nov 11 at 13:01
add a comment |
3 Answers
3
active
oldest
votes
Are you running Windows? Currently most Pytorch tutorial requires Pytorch 1.0 which is currently unavailable on Windows, I'm trying it in a different OS.
Will edit the answer as soon as I get it running on Ubuntu 18.
Yes,i run it on windows, but I import torch without any question. python 3.6 package: pip,CUDA:9.0 it seems some data processing have question.Because Errormessage show:IndexError: list index out of range I'm trying it in a different OS. "Will edit the answer as soon as I get it running on Ubuntu 18. " Ah, It was exhilarating, I will try it as soon as possible. the error seems happens in : def filterPair(p): def filterPairs(pairs): I am very confused about this.
– 眠咖啡
Nov 15 at 23:30
add a comment |
def filter_pair(self, p):
try:
return len(p[0].split(' ')) < self.MAX_LENGTH and len(p[1].split(' '))< self.MAX_LENGTH
except:
return False
This is because some of pairs are empty list
Thanks, But the corpus are cornell movie-dialogs corpus.Corpus <cs.cornell.edu/~cristian/… is a rich dataset of movie character dialog: 220,579 conversational exchanges between 10,292 pairs of movie characters 9,035 characters from 617 movies 304,713 total utterances I am not understanding of the empty list in training data,but it showed Start preparing training data ... Reading lines... Read 442563 sentence pairs
– 眠咖啡
Nov 15 at 23:10
add a comment |
I think the problem is the way the lines are read in resulting in blank lines. You can get over the problem rather crudely by filtering out blank lines. Here is such a crude solution in the readVocs routine.
# Read query/response pairs and return a voc object
def readVocs(datafile, corpus_name):
print("Reading lines...")
# Read the file and split into lines
lines = open(datafile, encoding='utf-8').
read().strip().split('n')
#Now on windows you seem to get alternate blank lines so filter them out.
lines2=
for l in lines:
if len(l)>0:
lines2.append(l)
#And as a check just print the first 10
for index, line in enumerate(lines2[:10]):
print(index,' - ',line)
# Split every line into pairs and normalize
pairs = [[normalizeString(s) for s in l.split('t')] for l in lines2]
voc = Voc(corpus_name)
return voc, pair
I tried the above with the tutorial mentioned and it runs all the way through quite happily on Windows with Torch version 0.4.1
– Mike Sharp
Nov 19 at 18:55
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247475%2fpytorch-chatbot-tutorial-problem-how-can-i-solve-list-index-out-of-range%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Are you running Windows? Currently most Pytorch tutorial requires Pytorch 1.0 which is currently unavailable on Windows, I'm trying it in a different OS.
Will edit the answer as soon as I get it running on Ubuntu 18.
Yes,i run it on windows, but I import torch without any question. python 3.6 package: pip,CUDA:9.0 it seems some data processing have question.Because Errormessage show:IndexError: list index out of range I'm trying it in a different OS. "Will edit the answer as soon as I get it running on Ubuntu 18. " Ah, It was exhilarating, I will try it as soon as possible. the error seems happens in : def filterPair(p): def filterPairs(pairs): I am very confused about this.
– 眠咖啡
Nov 15 at 23:30
add a comment |
Are you running Windows? Currently most Pytorch tutorial requires Pytorch 1.0 which is currently unavailable on Windows, I'm trying it in a different OS.
Will edit the answer as soon as I get it running on Ubuntu 18.
Yes,i run it on windows, but I import torch without any question. python 3.6 package: pip,CUDA:9.0 it seems some data processing have question.Because Errormessage show:IndexError: list index out of range I'm trying it in a different OS. "Will edit the answer as soon as I get it running on Ubuntu 18. " Ah, It was exhilarating, I will try it as soon as possible. the error seems happens in : def filterPair(p): def filterPairs(pairs): I am very confused about this.
– 眠咖啡
Nov 15 at 23:30
add a comment |
Are you running Windows? Currently most Pytorch tutorial requires Pytorch 1.0 which is currently unavailable on Windows, I'm trying it in a different OS.
Will edit the answer as soon as I get it running on Ubuntu 18.
Are you running Windows? Currently most Pytorch tutorial requires Pytorch 1.0 which is currently unavailable on Windows, I'm trying it in a different OS.
Will edit the answer as soon as I get it running on Ubuntu 18.
answered Nov 12 at 13:28
Kapil Pawar
13
13
Yes,i run it on windows, but I import torch without any question. python 3.6 package: pip,CUDA:9.0 it seems some data processing have question.Because Errormessage show:IndexError: list index out of range I'm trying it in a different OS. "Will edit the answer as soon as I get it running on Ubuntu 18. " Ah, It was exhilarating, I will try it as soon as possible. the error seems happens in : def filterPair(p): def filterPairs(pairs): I am very confused about this.
– 眠咖啡
Nov 15 at 23:30
add a comment |
Yes,i run it on windows, but I import torch without any question. python 3.6 package: pip,CUDA:9.0 it seems some data processing have question.Because Errormessage show:IndexError: list index out of range I'm trying it in a different OS. "Will edit the answer as soon as I get it running on Ubuntu 18. " Ah, It was exhilarating, I will try it as soon as possible. the error seems happens in : def filterPair(p): def filterPairs(pairs): I am very confused about this.
– 眠咖啡
Nov 15 at 23:30
Yes,i run it on windows, but I import torch without any question. python 3.6 package: pip,CUDA:9.0 it seems some data processing have question.Because Errormessage show:IndexError: list index out of range I'm trying it in a different OS. "Will edit the answer as soon as I get it running on Ubuntu 18. " Ah, It was exhilarating, I will try it as soon as possible. the error seems happens in : def filterPair(p): def filterPairs(pairs): I am very confused about this.
– 眠咖啡
Nov 15 at 23:30
Yes,i run it on windows, but I import torch without any question. python 3.6 package: pip,CUDA:9.0 it seems some data processing have question.Because Errormessage show:IndexError: list index out of range I'm trying it in a different OS. "Will edit the answer as soon as I get it running on Ubuntu 18. " Ah, It was exhilarating, I will try it as soon as possible. the error seems happens in : def filterPair(p): def filterPairs(pairs): I am very confused about this.
– 眠咖啡
Nov 15 at 23:30
add a comment |
def filter_pair(self, p):
try:
return len(p[0].split(' ')) < self.MAX_LENGTH and len(p[1].split(' '))< self.MAX_LENGTH
except:
return False
This is because some of pairs are empty list
Thanks, But the corpus are cornell movie-dialogs corpus.Corpus <cs.cornell.edu/~cristian/… is a rich dataset of movie character dialog: 220,579 conversational exchanges between 10,292 pairs of movie characters 9,035 characters from 617 movies 304,713 total utterances I am not understanding of the empty list in training data,but it showed Start preparing training data ... Reading lines... Read 442563 sentence pairs
– 眠咖啡
Nov 15 at 23:10
add a comment |
def filter_pair(self, p):
try:
return len(p[0].split(' ')) < self.MAX_LENGTH and len(p[1].split(' '))< self.MAX_LENGTH
except:
return False
This is because some of pairs are empty list
Thanks, But the corpus are cornell movie-dialogs corpus.Corpus <cs.cornell.edu/~cristian/… is a rich dataset of movie character dialog: 220,579 conversational exchanges between 10,292 pairs of movie characters 9,035 characters from 617 movies 304,713 total utterances I am not understanding of the empty list in training data,but it showed Start preparing training data ... Reading lines... Read 442563 sentence pairs
– 眠咖啡
Nov 15 at 23:10
add a comment |
def filter_pair(self, p):
try:
return len(p[0].split(' ')) < self.MAX_LENGTH and len(p[1].split(' '))< self.MAX_LENGTH
except:
return False
This is because some of pairs are empty list
def filter_pair(self, p):
try:
return len(p[0].split(' ')) < self.MAX_LENGTH and len(p[1].split(' '))< self.MAX_LENGTH
except:
return False
This is because some of pairs are empty list
edited Nov 15 at 19:33
pushkin
3,939112651
3,939112651
answered Nov 15 at 19:24
Bibhas
1
1
Thanks, But the corpus are cornell movie-dialogs corpus.Corpus <cs.cornell.edu/~cristian/… is a rich dataset of movie character dialog: 220,579 conversational exchanges between 10,292 pairs of movie characters 9,035 characters from 617 movies 304,713 total utterances I am not understanding of the empty list in training data,but it showed Start preparing training data ... Reading lines... Read 442563 sentence pairs
– 眠咖啡
Nov 15 at 23:10
add a comment |
Thanks, But the corpus are cornell movie-dialogs corpus.Corpus <cs.cornell.edu/~cristian/… is a rich dataset of movie character dialog: 220,579 conversational exchanges between 10,292 pairs of movie characters 9,035 characters from 617 movies 304,713 total utterances I am not understanding of the empty list in training data,but it showed Start preparing training data ... Reading lines... Read 442563 sentence pairs
– 眠咖啡
Nov 15 at 23:10
Thanks, But the corpus are cornell movie-dialogs corpus.Corpus <cs.cornell.edu/~cristian/… is a rich dataset of movie character dialog: 220,579 conversational exchanges between 10,292 pairs of movie characters 9,035 characters from 617 movies 304,713 total utterances I am not understanding of the empty list in training data,but it showed Start preparing training data ... Reading lines... Read 442563 sentence pairs
– 眠咖啡
Nov 15 at 23:10
Thanks, But the corpus are cornell movie-dialogs corpus.Corpus <cs.cornell.edu/~cristian/… is a rich dataset of movie character dialog: 220,579 conversational exchanges between 10,292 pairs of movie characters 9,035 characters from 617 movies 304,713 total utterances I am not understanding of the empty list in training data,but it showed Start preparing training data ... Reading lines... Read 442563 sentence pairs
– 眠咖啡
Nov 15 at 23:10
add a comment |
I think the problem is the way the lines are read in resulting in blank lines. You can get over the problem rather crudely by filtering out blank lines. Here is such a crude solution in the readVocs routine.
# Read query/response pairs and return a voc object
def readVocs(datafile, corpus_name):
print("Reading lines...")
# Read the file and split into lines
lines = open(datafile, encoding='utf-8').
read().strip().split('n')
#Now on windows you seem to get alternate blank lines so filter them out.
lines2=
for l in lines:
if len(l)>0:
lines2.append(l)
#And as a check just print the first 10
for index, line in enumerate(lines2[:10]):
print(index,' - ',line)
# Split every line into pairs and normalize
pairs = [[normalizeString(s) for s in l.split('t')] for l in lines2]
voc = Voc(corpus_name)
return voc, pair
I tried the above with the tutorial mentioned and it runs all the way through quite happily on Windows with Torch version 0.4.1
– Mike Sharp
Nov 19 at 18:55
add a comment |
I think the problem is the way the lines are read in resulting in blank lines. You can get over the problem rather crudely by filtering out blank lines. Here is such a crude solution in the readVocs routine.
# Read query/response pairs and return a voc object
def readVocs(datafile, corpus_name):
print("Reading lines...")
# Read the file and split into lines
lines = open(datafile, encoding='utf-8').
read().strip().split('n')
#Now on windows you seem to get alternate blank lines so filter them out.
lines2=
for l in lines:
if len(l)>0:
lines2.append(l)
#And as a check just print the first 10
for index, line in enumerate(lines2[:10]):
print(index,' - ',line)
# Split every line into pairs and normalize
pairs = [[normalizeString(s) for s in l.split('t')] for l in lines2]
voc = Voc(corpus_name)
return voc, pair
I tried the above with the tutorial mentioned and it runs all the way through quite happily on Windows with Torch version 0.4.1
– Mike Sharp
Nov 19 at 18:55
add a comment |
I think the problem is the way the lines are read in resulting in blank lines. You can get over the problem rather crudely by filtering out blank lines. Here is such a crude solution in the readVocs routine.
# Read query/response pairs and return a voc object
def readVocs(datafile, corpus_name):
print("Reading lines...")
# Read the file and split into lines
lines = open(datafile, encoding='utf-8').
read().strip().split('n')
#Now on windows you seem to get alternate blank lines so filter them out.
lines2=
for l in lines:
if len(l)>0:
lines2.append(l)
#And as a check just print the first 10
for index, line in enumerate(lines2[:10]):
print(index,' - ',line)
# Split every line into pairs and normalize
pairs = [[normalizeString(s) for s in l.split('t')] for l in lines2]
voc = Voc(corpus_name)
return voc, pair
I think the problem is the way the lines are read in resulting in blank lines. You can get over the problem rather crudely by filtering out blank lines. Here is such a crude solution in the readVocs routine.
# Read query/response pairs and return a voc object
def readVocs(datafile, corpus_name):
print("Reading lines...")
# Read the file and split into lines
lines = open(datafile, encoding='utf-8').
read().strip().split('n')
#Now on windows you seem to get alternate blank lines so filter them out.
lines2=
for l in lines:
if len(l)>0:
lines2.append(l)
#And as a check just print the first 10
for index, line in enumerate(lines2[:10]):
print(index,' - ',line)
# Split every line into pairs and normalize
pairs = [[normalizeString(s) for s in l.split('t')] for l in lines2]
voc = Voc(corpus_name)
return voc, pair
answered Nov 18 at 9:42
Mike Sharp
11
11
I tried the above with the tutorial mentioned and it runs all the way through quite happily on Windows with Torch version 0.4.1
– Mike Sharp
Nov 19 at 18:55
add a comment |
I tried the above with the tutorial mentioned and it runs all the way through quite happily on Windows with Torch version 0.4.1
– Mike Sharp
Nov 19 at 18:55
I tried the above with the tutorial mentioned and it runs all the way through quite happily on Windows with Torch version 0.4.1
– Mike Sharp
Nov 19 at 18:55
I tried the above with the tutorial mentioned and it runs all the way through quite happily on Windows with Torch version 0.4.1
– Mike Sharp
Nov 19 at 18:55
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247475%2fpytorch-chatbot-tutorial-problem-how-can-i-solve-list-index-out-of-range%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Please do not put your error messages in the image, but rather paste the text to the actual post instead.
– dennlinger
Nov 11 at 13:01