Skip to content Skip to sidebar Skip to footer

Tensorflow Dataset With Different Shapes

I use convolutional network for clasifying images with different shapes. I can not find a way to load images in Tensorflow. Based on this issue it should work with tf.data.Dataset(

Solution 1:

dataset.batch() is trying to build a dense batch from tensors of different sizes (your different sized images), as mentioned here: tf.contrib.data.DataSet batch size can only set to 1

Your code is likely to work if either 1. you are setting batch_size = 1 or 2. resize all images to same size, e.g. using tf.image.resize_image_with_crop_or_pad() in your read_file-function.

Another option would be to use dataset.padded_batch(...) instead of dataset.batch and specify the padded_shape such that all images have the same size (incl. padding), i.e. probably dataset.padded_batch(batch_size, padded_shape=[None]).

Lastly, in the upcoming TF r1.4 you might use dataset.from_generator().

Post a Comment for "Tensorflow Dataset With Different Shapes"