Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def predict(text):
- model = TestNeuroConfig.loaded_model
- d = keras.datasets.imdb.get_word_index()
- words = text.split()
- review = []
- for word in words:
- if word not in d:
- review.append(2)
- else:
- review.append(d[word] + 3)
- review = keras.preprocessing.sequence.pad_sequences([review],
- truncating='pre', padding='pre', maxlen=10000)
- prediction = model.predict(review)
- print("Prediction (0 = negative, 1 = positive) = ", end="")
- print("%0.4f" % prediction[0][0])
- return prediction[0][0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement