Fix dump model. (#5485)

This commit is contained in:
Jiaming Yuan 2020-04-05 03:52:54 +08:00 committed by GitHub
parent 5fc5ec539d
commit a9313802ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 5 deletions

View File

@ -199,7 +199,7 @@ class Learner : public Model, public Configurable, public rabit::Serializable {
*/
virtual std::vector<std::string> DumpModel(const FeatureMap& fmap,
bool with_stats,
std::string format) const = 0;
std::string format) = 0;
virtual XGBAPIThreadLocalEntry& GetThreadLocal() const = 0;
/*!

View File

@ -663,7 +663,6 @@ inline void XGBoostDumpModelImpl(BoosterHandle handle, const FeatureMap &fmap,
auto *bst = static_cast<Learner*>(handle);
std::vector<std::string>& str_vecs = bst->GetThreadLocal().ret_vec_str;
std::vector<const char*>& charp_vecs = bst->GetThreadLocal().ret_vec_charp;
bst->Configure();
str_vecs = bst->DumpModel(fmap, with_stats != 0, format);
charp_vecs.resize(str_vecs.size());
for (size_t i = 0; i < str_vecs.size(); ++i) {

View File

@ -897,9 +897,8 @@ class LearnerImpl : public LearnerIO {
std::vector<std::string> DumpModel(const FeatureMap& fmap,
bool with_stats,
std::string format) const override {
CHECK(!this->need_configuration_)
<< "The model hasn't been built yet. Are you using raw Booster interface?";
std::string format) override {
this->Configure();
return gbm_->DumpModel(fmap, with_stats, format);
}