MATLAB: Can “feedforwardnet” and “patternnet” accept images (2-D or 3-D) as inputs

1d2d3dclassicalDeep Learning Toolboxfeedforwardnetnetworksneuralpatternpatternnetrecognition

Can "feedforwardnet" and "patternnet" accept images (2-D or 3-D) as inputs? It seems in all the examples I have seen, they are only able to accept 1-D vectors of feature values as inputs

Best Answer

The input data for training classical neural networks is expected to be an R x Q dimensional matrix (or a cell array of R x Q matrices), where Q is the batch size or number of observations and R is the number of variables. So "feedforwardnet" and "patternnet" can only accept inputs that are each 1D.
I recommend you try our deep learning functionalities. Deep learning networks are now the state of the art for image classification/regression (as opposed to classical/shallow neural nets such as patternnet and feedforwardnet) and have also been developed with good GPU performance in mind. Note that are our deep learning networks currently only support 2D data (or 3D data reshaped into 2D). Here are some links with information on our deep learning:
Depending on the data, the best option might be to use convolutional neural networks (CNNs). These networks are designed to model spatial dependencies between variables/features and are the state-of-the-art for tasks such as image classification.
Please see here how to create a simple classification deep learning network for 2-D image data:
Related Question