问题描述
我解码了JPEG图像,并以二维numpy.ndarray
的形式将其以n_samples
x n_features
的形状显示.我将其喂入tensorflow如下:
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})
这将返回TypeError:TypeError: unhashable type: 'numpy.ndarray'
.
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.
推荐答案
我猜您的X和train_set.Features可能具有不同的形状.例如,
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}
这篇关于tensorflow:如何喂numpy.ndarray?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!