[英]model.predict return values
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.我正在使用 imdb 数据集进行评论,当我想使用 tensorflow 中的 model.predict 方法预测用户给定输入的结果时,它会给出一个数组。 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我也使用 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任何帮助都会有所帮助
If I'm not mistaken model.predict
returns numpy
array for each corresponding prediction of the y_test
.如果我没记错的
model.predict
会为y_test
的每个相应预测返回numpy
数组。 To interpret the values you could use evaluate
method to find the accuracy of your model要解释值,您可以使用
evaluate
方法来查找 model 的准确性
score = model.evaluate(x_test, y_test, verbose=0)
print('Test loss:', score[0])
print('Test accuracy:', score[1])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.