张量流中的tf.data.Dataset.from_generator函数的问题

时间:2018-08-20 12:38:10

标签: python tensorflow deep-learning

我希望使用tf.data.Dataset.from_generator来帮助我生成输入数据流。但是,当我读取两个图像并将它们裁剪为[255,255,3]形状时,我无法生成输入数据流。 错误消息是

  

InvalidArgumentError:ValueError:设置具有序列的数组元素。

代码如下:

函数sample_generator生成一些数据

instance_image_2 = tf.reshape(instance_image_2, [255,255,3])
exemplar_image_2 = tf.reshape(exemplar_image_2, [255,255,3])
yield exemplar_image_2,instance_image_2

另一个功能

dataset = tf.data.Dataset.from_generator(sample_generator,output_types=(tf.float32, tf.float32),output_shapes=(tf.TensorShape([255,255,3]), tf.TensorShape([255,255,3])))

编译后,我收到错误消息。

我确定每个张量的形状正确。

0 个答案:

没有答案