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

Method getTestData

mnist-acgan/web-data.js:129–141  ·  view source on GitHub ↗

* Get all test data as a data tensor a 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: The

(numExamples)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected