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
31302bf7
Commit
31302bf7
authored
Jun 20, 2017
by
Guolin Ke
Browse files
force set to zero to prediction buffer.
parent
d0858b36
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
2 deletions
+3
-2
src/boosting/gbdt.cpp
src/boosting/gbdt.cpp
+1
-0
src/boosting/gbdt_prediction.cpp
src/boosting/gbdt_prediction.cpp
+2
-2
No files found.
src/boosting/gbdt.cpp
View file @
31302bf7
...
...
@@ -774,6 +774,7 @@ std::string GBDT::ModelToIfElse(int num_iteration) const {
std
::
stringstream
pred_str_buf
;
pred_str_buf
<<
"
\t
"
<<
"int early_stop_round_counter = 0;"
<<
std
::
endl
;
pred_str_buf
<<
"
\t
"
<<
"std::memset(output, 0, sizeof(double) * num_tree_per_iteration_);"
<<
std
::
endl
;
pred_str_buf
<<
"
\t
"
<<
"for (int i = 0; i < num_iteration_for_pred_; ++i) {"
<<
std
::
endl
;
pred_str_buf
<<
"
\t\t
"
<<
"for (int k = 0; k < num_tree_per_iteration_; ++k) {"
<<
std
::
endl
;
pred_str_buf
<<
"
\t\t\t
"
<<
"output[k] += (*PredictTreePtr[i * num_tree_per_iteration_ + k])(features);"
<<
std
::
endl
;
...
...
src/boosting/gbdt_prediction.cpp
View file @
31302bf7
...
...
@@ -8,12 +8,13 @@ namespace LightGBM {
void
GBDT
::
PredictRaw
(
const
double
*
features
,
double
*
output
,
const
PredictionEarlyStopInstance
*
early_stop
)
const
{
int
early_stop_round_counter
=
0
;
// set zero
std
::
memset
(
output
,
0
,
sizeof
(
double
)
*
num_tree_per_iteration_
);
for
(
int
i
=
0
;
i
<
num_iteration_for_pred_
;
++
i
)
{
// predict all the trees for one iteration
for
(
int
k
=
0
;
k
<
num_tree_per_iteration_
;
++
k
)
{
output
[
k
]
+=
models_
[
i
*
num_tree_per_iteration_
+
k
]
->
Predict
(
features
);
}
// check early stopping
++
early_stop_round_counter
;
if
(
early_stop
->
round_period
==
early_stop_round_counter
)
{
...
...
@@ -27,7 +28,6 @@ void GBDT::PredictRaw(const double* features, double* output, const PredictionEa
void
GBDT
::
Predict
(
const
double
*
features
,
double
*
output
,
const
PredictionEarlyStopInstance
*
early_stop
)
const
{
PredictRaw
(
features
,
output
,
early_stop
);
if
(
objective_function_
!=
nullptr
)
{
objective_function_
->
ConvertOutput
(
output
,
output
);
}
...
...
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