【发布时间】:2018-02-18 17:18:58
【问题描述】:
我正在编写一个卷积神经网络来在 TensorFlow 中对图像进行分类,但是有一个问题:
当我尝试将我的 NumPy 平面图像数组(RGB 值从 0 到 255 的 3 个通道)输入到 tf.estimator.inputs.numpy_input_fn 时,我收到以下错误:
TypeError: Failed to convert object of type <class 'dict'> to Tensor.
Contents: {'x': <tf.Tensor 'random_shuffle_queue_DequeueMany:1' shape=(8,
196608) dtype=uint8>}. Consider casting elements to a supported type.
我的 numpy_imput_fn 看起来像这样:
train_input_fn = tf.estimator.inputs.numpy_input_fn(
x={'x': train_x},
y=train_y,
batch_size=8,
num_epochs=None,
shuffle=True)
在函数的文档中说 x 应该是 NumPy 数组的字典:
x: numpy 数组对象的字典。
【问题讨论】:
标签: numpy tensorflow typeerror