MCPcopy
hub / github.com/tensorflow/tfjs / accuracy

Function accuracy

tfjs-vis/src/util/math.ts:242–254  ·  view source on GitHub ↗
(
    labels: Tensor, predictions: Tensor)

Source from the content-addressed store, hash-verified

240 * @doc {heading: 'Metrics', namespace: 'metrics'}
241 */
242export async function accuracy(
243 labels: Tensor, predictions: Tensor): Promise<number> {
244 assertShapesMatch(
245 labels.shape, predictions.shape, 'Error computing accuracy.');
246
247 const eq = labels.equal(predictions);
248 const mean = eq.mean();
249
250 const acc = (await mean.data())[0];
251
252 dispose([eq, mean]);
253 return acc;
254}
255
256/**
257 * Computes per class accuracy between prediction and labels. Each value in

Callers 1

math_test.tsFile · 0.90

Calls 5

assertShapesMatchFunction · 0.90
disposeFunction · 0.90
equalMethod · 0.80
meanMethod · 0.80
dataMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…