Spaces:
Sleeping
Sleeping
Sudhanshu976
commited on
Commit
•
a1a5f99
1
Parent(s):
e7ad38e
fifth
Browse files
pages/7_NEXT_WORD_PREDICTOR.py
CHANGED
@@ -40,6 +40,7 @@ if st.button("PREDICT"):
|
|
40 |
|
41 |
|
42 |
max_len = max([len(x) for x in input_sequences])
|
|
|
43 |
|
44 |
padded_input_sentences = pad_sequences(input_sequences , maxlen = max_len , padding ="pre")
|
45 |
X = padded_input_sentences[:,:-1]
|
@@ -50,7 +51,7 @@ if st.button("PREDICT"):
|
|
50 |
|
51 |
|
52 |
model = Sequential()
|
53 |
-
model.add(Embedding(num_class+1,100,input_length =
|
54 |
|
55 |
model.add(LSTM(250))
|
56 |
|
@@ -65,7 +66,7 @@ if st.button("PREDICT"):
|
|
65 |
|
66 |
|
67 |
output_token = tokenizer.texts_to_sequences([test])[0]
|
68 |
-
padded_token = pad_sequences([output_token] , maxlen=
|
69 |
output = np.argmax(model.predict(padded_token))
|
70 |
for word,index in tokenizer.word_index.items():
|
71 |
if index == output:
|
|
|
40 |
|
41 |
|
42 |
max_len = max([len(x) for x in input_sequences])
|
43 |
+
use = max_len-1
|
44 |
|
45 |
padded_input_sentences = pad_sequences(input_sequences , maxlen = max_len , padding ="pre")
|
46 |
X = padded_input_sentences[:,:-1]
|
|
|
51 |
|
52 |
|
53 |
model = Sequential()
|
54 |
+
model.add(Embedding(num_class+1,100,input_length = use))
|
55 |
|
56 |
model.add(LSTM(250))
|
57 |
|
|
|
66 |
|
67 |
|
68 |
output_token = tokenizer.texts_to_sequences([test])[0]
|
69 |
+
padded_token = pad_sequences([output_token] , maxlen=max_len, padding="pre")
|
70 |
output = np.argmax(model.predict(padded_token))
|
71 |
for word,index in tokenizer.word_index.items():
|
72 |
if index == output:
|