MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / showTestResults

Function showTestResults

mnist/ui.js:33–60  ·  view source on GitHub ↗
(batch, predictions, labels)

Source from the content-addressed store, hash-verified

31}
32
33export function showTestResults(batch, predictions, labels) {
34 const testExamples = batch.xs.shape[0];
35 imagesElement.innerHTML = '';
36 for (let i = 0; i < testExamples; i++) {
37 const image = batch.xs.slice([i, 0], [1, batch.xs.shape[1]]);
38
39 const div = document.createElement('div');
40 div.className = 'pred-container';
41
42 const canvas = document.createElement('canvas');
43 canvas.className = 'prediction-canvas';
44 draw(image.flatten(), canvas);
45
46 const pred = document.createElement('div');
47
48 const prediction = predictions[i];
49 const label = labels[i];
50 const correct = prediction === label;
51
52 pred.className = `pred ${(correct ? 'pred-correct' : 'pred-incorrect')}`;
53 pred.innerText = `pred: ${prediction}`;
54
55 div.appendChild(pred);
56 div.appendChild(canvas);
57
58 imagesElement.appendChild(div);
59 }
60}
61
62const lossLabelElement = document.getElementById('loss-label');
63const accuracyLabelElement = document.getElementById('accuracy-label');

Callers

nothing calls this directly

Calls 1

drawFunction · 0.70

Tested by

no test coverage detected