Merge branch 'master' into unity

Conflicts:
	src/learner/evaluation-inl.hpp
	wrapper/xgboost_R.cpp
	wrapper/xgboost_wrapper.cpp
	wrapper/xgboost_wrapper.h
This commit is contained in:
tqchen
2014-08-26 20:32:07 -07:00
21 changed files with 169 additions and 146 deletions

View File

@@ -51,9 +51,9 @@ class GBLinear : public IGradBooster<FMatrix> {
// for all the output group
for (int gid = 0; gid < ngroup; ++gid) {
double sum_grad = 0.0, sum_hess = 0.0;
const unsigned ndata = static_cast<unsigned>(rowset.size());
const bst_omp_uint ndata = static_cast<bst_omp_uint>(rowset.size());
#pragma omp parallel for schedule(static) reduction(+: sum_grad, sum_hess)
for (unsigned i = 0; i < ndata; ++i) {
for (bst_omp_uint i = 0; i < ndata; ++i) {
bst_gpair &p = gpair[rowset[i] * ngroup + gid];
if (p.hess >= 0.0f) {
sum_grad += p.grad; sum_hess += p.hess;
@@ -65,7 +65,7 @@ class GBLinear : public IGradBooster<FMatrix> {
model.bias()[gid] += dw;
// update grad value
#pragma omp parallel for schedule(static)
for (unsigned i = 0; i < ndata; ++i) {
for (bst_omp_uint i = 0; i < ndata; ++i) {
bst_gpair &p = gpair[rowset[i] * ngroup + gid];
if (p.hess >= 0.0f) {
p.grad += p.hess * dw;
@@ -73,9 +73,9 @@ class GBLinear : public IGradBooster<FMatrix> {
}
}
// number of features
const unsigned nfeat = static_cast<unsigned>(feat_index.size());
const bst_omp_uint nfeat = static_cast<bst_omp_uint>(feat_index.size());
#pragma omp parallel for schedule(static)
for (unsigned i = 0; i < nfeat; ++i) {
for (bst_omp_uint i = 0; i < nfeat; ++i) {
const bst_uint fid = feat_index[i];
for (int gid = 0; gid < ngroup; ++gid) {
double sum_grad = 0.0, sum_hess = 0.0;
@@ -117,9 +117,9 @@ class GBLinear : public IGradBooster<FMatrix> {
// k is number of group
preds.resize(preds.size() + batch.size * ngroup);
// parallel over local batch
const unsigned nsize = static_cast<unsigned>(batch.size);
const bst_omp_uint nsize = static_cast<bst_omp_uint>(batch.size);
#pragma omp parallel for schedule(static)
for (unsigned i = 0; i < nsize; ++i) {
for (bst_omp_uint i = 0; i < nsize; ++i) {
const size_t ridx = batch.base_rowid + i;
// loop over output groups
for (int gid = 0; gid < ngroup; ++gid) {

View File

@@ -94,8 +94,9 @@ class GBTree : public IGradBooster<FMatrix> {
"must have exactly ngroup*nrow gpairs");
std::vector<bst_gpair> tmp(gpair.size()/ngroup);
for (int gid = 0; gid < ngroup; ++gid) {
bst_omp_uint nsize = static_cast<bst_omp_uint>(tmp.size());
#pragma omp parallel for schedule(static)
for (size_t i = 0; i < tmp.size(); ++i) {
for (bst_omp_uint i = 0; i < nsize; ++i) {
tmp[i] = gpair[i * ngroup + gid];
}
this->BoostNewTrees(tmp, fmat, info, gid);
@@ -125,9 +126,9 @@ class GBTree : public IGradBooster<FMatrix> {
while (iter->Next()) {
const SparseBatch &batch = iter->Value();
// parallel over local batch
const unsigned nsize = static_cast<unsigned>(batch.size);
const bst_omp_uint nsize = static_cast<bst_omp_uint>(batch.size);
#pragma omp parallel for schedule(static)
for (unsigned i = 0; i < nsize; ++i) {
for (bst_omp_uint i = 0; i < nsize; ++i) {
const int tid = omp_get_thread_num();
tree::RegTree::FVec &feats = thread_temp[tid];
int64_t ridx = static_cast<int64_t>(batch.base_rowid + i);