dennybritz / rnn-tutorial-rnnlm

Recurrent Neural Network Tutorial, Part 2 - Implementing a RNN in Python and Theano
Apache License 2.0
895 stars 468 forks source link

IndexError: shape mismatch: #10

Closed ichernob closed 7 years ago

ichernob commented 8 years ago

Hi, I'm trying to get intuition in rnnlm and write your code from tutorial step by step. Could you please clarify, why your code throws an exception: "in calculate_total_loss correct_word_predictions = o[np.arange(len(y)), y[i]] IndexError: shape mismatch: indexing arrays could not be broadcast together with shapes (1000,) (20,) "? I'm using python 3

Thanks in advance.

P.S. It would be great if you also kindly clarify some points about your data file "reddit-comments-2015-08.csv":

  1. As i understand, comments in csv file must be separated by double quotes, but it is wrong in your file.
  2. Also i tried use just half of file content, but in that case i always get error: "in sentences = itertools.chain(*[nltk.sent_tokenize(x[0].lower()) for x in reader]) IndexError: list index out of range".

I would be appreciate if you kindly clarify these points.