"...git@developer.sourcefind.cn:tianlh/lightgbm-dcu.git" did not exist on "787780851f911fb96fa2895b05ac792291954cf5"
Commit b1bbebaa authored by Ilya Matiach's avatar Ilya Matiach Committed by Guolin Ke
Browse files

fix num machines check in distributed case (#1611)

parent 08c82ee6
...@@ -785,6 +785,7 @@ void SerialTreeLearner::RenewTreeOutput(Tree* tree, const ObjectiveFunction* obj ...@@ -785,6 +785,7 @@ void SerialTreeLearner::RenewTreeOutput(Tree* tree, const ObjectiveFunction* obj
bag_mapper = bag_indices; bag_mapper = bag_indices;
} }
std::vector<int> n_nozeroworker_perleaf(tree->num_leaves(), 1); std::vector<int> n_nozeroworker_perleaf(tree->num_leaves(), 1);
int num_machines = Network::num_machines();
#pragma omp parallel for schedule(static) #pragma omp parallel for schedule(static)
for (int i = 0; i < tree->num_leaves(); ++i) { for (int i = 0; i < tree->num_leaves(); ++i) {
const double output = static_cast<double>(tree->LeafOutput(i)); const double output = static_cast<double>(tree->LeafOutput(i));
...@@ -795,12 +796,12 @@ void SerialTreeLearner::RenewTreeOutput(Tree* tree, const ObjectiveFunction* obj ...@@ -795,12 +796,12 @@ void SerialTreeLearner::RenewTreeOutput(Tree* tree, const ObjectiveFunction* obj
const double new_output = obj->RenewTreeOutput(output, prediction, index_mapper, bag_mapper, cnt_leaf_data); const double new_output = obj->RenewTreeOutput(output, prediction, index_mapper, bag_mapper, cnt_leaf_data);
tree->SetLeafOutput(i, new_output); tree->SetLeafOutput(i, new_output);
} else { } else {
CHECK(Network::num_machines() > 1); CHECK(num_machines > 1);
tree->SetLeafOutput(i, 0.0); tree->SetLeafOutput(i, 0.0);
n_nozeroworker_perleaf[i] = 0; n_nozeroworker_perleaf[i] = 0;
} }
} }
if (Network::num_machines() > 1) { if (num_machines > 1) {
std::vector<double> outputs(tree->num_leaves()); std::vector<double> outputs(tree->num_leaves());
for (int i = 0; i < tree->num_leaves(); ++i) { for (int i = 0; i < tree->num_leaves(); ++i) {
outputs[i] = static_cast<double>(tree->LeafOutput(i)); outputs[i] = static_cast<double>(tree->LeafOutput(i));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment