Get an iterable tensor without running eval

Is there a way to make Tensor iterable without starting eval()to get my numpy array?

I am trying to iterate through two parts of the tensor after using split()it, but this happens when building the hidden layers of my neural network, so this must happen before I can start the session,

import tensorflow as tf
x = tf.placeholder('float', [None, nbits])
layer = [x]
for i in range(1,numbits):
    layer.append(tf.add(tf.matmul(weights[i-1], layer[i-1]), biases[i-1]))
    aes, bes = tf.split(1, 2, layer[-1])
        if i%2 == 1:
            for am, a, b in zip(add_layer, aes, bes):
                layer.append(am.ex(a, b))

The problem is what layer[-1]is tf.placeholderat this point, therefore aesboth besare both tensors, and I cannot iterate over with zip().

Any ideas would be appreciated.

+4
source share
1 answer

No no; not directly.

Tensorflow : Python, , . ; . , , (session.run(), .eval() ..)

, , session.run(). node .

, Tensorflow , Python (, zip). , , , - , , ( Tensorflow):-) , , Tensorflow.

, , , ( ). tf.split Python, - zip .

, !

+1

All Articles