Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calculate
base_score
based on input labels for mae. (#8107)
Fit an intercept as base score for abs loss.
- Loading branch information
1 parent
4f42aa5
commit fffb1fc
Showing
42 changed files
with
999 additions
and
343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/*! | ||
* Copyright 2022 by XGBoost Contributors | ||
*/ | ||
#include "numeric.h" | ||
|
||
#include <numeric> // std::accumulate | ||
#include <type_traits> // std::is_same | ||
|
||
#include "threading_utils.h" // MemStackAllocator, ParallelFor, DefaultMaxThreads | ||
#include "xgboost/generic_parameters.h" // Context | ||
#include "xgboost/host_device_vector.h" // HostDeviceVector | ||
|
||
namespace xgboost { | ||
namespace common { | ||
double Reduce(Context const* ctx, HostDeviceVector<float> const& values) { | ||
if (ctx->IsCPU()) { | ||
auto const& h_values = values.ConstHostVector(); | ||
MemStackAllocator<double, DefaultMaxThreads()> result_tloc(ctx->Threads(), 0); | ||
ParallelFor(h_values.size(), ctx->Threads(), | ||
[&](auto i) { result_tloc[omp_get_thread_num()] += h_values[i]; }); | ||
auto result = std::accumulate(result_tloc.cbegin(), result_tloc.cend(), 0.0); | ||
static_assert(std::is_same<decltype(result), double>::value, ""); | ||
return result; | ||
} | ||
return cuda::Reduce(ctx, values); | ||
} | ||
} // namespace common | ||
} // namespace xgboost |
Oops, something went wrong.