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

Function evaluate

tensorflow/contrib/eager/python/examples/revnet/main.py:218–230  ·  view source on GitHub ↗

Compute accuracy with the given dataset iterator.

(model, dataset)

Source from the content-addressed store, hash-verified

216
217
218def evaluate(model, dataset):
219 """Compute accuracy with the given dataset iterator."""
220 mean_loss = tfe.metrics.Mean()
221 accuracy = tfe.metrics.Accuracy()
222 for x, y in dataset:
223 logits, _ = model(x, training=False)
224 loss = model.compute_loss(logits=logits, labels=y)
225 accuracy(
226 labels=tf.cast(y, tf.int64),
227 predictions=tf.argmax(logits, axis=1, output_type=tf.int64))
228 mean_loss(loss)
229
230 return accuracy.result().numpy(), mean_loss.result().numpy()
231
232
233if __name__ == "__main__":

Callers 1

mainFunction · 0.70

Calls 8

resultMethod · 0.95
modelFunction · 0.85
compute_lossMethod · 0.80
argmaxMethod · 0.80
accuracyFunction · 0.50
MeanMethod · 0.45
castMethod · 0.45
numpyMethod · 0.45

Tested by

no test coverage detected