It's not possible to feed images of different size into a single input batch. Every batch can have an undefined number of samples (that's the batch size usually, below noted with None
) but every sample must have the same dimensions.
When you train a fully convolutional network you have to train it like a network with fully connected layers at the end.
So, every input image in the input batch must have the same widht, height and depth. Resize them.
The only difference is that while fully connected layers output a single output vector for every sample in the input batch (shape [None, num_classes]
) the fully convolutional outputs a probability map of classes.
During train, when the input images dimensions are equals to the network input dimensions, the output will be a probability map with shape [None, 1, 1, num_classes]
.
You can remove the dimensions of size 1 from the output tensor using tf.squeeze
and then calculate the loss and accuracy just like you do with a fully connected network.
At test time, when you feed the network images with dimensions greater than the input, the output will be a probability map with size [None, n, n, num_classes]
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…