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
a86a211b
Unverified
Commit
a86a211b
authored
Jan 11, 2021
by
shiyu1994
Committed by
GitHub
Jan 11, 2021
Browse files
fix bug in corner case of hist bin mismatch (#3694)
parent
c7c4e084
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
9 deletions
+4
-9
src/io/dataset.cpp
src/io/dataset.cpp
+1
-9
src/io/train_share_states.cpp
src/io/train_share_states.cpp
+3
-0
No files found.
src/io/dataset.cpp
View file @
a86a211b
...
...
@@ -556,18 +556,11 @@ MultiValBin* Dataset::GetMultiBinFromAllFeatures(const std::vector<uint32_t>& of
}
}
sum_dense_ratio
/=
ncol
;
const
int
offset
=
(
1.0
f
-
sum_dense_ratio
)
>=
MultiValBin
::
multi_val_bin_sparse_threshold
?
1
:
0
;
int
num_total_bin
=
offset
;
for
(
int
gid
=
0
;
gid
<
num_groups_
;
++
gid
)
{
if
(
feature_groups_
[
gid
]
->
is_multi_val_
)
{
for
(
int
fid
=
0
;
fid
<
feature_groups_
[
gid
]
->
num_feature_
;
++
fid
)
{
const
auto
&
bin_mapper
=
feature_groups_
[
gid
]
->
bin_mappers_
[
fid
];
most_freq_bins
.
push_back
(
bin_mapper
->
GetMostFreqBin
());
num_total_bin
+=
bin_mapper
->
num_bin
();
if
(
most_freq_bins
.
back
()
==
0
)
{
num_total_bin
-=
offset
;
}
#pragma omp parallel for schedule(static, 1)
for
(
int
tid
=
0
;
tid
<
num_threads
;
++
tid
)
{
iters
[
tid
].
emplace_back
(
...
...
@@ -576,7 +569,6 @@ MultiValBin* Dataset::GetMultiBinFromAllFeatures(const std::vector<uint32_t>& of
}
}
else
{
most_freq_bins
.
push_back
(
0
);
num_total_bin
+=
feature_groups_
[
gid
]
->
bin_offsets_
.
back
()
-
offset
;
for
(
int
tid
=
0
;
tid
<
num_threads
;
++
tid
)
{
iters
[
tid
].
emplace_back
(
feature_groups_
[
gid
]
->
FeatureGroupIterator
());
}
...
...
@@ -586,7 +578,7 @@ MultiValBin* Dataset::GetMultiBinFromAllFeatures(const std::vector<uint32_t>& of
Log
::
Debug
(
"Dataset::GetMultiBinFromAllFeatures: sparse rate %f"
,
1.0
-
sum_dense_ratio
);
ret
.
reset
(
MultiValBin
::
CreateMultiValBin
(
num_data_
,
num_total_bin
,
static_cast
<
int
>
(
most_freq_bins
.
size
()),
num_data_
,
offsets
.
back
()
,
static_cast
<
int
>
(
most_freq_bins
.
size
()),
1.0
-
sum_dense_ratio
,
offsets
));
PushDataToMultiValBin
(
num_data_
,
most_freq_bins
,
offsets
,
&
iters
,
ret
.
get
());
ret
->
FinishLoad
();
...
...
src/io/train_share_states.cpp
View file @
a86a211b
...
...
@@ -176,6 +176,9 @@ void MultiValBinWrapper::CopyMultiValBinSubset(
if
(
feature_groups
[
i
]
->
is_multi_val_
)
{
for
(
int
j
=
0
;
j
<
feature_groups
[
i
]
->
num_feature_
;
++
j
)
{
const
auto
&
bin_mapper
=
feature_groups
[
i
]
->
bin_mappers_
[
j
];
if
(
i
==
0
&&
j
==
0
&&
bin_mapper
->
GetMostFreqBin
()
>
0
)
{
num_total_bin
=
1
;
}
int
cur_num_bin
=
bin_mapper
->
num_bin
();
if
(
bin_mapper
->
GetMostFreqBin
()
==
0
)
{
cur_num_bin
-=
offset
;
...
...
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