Repository navigation
JSON configuration IO. - #5111
Conversation
|
Made the naming more consistent across XGBoost: #5112 . |
1f8f425 to
60b0f88
Compare
|
I wonder why tests are failing. Is this WIP? |
|
I made some extra cleanup and found some problems in existing code. |
|
Got it. Let me know if I can help in any way. |
|
I thought with JSON we can enable a fully restored model from pickle, except I missed the prediction cache. The DMatrix cache is missing. It generates a very small (<1e-7) floating difference due to different floating point errors. Also slower performance. |
e415d25 to
d80e36f
Compare
| fromJson(in["gbtree_train_param"], &tparam_); | ||
| int32_t const n_gpus = xgboost::common::AllVisibleGPUs(); | ||
| if (n_gpus == 0 && tparam_.predictor == PredictorType::kGPUPredictor) { | ||
| tparam_.UpdateAllowUnknown(Args{{"predictor", "auto"}}); |
There was a problem hiding this comment.
YES! This is so much better than my previous hack in #3856
| if (saved_param == "predictor" || saved_param == "gpu_id") { | ||
| cfg_[saved_param] = kv.second; | ||
| LOG(INFO) | ||
| << "Parameter '" << saved_param << "' has been recovered from " | ||
| << "the saved model. It will be set to " | ||
| << RenderParamVal(kv.second) << " for prediction. To " | ||
| << "override the predictor behavior, explicitly set '" | ||
| << saved_param << "' parameter as follows:\n" | ||
| << " * Python package: bst.set_param('" | ||
| << saved_param << "', [new value])\n" | ||
| << " * R package: xgb.parameters(bst) <- list(" | ||
| << saved_param << " = [new value])\n" | ||
| << " * JVM packages: bst.setParam(\"" | ||
| << saved_param << "\", [new value])"; | ||
| } |
RAMitchell
left a comment
There was a problem hiding this comment.
LGTM. A few in-line comments would help me a lot if I ever have to deal with python serialisation code.
|
On a second thought, let me lower down the serialization code into c++, might get rid of one big FIXME. |
fba8189 to
bf552c2
Compare
|
@hcho3 @RAMitchell I moved the concatenation into c++ from Python. This saves me from the trouble of handling R code, also formalize the difference between "Saving model" and "Serialization" in C API. |
RAMitchell
left a comment
There was a problem hiding this comment.
I am a little confused. What is the difference between all of the following
XGBoosterLoadModel/XGBoosterSaveModel
XGBoosterLoadModelFromBuffer
XGBoosterGetModelRaw
XGBoosterSerializeToBuffer/XGBoosterUnserializeFromBuffer
Did you decide to abandon json for python pickling or is this more of a hybrid approach? What is the usefulness of python methods for save_config/load_config with json? Is it just for testing/parameter validation?
|
@RAMitchell With the term "Model" it means saving only the tree, with the term "Config" it means all internal parameters, with the term "Serialization" it means save everything, the two of above combined. Saving config is just an extra bonus for showing the internal parameters of XGBoos t. |
The "Configuration" part of #4732 . See the
saving_model.rstin #4732 for what does the configuration look like.