* 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)
| 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 | } |
no outgoing calls
no test coverage detected