tensorflow:如何喂numpy.ndarray?

时间:2016-04-29 20:19:44

标签: python numpy multidimensional-array type-conversion tensorflow

我解码了JPEG图像,并将其作为二维n_samples形状n_features x numpy.ndarray。我将此提供给tensorflow如下:

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

返回TypeError:TypeError: unhashable type: 'numpy.ndarray'

我认为这是一个简单的问题,但我找不到好的建议。最近我发现这篇文章是关于堆栈溢出的,但据我所知,这就是我的工作。

1 个答案:

答案 0 :(得分:1)

我猜你的X和train_set.Features可能有不同的形状。 例如,

# 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}