I am trying to write a sequence to an RNN sequence in keras. I encoded this program using what I understood from the Internet. First, I marked the text, and then converted the text to a sequence and filled in the form of the variable of function X. The target variable Y was obtained by first moving x to the left and then putting it aside. Finally, I passed my function and target variable to my LSTM model.
This is my code that I wrote in keras for this purpose.
from keras.preprocessing.text import Tokenizer,base_filter from keras.preprocessing.sequence import pad_sequences from keras.models import Sequential from keras.layers import Dense, Activation,Dropout,Embedding from keras.layers import LSTM def shift(seq, n): n = n % len(seq) return seq[n:] + seq[:n] txt="abcdefghijklmn"*100 tk = Tokenizer(nb_words=2000, filters=base_filter(), lower=True, split=" ") tk.fit_on_texts(txt) x = tk.texts_to_sequences(txt)
The problem is that it shows an error
Epoch 1/10 IndexError: index 14 is out of bounds for size 14 Apply node that caused the error: AdvancedSubtensor1(if{inplace}.0, Reshape{1}.0) Toposort index: 80
source share