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!