How to chose convolutional network size to fit in memory?
2 views (last 30 days)
Show older comments
Hi,
I am trying to use NN toolbox with convolutional layer for regression problem, specifically depth estimation from image. For this, I want to use 256x256 as input and kind of smaller size for output but still can't fit into RAM. What i need to do to chose best sizes of layers?
Another question, why I cant use datastores(without loading images into RAM) with Regression Layer?
Thanks for attention
1 Comment
Mity sosi
on 11 May 2019
Hi
Can you expalin how to define ' your regressors in the other columns ' , I do not know it . because I have the same problem.
Thanks
Accepted Answer
Amy
on 14 Aug 2017
Hi Denys,
See https://www.mathworks.com/help/nnet/ug/layers-of-a-convolutional-neural-network.html for information on defining layers for your convolutional neural network.
In a CNN, the majority of the weights are held by the fully connected layers. The convolutional layers in the network convert spatial information into more compact semantic information. Pooling layers then downsample redundant information so that when you reach fully connected layers they are receiving fewer activations.
I am not sure what your CNN looks like, but if you have fewer convolutional layers in your network, your last fully connected layer ends up with a greater number of weights. This could be what is causing you to run out of RAM.
As an example, you could refer to the layers in the AlexNet network for ideas for defining your network layers: https://www.mathworks.com/help/nnet/examples/visualize-features-of-a-convolutional-neural-network.html
As for using image datastores, you can use them with a regression layer without loading them into memory. For now, you can get the image file names from the datastore, then create a table with the file names in the first column and your regressors in the other columns, and feed that to trainNetwork.
3 Comments
Chee Ho Ng
on 27 Dec 2017
Edited: Chee Ho Ng
on 27 Dec 2017
Hello Ms.Amy, I found your answer helpful too. I got a related further question:
Do Matlab have any function that can calculate the required memory for a CNN? In my case, I'm training with GPU.
This can help user predict how much RAM is needed for a CNN design.
Since we have define our layers for CNN, I hope there is a function that can save user time for manual calculation.
Hope to hear from you. Thank you in advance!
Mity sosi
on 11 May 2019
Dear Amy,
Can you expalin how to define ' your regressors in the other columns ' , I do not know it .
Thanks
More Answers (1)
Mity sosi
on 11 May 2019
Dear Amy,
Can you expalin how to define ' your regressors in the other columns ' , I do not know it .
Thanks
0 Comments
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!