Fix #3342 and h2oai/h2o4gpu#625: Save predictor parameters in model file (#3856)

* Fix #3342 and h2oai/h2o4gpu#625: Save predictor parameters in model file

This allows pickled models to retain predictor attributes, such as
'predictor' (whether to use CPU or GPU) and 'n_gpu' (number of GPUs
to use). Related: h2oai/h2o4gpu#625

Closes #3342.

TODO. Write a test.

* Fix lint

* Do not load GPU predictor into CPU-only XGBoost

* Add a test for pickling GPU predictors

* Make sample data big enough to pass multi GPU test

* Update test_gpu_predictor.cu
This commit is contained in:
Philip Hyunsu Cho
2018-11-03 21:45:38 -07:00
committed by GitHub
parent e04ab56b57
commit 91537e7353
7 changed files with 206 additions and 51 deletions

View File

@@ -10,6 +10,7 @@
#include <rabit/rabit.h>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include "./base.h"
@@ -178,6 +179,12 @@ class Learner : public rabit::Serializable {
*/
static Learner* Create(const std::vector<std::shared_ptr<DMatrix> >& cache_data);
/*!
* \brief Get configuration arguments currently stored by the learner
* \return Key-value pairs representing configuration arguments
*/
virtual const std::map<std::string, std::string>& GetConfigurationArguments() const = 0;
protected:
/*! \brief internal base score of the model */
bst_float base_score_;