1

I was wondering if there is a way to feed a network with multidimensional arrays in tensorflow.

I have a placeholder:

y_ = tf.placeholder(tf.float32, shape=[None, None, 6], name='y')

Where I feed it with a batch of lists of label with a varying dimensions where each labels is of size 6, i.e :

y_batch = [ array([[ 124.77579894,   17.88854382,   65.        ,  136.5       ,
       0.6       ,    0.8       ],
   [  25.17935662,    8.06225775,  158.        ,   27.5       ,
       0.96923077,    0.24615385]])
array([[  10.29563014,   11.66190379,   52.5       ,  113.5       ,
       0.47058824,   -0.88235294],
   [  81.88406438,   23.19482701,  102.        ,  104.5       ,
       0.96654275,   -0.25650558],
   [  26.        ,    8.54400375,  166.5       ,   90.        ,
       0.75342466,   -0.65753425]])
array([[  25.29822128,    8.54400375,  196.        ,  126.5       ,
      -0.75342466,   -0.65753425]])]

I feed it this way:

sess.run(train_step, feed_dict={x: x_batch, y_: y_batch, keep_prob: 0.5})

And throwing this error from the line above:

ValueError: setting an array element with a sequence.
Richard Hou.
  • 63
  • 1
  • 4

1 Answers1

0

From this answer: This particular error is coming out of numpy. Calling np.array on a sequence with a inconsistant dimensions can throw it.

np.array([1,2,3,[4,5,6]])

ValueError: setting an array element with a sequence.

It looks like it's failing at the point where tf ensures that all the elements of the feed_dict are of type numpy.array. So, check your feed_dict.

For relevant discussion, see this post.

Community
  • 1
  • 1
Wasi Ahmad
  • 31,685
  • 30
  • 101
  • 155