How can I make my neural network support any size of image input?
10 次查看(过去 30 天)
显示 更早的评论
There are three levels of code writing to do a vision-related deep learning task.
Highest Level: complete layerGraph and train with trainNetwork function.
Middle level: build a layerGraph without loss. Instead, calculate loss and gradient in an eval function. One can also specify customed learning rate schedule. This level allows some customization, and still exploits the easy-to-use highest level features.
Lowest level: this level has no concept of layer. Coders have to take care of the parameters themself. It's really messy and time-consuming to build and train a network in this way.
My question is: Highest level and middle level all requires a certain size of input, i.e, an imageInputLayer. But imageInputLayer only supports for fixed image size. I do not want to trouble myself with lowest level coding. So how could I make my NN take inputs of any size?
0 个评论
采纳的回答
Ryan Comeau
2020-5-10
Hello,
I wish it was possible to just dump images of multiple sizes as well. Unfortunately though each image would yield a differen size of convultion maps and a different number. How then would it make sense to pass these into a full connection layer and curve fit these convolutions maps? It would be like sorting oranges by size, but half of your input oranges are apples, it would be a strange task.
There is however a solution to this problem. Your input images need to be scaled to the size of your network input size. This is one of the preprocessing steps that is important. Here is some code that could resize all of your images:
image=imread('path/to/image');
number_rows=200; %depending on the input size of your network
number_cols=300; %depending on input size.
rescaled_image=imresize(image,[number_rows number_cols])
It may seem unintuitive, but computers don't see the same way we do and the scale of things doesn't always matter.
Hope this helps,
RC
1 个评论
Jacques Boutet de Monvel
2022-5-31
If it is true that there is no way to feed an image of unprescribed size to a fully convolutional network, this is too bad! It misses one of the most attractive and elegant features of FCNs: the ability to process an image of any size in a seamless - translation invariant way at prediction time, while the network has been trained on much smaller image patches. This is very useful, and even crucial for segmentation applications.
Why not implement this feature at least to give the choice to users? This is one thing that could (still) make matconvnet more attractive than the matlab DL toolbox, despite all its impressive features.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!