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

Function CheckTopLabel

tensorflow/examples/label_image/main.cc:259–275  ·  view source on GitHub ↗

This is a testing function that returns whether the top label index is the one that's expected.

Source from the content-addressed store, hash-verified

257// This is a testing function that returns whether the top label index is the
258// one that's expected.
259Status CheckTopLabel(const std::vector<Tensor>& outputs, int expected,
260 bool* is_expected) {
261 *is_expected = false;
262 Tensor indices;
263 Tensor scores;
264 const int how_many_labels = 1;
265 TF_RETURN_IF_ERROR(GetTopLabels(outputs, how_many_labels, &indices, &scores));
266 tensorflow::TTypes<int32>::Flat indices_flat = indices.flat<int32>();
267 if (indices_flat(0) != expected) {
268 LOG(ERROR) << "Expected label #" << expected << " but got #"
269 << indices_flat(0);
270 *is_expected = false;
271 } else {
272 *is_expected = true;
273 }
274 return Status::OK();
275}
276
277int main(int argc, char* argv[]) {
278 // These are the command-line flags the program can understand.

Callers 1

mainFunction · 0.70

Calls 1

GetTopLabelsFunction · 0.70

Tested by

no test coverage detected