我解码了一张 JPEG 图像,并将它的形状设置为 n_samples
x n_features
作为二维 numpy.ndarray
。我按如下方式将其提供给 tensorflow:
sess.run(train_step, feed_dict={X : train_set.Features, y_ : train_set.labels})
这会返回一个 TypeError:TypeError: unhashable type: 'numpy.ndarray'
。
我认为这是一个简单的问题,但我找不到好的建议。我发现最接近的是这篇关于堆栈溢出的帖子,但据我所知,这就是我所做的。
最佳答案
我猜你的 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}
关于python - tensorflow:如何喂养 numpy.ndarray?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36946802/