How to create a vector in TensorFlow.js, where the i-th entry is a scalar raised to the i-th power?


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?


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();

    [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

Leave a Reply

(*) Required, Your email will not be published