问题
When one passes to tf.train.batch, it looks like the shape of the element has to be strictly defined, else it would complain that All shapes must be fully defined
if there exist Tensors with shape Dimension(None)
. How, then, does one train on images of different sizes?
回答1:
You could set dynamic_pad=True
in the argument of tf.train.batch.
dynamic_pad
: Boolean. Allow variable dimensions in input shapes. The given dimensions are padded upon dequeue so that tensors within a batch have the same shapes.
回答2:
Usually, images are resized to a certain number of pixels.
Depending on your task you might be able to use other techniques in order to process images of varying sizes. For example, for face recognition and OCR, a fix sized window is used, that is then moved over the image. On other tasks, convolutional neural networks with pooling layers or recurrent neural networks can be helpful.
来源:https://stackoverflow.com/questions/45147525/tensorflow-batches-of-variable-sized-images