I used the outerProduct function in the TensorFlow.js framework on two 1D arrays (a,b), but I am finding it difficult to get the values of the resulting tensor in the regular javascript format.
Even after using .dataSync and Array.from(), I am still unable to get the expected output format. The resulting outer product between the two 1D arrays should give one 2D array, but I am getting 1D array instead.
const a = tf.tensor1d([1, 2]);
const b = tf.tensor1d([3, 4]);
const tensor = tf.outerProduct(b, a);
const values = tensor.dataSync();
const array1 = Array.from(values);
console.log(array1);
The expected result is array1 = [ [ 3, 6 ] , [ 4, 8 ] ], but I am getting array1 = [ 3, 6, 4, 8 ]