Creating an array of tensors in tensorflow?
<p>Suppose I have two tensor variables each of size 2x4:</p>

<pre><code>v1 = tf.logical_and(a1, b1)
v2 = tf.logical_and(a2, b2)
</code></pre>

<p>Instead, I want to store these in an array called <code>v</code> which is of size 2x2x4. How do I do this in Tensorflow? The idea would be something like this:</p>

<pre><code>for i in range(2):
  v[i] = tf.logical_and(a[i],b[i])
</code></pre>

<p>How do I initialize <code>v</code>? I tried initializing <code>v</code> as a numpy array which did not work. I also tried initializing it as a tensorflow variable, ie. <code>tf.Variable(tf.zeros([2]))</code> but that does not work either.</p>

<p>Note, <code>a</code> and <code>b</code> are dynamic inputs, ie. they are <code>tf.placeholder</code> variables.</p>

<p>tf.pack() is probably what you are looking for.</p>

python arrays numpy tensorflow