PeterHeuz
PeterHeuz

Reputation: 430

tensorflow: How to feed numpy.ndarray?

I decoded a JPEG image and have it in the shape n_samples x n_features as a two-dimensional numpy.ndarray. I feed this to tensorflow as following:

sess.run(train_step, feed_dict={X : train_set.Features, y_ : train_set.labels}) 

This returns a TypeError: TypeError: unhashable type: 'numpy.ndarray'.

I think it is a simple issue, but I cannot find good advise on that. Closest I found was this post on stack overflow but as far as I understand, that's what I do.

Upvotes: 2

Views: 6929

Answers (1)

xuesen Zhang
xuesen Zhang

Reputation: 41

I guess your X and train_set.Features maybe have different shape. for examples,

# cifar10 datasets 
x = tf.placeholder(tf.float32,shape = (None,32,32,3))
y = tf.placeholder(tf.float32,shape = (None,10))
print x_batch.shape   # (batch_size,32,32,3)
print y_batch.shape   # (batch_size,10)
# and feed_dict should be
feed_dict = {x:x_batch,y:y_batch}

Upvotes: 1

Related Questions