diff --git a/src/io/page_fmatrix-inl.hpp b/src/io/page_fmatrix-inl.hpp index 0527da827..44cb9abdc 100644 --- a/src/io/page_fmatrix-inl.hpp +++ b/src/io/page_fmatrix-inl.hpp @@ -339,7 +339,7 @@ class FMatrixPage : public IFMatrix { } if (ktop % 100000 == 0) { utils::Printf("\r \r"); - utils::Printf("InitCol: %lu rows ", static_cast(ktop)); + utils::Printf("InitCol: %lu rows ", static_cast(ktop)); } } } diff --git a/src/learner/learner-inl.hpp b/src/learner/learner-inl.hpp index 630f8fa20..616cf03e9 100644 --- a/src/learner/learner-inl.hpp +++ b/src/learner/learner-inl.hpp @@ -227,14 +227,19 @@ class BoostLearner : public rabit::ISerializable { */ inline void SaveModel(const char *fname) const { FILE *fp; + bool use_stdout = false;; +#ifndef XGBOOST_STRICT_CXX98_ if (!strcmp(fname, "stdout")) { fp = stdout; - } else { + use_stdout = true; + } else +#endif + { fp = utils::FopenCheck(fname, "wb"); } utils::FileStream fo(fp); std::string header; - if (save_base64 != 0|| fp == stdout) { + if (save_base64 != 0|| use_stdout) { fo.Write("bs64\t", 5); utils::Base64OutStream bout(fp); this->SaveModel(bout); @@ -243,7 +248,9 @@ class BoostLearner : public rabit::ISerializable { fo.Write("binf", 4); this->SaveModel(fo); } - if (fp != stdout) fclose(fp); + if (!use_stdout) { + fclose(fp); + } } /*! * \brief check if data matrix is ready to be used by training, diff --git a/src/learner/objective-inl.hpp b/src/learner/objective-inl.hpp index 7702774f9..9887e7a05 100644 --- a/src/learner/objective-inl.hpp +++ b/src/learner/objective-inl.hpp @@ -206,7 +206,8 @@ class SoftmaxMultiClassObj : public IObjFunction { Softmax(&rec); const unsigned j = i % nstep; int label = static_cast(info.labels[j]); - utils::Check(label < nclass, "SoftmaxMultiClassObj: label exceed num_class"); + utils::Check(label >= 0 && label < nclass, + "SoftmaxMultiClassObj: label must be in [0, num_class)"); const float wt = info.GetWeight(j); for (int k = 0; k < nclass; ++k) { float p = rec[k]; diff --git a/src/utils/matrix_csr.h b/src/utils/matrix_csr.h index bc9479cc3..14e0667ee 100644 --- a/src/utils/matrix_csr.h +++ b/src/utils/matrix_csr.h @@ -208,7 +208,6 @@ struct SparseCSRFileBuilder { fo->Write(BeginPtr(buffer_data), (rptr[end] - rptr[begin]) * sizeof(IndexType)); } } - printf("CSV::begin_dat=%lu\n", begin_data); } protected: inline void WriteBuffer(void) {