Closed miftahihsan closed 5 years ago
****(This problem is from NLP number 20)****
Hello, I was having problem saving and loading this model I used model.save(path.h5) to save the model
used the code below to load the model
==========================================================
import tensorflow as tf from tensorflow.python.keras.preprocessing.text import Tokenizer from tensorflow.python.keras.preprocessing.sequence import pad_sequences
pad = 'pre' num_words = 10000 max_tokens = 544
tokenizer = Tokenizer(num_words)
text = ["Great movie!", "Worst Movie ever!"]
tokens = tokenizer.texts_to_sequences(text)
tokens_pad = pad_sequences(tokens, maxlen=max_tokens, padding=pad, truncating=pad)
new_model = tf.keras.models.load_model("path.h5")
new_model.predict(tokens_pad)
===========================================================
my all my results are the same rather then having two different +ve and -ve sentiment
array([[0.57864296], [0.57864296]], dtype=float32)
If possible please do tell me what I am doing wrong, and how to fix this issue Thank You!
****(This problem is from NLP number 20)****
Hello, I was having problem saving and loading this model I used model.save(path.h5) to save the model
used the code below to load the model
==========================================================
import tensorflow as tf from tensorflow.python.keras.preprocessing.text import Tokenizer from tensorflow.python.keras.preprocessing.sequence import pad_sequences
pad = 'pre' num_words = 10000 max_tokens = 544
tokenizer = Tokenizer(num_words)
text = ["Great movie!", "Worst Movie ever!"]
tokens = tokenizer.texts_to_sequences(text)
tokens_pad = pad_sequences(tokens, maxlen=max_tokens, padding=pad, truncating=pad)
new_model = tf.keras.models.load_model("path.h5")
new_model.predict(tokens_pad)
===========================================================
my all my results are the same rather then having two different +ve and -ve sentiment
array([[0.57864296], [0.57864296]], dtype=float32)
If possible please do tell me what I am doing wrong, and how to fix this issue Thank You!