Commit 92e95e62 authored by Lingyi Hu's avatar Lingyi Hu Committed by Guolin Ke
Browse files

fix trival typo (#1915)

parent c9bcba44
...@@ -92,8 +92,8 @@ public: ...@@ -92,8 +92,8 @@ public:
inline int num_bin() const { return num_bin_; } inline int num_bin() const { return num_bin_; }
/*! \brief Missing Type */ /*! \brief Missing Type */
inline MissingType missing_type() const { return missing_type_; } inline MissingType missing_type() const { return missing_type_; }
/*! \brief True if bin is trival (contains only one bin) */ /*! \brief True if bin is trivial (contains only one bin) */
inline bool is_trival() const { return is_trival_; } inline bool is_trivial() const { return is_trivial_; }
/*! \brief Sparsity of this bin ( num_zero_bins / num_data ) */ /*! \brief Sparsity of this bin ( num_zero_bins / num_data ) */
inline double sparse_rate() const { return sparse_rate_; } inline double sparse_rate() const { return sparse_rate_; }
/*! /*!
...@@ -190,8 +190,8 @@ private: ...@@ -190,8 +190,8 @@ private:
MissingType missing_type_; MissingType missing_type_;
/*! \brief Store upper bound for each bin */ /*! \brief Store upper bound for each bin */
std::vector<double> bin_upper_bound_; std::vector<double> bin_upper_bound_;
/*! \brief True if this feature is trival */ /*! \brief True if this feature is trivial */
bool is_trival_; bool is_trivial_;
/*! \brief Sparse rate of this bins( num_bin0/num_data ) */ /*! \brief Sparse rate of this bins( num_bin0/num_data ) */
double sparse_rate_; double sparse_rate_;
/*! \brief Type of this bin */ /*! \brief Type of this bin */
......
...@@ -25,7 +25,7 @@ namespace LightGBM { ...@@ -25,7 +25,7 @@ namespace LightGBM {
BinMapper::BinMapper(const BinMapper& other) { BinMapper::BinMapper(const BinMapper& other) {
num_bin_ = other.num_bin_; num_bin_ = other.num_bin_;
missing_type_ = other.missing_type_; missing_type_ = other.missing_type_;
is_trival_ = other.is_trival_; is_trivial_ = other.is_trivial_;
sparse_rate_ = other.sparse_rate_; sparse_rate_ = other.sparse_rate_;
bin_type_ = other.bin_type_; bin_type_ = other.bin_type_;
if (bin_type_ == BinType::NumericalBin) { if (bin_type_ == BinType::NumericalBin) {
...@@ -376,24 +376,24 @@ namespace LightGBM { ...@@ -376,24 +376,24 @@ namespace LightGBM {
} }
} }
// check trival(num_bin_ == 1) feature // check trivial(num_bin_ == 1) feature
if (num_bin_ <= 1) { if (num_bin_ <= 1) {
is_trival_ = true; is_trivial_ = true;
} else { } else {
is_trival_ = false; is_trivial_ = false;
} }
// check useless bin // check useless bin
if (!is_trival_ && NeedFilter(cnt_in_bin, static_cast<int>(total_sample_cnt), min_split_data, bin_type_)) { if (!is_trivial_ && NeedFilter(cnt_in_bin, static_cast<int>(total_sample_cnt), min_split_data, bin_type_)) {
is_trival_ = true; is_trivial_ = true;
} }
if (!is_trival_) { if (!is_trivial_) {
default_bin_ = ValueToBin(0); default_bin_ = ValueToBin(0);
if (bin_type_ == BinType::CategoricalBin) { if (bin_type_ == BinType::CategoricalBin) {
CHECK(default_bin_ > 0); CHECK(default_bin_ > 0);
} }
} }
if (!is_trival_) { if (!is_trivial_) {
// calculate sparse rate // calculate sparse rate
sparse_rate_ = static_cast<double>(cnt_in_bin[default_bin_]) / static_cast<double>(total_sample_cnt); sparse_rate_ = static_cast<double>(cnt_in_bin[default_bin_]) / static_cast<double>(total_sample_cnt);
} else { } else {
...@@ -420,8 +420,8 @@ namespace LightGBM { ...@@ -420,8 +420,8 @@ namespace LightGBM {
buffer += sizeof(num_bin_); buffer += sizeof(num_bin_);
std::memcpy(buffer, &missing_type_, sizeof(missing_type_)); std::memcpy(buffer, &missing_type_, sizeof(missing_type_));
buffer += sizeof(missing_type_); buffer += sizeof(missing_type_);
std::memcpy(buffer, &is_trival_, sizeof(is_trival_)); std::memcpy(buffer, &is_trivial_, sizeof(is_trivial_));
buffer += sizeof(is_trival_); buffer += sizeof(is_trivial_);
std::memcpy(buffer, &sparse_rate_, sizeof(sparse_rate_)); std::memcpy(buffer, &sparse_rate_, sizeof(sparse_rate_));
buffer += sizeof(sparse_rate_); buffer += sizeof(sparse_rate_);
std::memcpy(buffer, &bin_type_, sizeof(bin_type_)); std::memcpy(buffer, &bin_type_, sizeof(bin_type_));
...@@ -444,8 +444,8 @@ namespace LightGBM { ...@@ -444,8 +444,8 @@ namespace LightGBM {
buffer += sizeof(num_bin_); buffer += sizeof(num_bin_);
std::memcpy(&missing_type_, buffer, sizeof(missing_type_)); std::memcpy(&missing_type_, buffer, sizeof(missing_type_));
buffer += sizeof(missing_type_); buffer += sizeof(missing_type_);
std::memcpy(&is_trival_, buffer, sizeof(is_trival_)); std::memcpy(&is_trivial_, buffer, sizeof(is_trivial_));
buffer += sizeof(is_trival_); buffer += sizeof(is_trivial_);
std::memcpy(&sparse_rate_, buffer, sizeof(sparse_rate_)); std::memcpy(&sparse_rate_, buffer, sizeof(sparse_rate_));
buffer += sizeof(sparse_rate_); buffer += sizeof(sparse_rate_);
std::memcpy(&bin_type_, buffer, sizeof(bin_type_)); std::memcpy(&bin_type_, buffer, sizeof(bin_type_));
...@@ -472,7 +472,7 @@ namespace LightGBM { ...@@ -472,7 +472,7 @@ namespace LightGBM {
void BinMapper::SaveBinaryToFile(const VirtualFileWriter* writer) const { void BinMapper::SaveBinaryToFile(const VirtualFileWriter* writer) const {
writer->Write(&num_bin_, sizeof(num_bin_)); writer->Write(&num_bin_, sizeof(num_bin_));
writer->Write(&missing_type_, sizeof(missing_type_)); writer->Write(&missing_type_, sizeof(missing_type_));
writer->Write(&is_trival_, sizeof(is_trival_)); writer->Write(&is_trivial_, sizeof(is_trivial_));
writer->Write(&sparse_rate_, sizeof(sparse_rate_)); writer->Write(&sparse_rate_, sizeof(sparse_rate_));
writer->Write(&bin_type_, sizeof(bin_type_)); writer->Write(&bin_type_, sizeof(bin_type_));
writer->Write(&min_val_, sizeof(min_val_)); writer->Write(&min_val_, sizeof(min_val_));
...@@ -486,7 +486,7 @@ namespace LightGBM { ...@@ -486,7 +486,7 @@ namespace LightGBM {
} }
size_t BinMapper::SizesInByte() const { size_t BinMapper::SizesInByte() const {
size_t ret = sizeof(num_bin_) + sizeof(missing_type_) + sizeof(is_trival_) + sizeof(sparse_rate_) size_t ret = sizeof(num_bin_) + sizeof(missing_type_) + sizeof(is_trivial_) + sizeof(sparse_rate_)
+ sizeof(bin_type_) + sizeof(min_val_) + sizeof(max_val_) + sizeof(default_bin_); + sizeof(bin_type_) + sizeof(min_val_) + sizeof(max_val_) + sizeof(default_bin_);
if (bin_type_ == BinType::NumericalBin) { if (bin_type_ == BinType::NumericalBin) {
ret += sizeof(double) * num_bin_; ret += sizeof(double) * num_bin_;
......
...@@ -221,7 +221,7 @@ void Dataset::Construct( ...@@ -221,7 +221,7 @@ void Dataset::Construct(
// get num_features // get num_features
std::vector<int> used_features; std::vector<int> used_features;
for (int i = 0; i < static_cast<int>(bin_mappers.size()); ++i) { for (int i = 0; i < static_cast<int>(bin_mappers.size()); ++i) {
if (bin_mappers[i] != nullptr && !bin_mappers[i]->is_trival()) { if (bin_mappers[i] != nullptr && !bin_mappers[i]->is_trivial()) {
used_features.emplace_back(i); used_features.emplace_back(i);
} }
} }
......
...@@ -249,7 +249,7 @@ void GPUTreeLearner::AllocateGPUMemory() { ...@@ -249,7 +249,7 @@ void GPUTreeLearner::AllocateGPUMemory() {
sparse_feature_group_map_.clear(); sparse_feature_group_map_.clear();
// do nothing if no features can be processed on GPU // do nothing if no features can be processed on GPU
if (!num_dense_feature_groups_) { if (!num_dense_feature_groups_) {
Log::Warning("GPU acceleration is disabled because no non-trival dense features can be found"); Log::Warning("GPU acceleration is disabled because no non-trivial dense features can be found");
return; return;
} }
// allocate memory for all features (FIXME: 4 GB barrier on some devices, need to split to multiple buffers) // allocate memory for all features (FIXME: 4 GB barrier on some devices, need to split to multiple buffers)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment