model.predict return values

Viewed 1675

I am working in imdb dataset on reviews, when i want to predict the outcome of the user given input using the model.predict method in tensorflow it gives an array. How to interpret the results from that array?

string = str(input())
new_string = token.texts_to_sequences(string)
padded_new_string = pad_sequences(new_string,maxlen = 120, truncating = 'post')
print(model.predict(padded_new_string))

Also i used binary classification using sigmoid

model = tf.keras.Sequential([
    tf.keras.layers.Embedding(10000,16,input_length = 120),
    tf.keras.layers.Flatten(),
    tf.keras.layers.Dense(12,activation = 'relu'),
    tf.keras.layers.Dense(6,activation = 'relu'),
    tf.keras.layers.Dense(1,activation = 'sigmoid')
    ])        

Any help will be helpful

1 Answers

If I'm not mistaken model.predict returns numpy array for each corresponding prediction of the y_test. To interpret the values you could use evaluate method to find the accuracy of your model

score = model.evaluate(x_test, y_test, verbose=0)
print('Test loss:', score[0])
print('Test accuracy:', score[1])
Related