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

Method getTrainData

mnist/data.js:106–113  ·  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

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

Callers 1

trainFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected