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
0b9fe27a
Commit
0b9fe27a
authored
Oct 25, 2016
by
Hui Xue
Browse files
t push origin masterMerge branch 'xuehui1991-update_for_dcg'
merge to master.
parents
0dcd422a
bb05a06f
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
src/treelearner/serial_tree_learner.cpp
src/treelearner/serial_tree_learner.cpp
+5
-5
src/treelearner/serial_tree_learner.h
src/treelearner/serial_tree_learner.h
+1
-1
No files found.
src/treelearner/serial_tree_learner.cpp
View file @
0b9fe27a
...
@@ -91,7 +91,7 @@ void SerialTreeLearner::Init(const Dataset* train_data) {
...
@@ -91,7 +91,7 @@ void SerialTreeLearner::Init(const Dataset* train_data) {
// initialize ordered gradients and hessians
// initialize ordered gradients and hessians
ordered_gradients_
=
new
score_t
[
num_data_
];
ordered_gradients_
=
new
score_t
[
num_data_
];
ordered_hessians_
=
new
score_t
[
num_data_
];
ordered_hessians_
=
new
score_t
[
num_data_
];
// if has ordered bin, need allocat
a
a buffer to fast split
// if has ordered bin, need allocat
e
a buffer to fast split
if
(
has_ordered_bin_
)
{
if
(
has_ordered_bin_
)
{
is_data_in_leaf_
=
new
char
[
num_data_
];
is_data_in_leaf_
=
new
char
[
num_data_
];
}
}
...
@@ -239,16 +239,16 @@ bool SerialTreeLearner::BeforeFindBestSplit(int left_leaf, int right_leaf) {
...
@@ -239,16 +239,16 @@ bool SerialTreeLearner::BeforeFindBestSplit(int left_leaf, int right_leaf) {
larger_leaf_histogram_array_
=
nullptr
;
larger_leaf_histogram_array_
=
nullptr
;
}
else
if
(
num_data_in_left_child
<
num_data_in_right_child
)
{
}
else
if
(
num_data_in_left_child
<
num_data_in_right_child
)
{
smaller_leaf
=
left_leaf
;
smaller_leaf
=
left_leaf
;
// put parent(left) leaf's histograms into larger leaf's histgrams
// put parent(left) leaf's histograms into larger leaf's hist
o
grams
larger_leaf_histogram_array_
=
historical_histogram_array_
[
left_leaf
];
larger_leaf_histogram_array_
=
historical_histogram_array_
[
left_leaf
];
smaller_leaf_histogram_array_
=
historical_histogram_array_
[
right_leaf
];
smaller_leaf_histogram_array_
=
historical_histogram_array_
[
right_leaf
];
// We will construc histograms for smaller leaf, and smaller_leaf=left_leaf = parent.
// We will construc histograms for smaller leaf, and smaller_leaf=left_leaf = parent.
// if we don't swap the cache, we will overwrite the parent's hisogram cache.
// if we don't swap the cache, we will overwrite the parent's his
t
ogram cache.
std
::
swap
(
historical_histogram_array_
[
left_leaf
],
historical_histogram_array_
[
right_leaf
]);
std
::
swap
(
historical_histogram_array_
[
left_leaf
],
historical_histogram_array_
[
right_leaf
]);
}
else
{
}
else
{
smaller_leaf
=
right_leaf
;
smaller_leaf
=
right_leaf
;
// put parent(left) leaf's histograms to larger leaf's histgrams
// put parent(left) leaf's histograms to larger leaf's hist
o
grams
larger_leaf_histogram_array_
=
historical_histogram_array_
[
left_leaf
];
larger_leaf_histogram_array_
=
historical_histogram_array_
[
left_leaf
];
smaller_leaf_histogram_array_
=
historical_histogram_array_
[
right_leaf
];
smaller_leaf_histogram_array_
=
historical_histogram_array_
[
right_leaf
];
}
}
...
@@ -331,7 +331,7 @@ void SerialTreeLearner::FindBestThresholds() {
...
@@ -331,7 +331,7 @@ void SerialTreeLearner::FindBestThresholds() {
// only has root leaf
// only has root leaf
if
(
larger_leaf_splits_
==
nullptr
||
larger_leaf_splits_
->
LeafIndex
()
<
0
)
continue
;
if
(
larger_leaf_splits_
==
nullptr
||
larger_leaf_splits_
->
LeafIndex
()
<
0
)
continue
;
// construct histgr
o
ms for large leaf, we initialize larger leaf as the parent,
// construct hist
o
gr
a
ms for large leaf, we initialize larger leaf as the parent,
// so we can just subtract the smaller leaf's histograms
// so we can just subtract the smaller leaf's histograms
larger_leaf_histogram_array_
[
feature_index
].
Subtract
(
smaller_leaf_histogram_array_
[
feature_index
]);
larger_leaf_histogram_array_
[
feature_index
].
Subtract
(
smaller_leaf_histogram_array_
[
feature_index
]);
...
...
src/treelearner/serial_tree_learner.h
View file @
0b9fe27a
...
@@ -120,7 +120,7 @@ protected:
...
@@ -120,7 +120,7 @@ protected:
DataPartition
*
data_partition_
;
DataPartition
*
data_partition_
;
/*! \brief used for generate used features */
/*! \brief used for generate used features */
Random
random_
;
Random
random_
;
/*! \brief used for sub feature training, is_feature_used_[i] = fal
a
se means don't used feature i */
/*! \brief used for sub feature training, is_feature_used_[i] = false means don't used feature i */
bool
*
is_feature_used_
;
bool
*
is_feature_used_
;
/*! \brief cache historical histogram to speed up */
/*! \brief cache historical histogram to speed up */
FeatureHistogram
**
historical_histogram_array_
;
FeatureHistogram
**
historical_histogram_array_
;
...
...
Prev
1
2
Next
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