Я обучил модель, она показывает все 4 прогноза и сохранила ее в формате json.Когда я пытаюсь загрузить его и сделать прогноз, он показывает только один прогноз.Что может происходить?
Мой код:
test = pd.read_csv('./Data/test.tsv', sep="\t")
from nltk.tokenize import word_tokenize
from nltk import FreqDist
from nltk.stem import SnowballStemmer,WordNetLemmatizer
stemmer=SnowballStemmer('english')
lemma=WordNetLemmatizer()
from string import punctuation
import re
testing = test.Phrase.apply(lambda x: x.lower())
tokenizer = Tokenizer(num_words= 10000)
X_test = tokenizer.texts_to_sequences(testing.values)
X_test = sequence.pad_sequences(X_test, maxlen=48)
json_file = open('model1.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
loaded_model = model_from_json(loaded_model_json)
# Load weights into new model
loaded_model.load_weights('model1.h5')
loaded_model.compile(loss='categorical_crossentropy',
optimizer=Adam(lr=0.001),
metrics=['accuracy'])
prediction = model.predict_classes(X_test,verbose=1)
model.summary()#while training
Layer (type) Output Shape Param #
=================================================================
embedding_1 (Embedding) (None, None, 100) 1373200
_________________________________________________________________
lstm_1 (LSTM) (None, None, 64) 42240
_________________________________________________________________
lstm_2 (LSTM) (None, 32) 12416
_________________________________________________________________
dense_1 (Dense) (None, 5) 165
=================================================================
Total params: 1,428,021
Trainable params: 1,428,021
Non-trainable params: 0
print(X_test.shape)
(66292, 48)