I'm working in python/tensorflow. I have a tensor x (4 dimensions) and want to take the sum over a slice of the tensor
np.sum(x[:,:,:,0])
I get the error
ValueError: setting an array element with a sequence.
What am I doing wrong?
I'm working in python/tensorflow. I have a tensor x (4 dimensions) and want to take the sum over a slice of the tensor
np.sum(x[:,:,:,0])
I get the error
ValueError: setting an array element with a sequence.
What am I doing wrong?
Assuming you're using TF 1.x, you can't do simple numpy operations on TF tensors (in TF 1.x). Instead do the following.
import tensorflow as tf
x = tf.random_normal(shape=[10, 5, 3, 2])
res = tf.reduce_sum(tf.gather(x, 0, axis=-1))
with tf.Session() as sess:
r = sess.run(res)