在调用模型前,需要先对测试集进行预处理,与训练集相同的方式。

假设测试集的特征为'test_features',标签为'test_labels',则可使用以下代码进行预测:

import tensorflow as tf

# 加载模型
new_model = tf.keras.models.load_model('models.model')

# 对测试集进行预处理
test_features = # 进行测试集特征的预处理
test_labels = # 进行测试集标签的预处理

# 预测测试集标签
predictions = new_model.predict(test_features)

# 输出预测结果
print(predictions)
使用训练好的模型进行测试集预测 - TensorFlow实战教程

原文地址: https://www.cveoy.top/t/topic/ojMj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录