MCPcopy Index your code
hub / github.com/tensorflow/tfjs-examples / getTestData

Method getTestData

mnist/data.js:126–138  ·  view source on GitHub ↗

* Get all test data as a data tensor and a labels tensor. * * @param {number} numExamples Optional number of examples to get. If not * provided, * all test examples will be returned. * @returns * xs: The data tensor, of shape `[numTestExamples, 28, 28, 1]`. * labels: T

(numExamples)

Source from the content-addressed store, hash-verified

124 * `[numTestExamples, 10]`.
125 */
126 getTestData(numExamples) {
127 let xs = tf.tensor4d(
128 this.testImages,
129 [this.testImages.length / IMAGE_SIZE, IMAGE_H, IMAGE_W, 1]);
130 let labels = tf.tensor2d(
131 this.testLabels, [this.testLabels.length / NUM_CLASSES, NUM_CLASSES]);
132
133 if (numExamples != null) {
134 xs = xs.slice([0, 0, 0, 0], [numExamples, IMAGE_H, IMAGE_W, 1]);
135 labels = labels.slice([0, 0], [numExamples, NUM_CLASSES]);
136 }
137 return {xs, labels};
138 }
139}

Callers 2

trainFunction · 0.45
showPredictionsFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected