I try to concatenate two tensors using tensorflow.js. If both tensors only contain numeric values it works fine.
var a = tf.tensor2d([[1.0, 2.0, 3.0], [10.0, 20.0, 30.0]]);
var b = tf.tensor2d([[8.0, 7.0, 5.0], [3.0, 11.0, 23.0]]);
var a_concat_b = a.concat(b, 1);
a_concat_b.print();
But if a tensor contains strings it fails.
var c = tf.tensor2d([["1.0", "2.0", "3.0"], ["10.0", "20.0", "30.0"]]);
var d = tf.tensor2d([["8.0", "7.0", "5.0"], ["3.0", "11.0", "23.0"]]);
var c_concat_d = c.concat(d, 1);
c_concat_d.print();
Error message:
Uncaught Error: Argument 'tensors[0]' passed to 'concat' must be numeric tensor, but got string tensor
Is it not possible at all to concatenate tensors containing strings or how could this be achieved?
The tensorflow.js API documentation only says that the types must match:
tf.concat (tensors, axis?)Concatenates a list of
tf.Tensorsalong a given axis.The tensors ranks and types must match, and their sizes must match in all dimensions except
axis.