Issue
I want to create a vector in TensorFlow.js, which has the following structure:
where a
is a non-complex scalar, n
is the length of the vector, and i
is the i
-th entry of the vector, starting to count at zero.
Is there a fast way of doing this or do I need to loop?
Solution
IIUC, you could try maybe something like this:
x = tf.tensor1d([1, 2, 3, 4, 5, 6, 7, 8]).toInt();
y = tf.range(0, x.shape[0], 1).toInt();
x.pow(y).print();
"Tensor
[1, 2, 9, 64, 625, 7776, 117649, 2097152]"
Answered By – AloneTogether
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0