Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
92e95e62
Commit
92e95e62
authored
Dec 20, 2018
by
Lingyi Hu
Committed by
Guolin Ke
Dec 20, 2018
Browse files
fix trival typo (#1915)
parent
c9bcba44
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
20 deletions
+20
-20
include/LightGBM/bin.h
include/LightGBM/bin.h
+4
-4
src/io/bin.cpp
src/io/bin.cpp
+14
-14
src/io/dataset.cpp
src/io/dataset.cpp
+1
-1
src/treelearner/gpu_tree_learner.cpp
src/treelearner/gpu_tree_learner.cpp
+1
-1
No files found.
include/LightGBM/bin.h
View file @
92e95e62
...
@@ -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 triv
i
al (contains only one bin) */
inline
bool
is_trival
()
const
{
return
is_trival_
;
}
inline
bool
is_triv
i
al
()
const
{
return
is_triv
i
al_
;
}
/*! \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 triv
i
al */
bool
is_trival_
;
bool
is_triv
i
al_
;
/*! \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 */
...
...
src/io/bin.cpp
View file @
92e95e62
...
@@ -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_triv
i
al_
=
other
.
is_triv
i
al_
;
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 triv
i
al(num_bin_ == 1) feature
if
(
num_bin_
<=
1
)
{
if
(
num_bin_
<=
1
)
{
is_trival_
=
true
;
is_triv
i
al_
=
true
;
}
else
{
}
else
{
is_trival_
=
false
;
is_triv
i
al_
=
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_triv
i
al_
&&
NeedFilter
(
cnt_in_bin
,
static_cast
<
int
>
(
total_sample_cnt
),
min_split_data
,
bin_type_
))
{
is_trival_
=
true
;
is_triv
i
al_
=
true
;
}
}
if
(
!
is_trival_
)
{
if
(
!
is_triv
i
al_
)
{
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_triv
i
al_
)
{
// 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_triv
i
al_
,
sizeof
(
is_triv
i
al_
));
buffer
+=
sizeof
(
is_trival_
);
buffer
+=
sizeof
(
is_triv
i
al_
);
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_triv
i
al_
,
buffer
,
sizeof
(
is_triv
i
al_
));
buffer
+=
sizeof
(
is_trival_
);
buffer
+=
sizeof
(
is_triv
i
al_
);
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_triv
i
al_
,
sizeof
(
is_triv
i
al_
));
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_triv
i
al_
)
+
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_
;
...
...
src/io/dataset.cpp
View file @
92e95e62
...
@@ -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_triv
i
al
())
{
used_features
.
emplace_back
(
i
);
used_features
.
emplace_back
(
i
);
}
}
}
}
...
...
src/treelearner/gpu_tree_learner.cpp
View file @
92e95e62
...
@@ -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-triv
i
al 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)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment