MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / CheckInvalidLabelIndex

Function CheckInvalidLabelIndex

tensorflow/core/kernels/sparse_xent_op.cc:33–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31
32template <typename Index>
33Status CheckInvalidLabelIndex(const Tensor& labels, int64 max_index) {
34 if (labels.NumElements() == 0) return Status::OK();
35 const auto label_values = labels.vec<Index>();
36 int64 bad_index;
37 auto min_max_dim_value = std::minmax_element(
38 label_values.data(), label_values.data() + label_values.size());
39 if (*min_max_dim_value.first < 0 || *min_max_dim_value.second >= max_index) {
40 bad_index = (*min_max_dim_value.first < 0) ? *min_max_dim_value.first
41 : *min_max_dim_value.second;
42 return errors::InvalidArgument(
43 "Received a label value of ", bad_index,
44 " which is outside the valid range of [0, ", max_index,
45 "). Label values: ", labels.SummarizeValue(labels.NumElements()));
46 }
47 return Status::OK();
48}
49
50template <typename Device, typename T, typename Index>
51class SparseSoftmaxXentWithLogitsOp : public OpKernel {

Callers

nothing calls this directly

Calls 5

InvalidArgumentFunction · 0.85
SummarizeValueMethod · 0.80
NumElementsMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected