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

Method getTrainData

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

* Get all training data as a data tensor and a labels tensor. * * @returns * xs: The data tensor, of shape `[numTrainExamples, 28, 28, 1]`. * labels: The one-hot encoded labels tensor, of shape * `[numTrainExamples, 10]`.

()

Source from the content-addressed store, hash-verified

107 * `[numTrainExamples, 10]`.
108 */
109 getTrainData() {
110 const xs = tf.tensor4d(
111 this.trainImages,
112 [this.trainImages.length / IMAGE_SIZE, IMAGE_H, IMAGE_W, 1]);
113 const labels = tf.tensor2d(
114 this.trainLabels, [this.trainLabels.length / NUM_CLASSES, NUM_CLASSES]);
115 return {xs, labels};
116 }
117
118 /**
119 * Get all test data as a data tensor a a labels tensor.

Callers 1

loadMnistDataFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected