Skip to content

Commit

Permalink
Restore.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Mar 27, 2023
1 parent a017e0d commit 05a7e32
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/data/data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@ void MetaInfo::SetInfoFromHost(Context const& ctx, StringView key, Json arr) {
return;
} else if (key == "label") {
CopyTensorInfoImpl(ctx, arr, &this->labels);
if (this->num_row_ != 0 && this->labels.Shape(0) != this->num_row_) {
CHECK_EQ(this->labels.Size() % this->num_row_, 0) << "Incorrect size for labels.";
size_t n_targets = this->labels.Size() / this->num_row_;
this->labels.Reshape(this->num_row_, n_targets);
}
auto const& h_labels = labels.Data()->ConstHostVector();
auto valid = std::none_of(h_labels.cbegin(), h_labels.cend(), data::LabelsCheck{});
CHECK(valid) << "Label contains NaN, infinity or a value too large.";
Expand Down Expand Up @@ -740,6 +745,7 @@ void MetaInfo::Validate(std::int32_t device) const {
return;
}
if (labels.Size() != 0) {
std::cout << labels.Shape(0) << " nr:" << num_row_ << std::endl;
CHECK_EQ(labels.Shape(0), num_row_) << "Size of labels must equal to number of rows.";
CheckDevice(device, labels);
return;
Expand Down

0 comments on commit 05a7e32

Please sign in to comment.