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

Function RunClassification

tensorflow/contrib/session_bundle/signature.cc:115–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115Status RunClassification(const ClassificationSignature& signature,
116 const Tensor& input, Session* session, Tensor* classes,
117 Tensor* scores) {
118 std::vector<string> output_tensor_names;
119 if (classes) {
120 output_tensor_names.push_back(signature.classes().tensor_name());
121 }
122 if (scores) {
123 output_tensor_names.push_back(signature.scores().tensor_name());
124 }
125 // Run the graph with our inputs and outputs.
126 std::vector<Tensor> outputs;
127 const Status run_status =
128 session->Run({{signature.input().tensor_name(), input}},
129 output_tensor_names, {}, &outputs);
130 if (!run_status.ok()) {
131 return run_status;
132 }
133 // Ensure the output is shaped how we expect.
134 // There should be one string Tensor of shape,
135 // [batch_size, num_recommendations].
136 if (outputs.size() != output_tensor_names.size()) {
137 return errors::Internal(
138 strings::StrCat("Expected ", output_tensor_names.size(),
139 " output tensor(s). Got: ", outputs.size()));
140 }
141 if (classes) {
142 *classes = outputs[0];
143 TF_RETURN_IF_ERROR(BatchSizesMatch(input, *classes));
144 }
145 if (scores) {
146 *scores = outputs[classes ? 1 : 0];
147 TF_RETURN_IF_ERROR(BatchSizesMatch(input, *scores));
148 }
149 return Status::OK();
150}
151
152Status GetRegressionSignature(const tensorflow::MetaGraphDef& meta_graph_def,
153 RegressionSignature* signature) {

Callers 2

TEST_FFunction · 0.85
TESTFunction · 0.85

Calls 11

InternalFunction · 0.85
BatchSizesMatchFunction · 0.85
StrCatFunction · 0.50
push_backMethod · 0.45
tensor_nameMethod · 0.45
classesMethod · 0.45
scoresMethod · 0.45
RunMethod · 0.45
inputMethod · 0.45
okMethod · 0.45
sizeMethod · 0.45

Tested by 2

TEST_FFunction · 0.68
TESTFunction · 0.68