Tensorflow While loop with Variable Creation Code here :
x = tf.Variable(100)
c = tf.Constant(2)
n = 100
loops = 50
l1 = tf.Variable(np.random.random(n))
c1 = tf.Variable(np.random.random(n))
x = tf.multiply(c1,tf.exp(-(x-l1)/c))
l2 = tf.Variable(np.random.random(n))
c2 = tf.Variable(np.random.random(n))
x = tf.multiply(c2,tf.exp(-(x-l2)/c))
l3 = tf.Variable(np.random.random(n))
c3 = tf.Variable(np.random.random(n))
x = tf.multiply(c3,tf.exp(-(x-l3)/c))
.....
.....
l50 = tf.Variable(np.random.random(n))
c50 = tf.Variable(np.random.random(n))
x = tf.multiply(c50,tf.exp(-(x-l50)/c))
So, I want to do that in while loop in tensorflow as:
while loop(i from 1 to 50):
l[i] = tf.Variable(np.random.random(n))
c[i] = tf.Variable(np.random.random(n))
x = tf.multiply(c[i],tf.exp(-(x-l[i])/c))
How can I achieve this in tensorflow.
Thanking you
{}(format code) button. You don't need to individually backtick every line.tf.while_loopfor details