练习 2请使用已经训练好的模型对测试集进行预测使用下面语句调用模型参数new_model = tfkerasmodelsload_modelmodelsmodel
在调用模型前,需要先对测试集进行预处理,与训练集相同的方式。
假设测试集的特征为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)
原文地址: https://www.cveoy.top/t/topic/fDFF 著作权归作者所有。请勿转载和采集!