[英]How tensorflow tf.contrib.learn.SVM reload trained model and use predict to classify new data
Training svm model with tensorflow tf.contrib.learn.SVM and saveing model; 使用tensorflow tf.contrib.learn.SVM训练svm模型并保存模型; the codes
密码
feature_columns = [tf.contrib.layers.real_valued_column(feat) for feat in self.feature_columns]
model_dir = os.path.join(define.root, 'src', 'static_data', 'svm_model_dir')
model = svm.SVM(example_id_column='example_id',
feature_columns=feature_columns,
model_dir=model_dir,
config=tf.contrib.learn.RunConfig(save_checkpoints_secs=10))
model.fit(input_fn=lambda: self.input_fun(self.df_train), steps=10000)
results = model.evaluate(input_fn=lambda: self.input_fun(self.df_test), steps=5, metrics=validation_metrics)
for key in sorted(results):
print('% s: % s' % (key, results[key]))
hwo to reload trained model and use predict to classify new data? 如何重新加载经过训练的模型并使用预测对新数据进行分类?
You call svm.SVM(..., model_dir)
and then call the fit()
and evaluate()
method. 您调用
svm.SVM(..., model_dir)
,然后调用fit()
和svm.SVM(..., model_dir)
evaluate()
方法。
You call svm.SVM(..., model_dir)
and then can call predict()
methods. 您调用
svm.SVM(..., model_dir)
,然后可以调用svm.SVM(..., model_dir)
predict()
方法。 Your model will find a trained model in the model_dir
and will load the trained model params. 您的模型将在
model_dir
找到经过训练的模型,并将加载经过训练的模型参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.