All shapes must be fully defined: [TensorShape([Dimension(299), Dimension(299), Dimension(3)])

今天重新写了tfrecord,结果报这个错误:

All shapes must be fully defined: [TensorShape([Dimension(299), Dimension(299), Dimension(3)])

 

原因:https://stackoverflow.com/questions/35620157/how-can-i-use-values-read-from-tfrecords-as-arguments-to-tf-reshape/35630798

https://stackoverflow.com/questions/35620157/how-can-i-use-values-read-from-tfrecords-as-arguments-to-tf-reshape/35630798

tf.train.shuffle_batch 里边的参数rank必须是一样的,而我的图片rank是 【299,299,3】,而label的形状是【none,2】,这俩货rank不一样
解决方法如下:
在 tf.train.shuffle_batch 之前,把 image 从 三维降到两维,方法 

image = tf.image.resize_image_with_crop_or_pad(image, 299, 299)
image = tf.reshape(image, tf.stack([299, 299, 3]))

你可能感兴趣的:(计算机视觉CV)