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

Function batchImages

fashion-mnist-vae/data.js:105–119  ·  view source on GitHub ↗

* Take an array of images (represented as typedarrays) and return * a tensor representing them. * * @param {Float32Array[]} imagesData * * @returns {Tensor3d} tensor of input images

(imagesData)

Source from the content-addressed store, hash-verified

103 * @returns {Tensor3d} tensor of input images
104 */
105function batchImages(imagesData) {
106 const numImages = imagesData.length;
107 const flat = [];
108 for (let i = 0; i < numImages; i++) {
109 const image = imagesData[i];
110 for (let j = 0; j < image.length; j++) {
111 flat.push(image[j]);
112 }
113 }
114
115 const batchedTensor =
116 tf.tensor3d(flat, [numImages, IMAGE_WIDTH, IMAGE_HEIGHT], 'float32');
117
118 return batchedTensor;
119}
120
121/**
122 * Convert an image represented as a typed array to a JIMP object.

Callers 1

trainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected