Q:

Create a tensor of multiple images with tf.browser.fromPixels with Tensorflow JS

I want to create a feature tensor of multiple images, using tf.browser.fromPixels.
const image1 = new ImageData(1, 1);
image1.data[0] = 100;
image1.data[1] = 150;
image1.data[2] = 200;
image1.data[3] = 255;

const image2 = new ImageData(1, 1);
image2.data[0] = 200;
image2.data[1] = 250;
image2.data[2] = 200;
image2.data[3] = 255;

const imageTensor1 = tf.browser.fromPixels(image1);
const imageTensor2 = tf.broser.fromPixels(image2);

// How do I now get imageTensor1 and imageTensor2 into one merged tensor?
const featureData = ???

How can I now merge two tensors into one tensor, contain information about both images? Are there any operations like tensor.push() or anything available? Do I need to keep the values as a array and only merge it into one tensor in the end?

A:

You can concatenate tensors with tf.concat(tensors, axis?)
const a = tf.tensor1d([1, 2]);
const b = tf.tensor1d([3, 4]);
a.concat(b);

Or with multiple tensors
const a = tf.tensor1d([1, 2]);
const b = tf.tensor1d([3, 4]);
const c = tf.tensor1d([5, 6]);
tf.concat([a, b, c]);

