How to do Pattern Recognition with 3D input data using Deep Learning Toolbox?

9 views (last 30 days)
If I have elements of 2D data that are put into a 3D inputs variable, is it possible to do pattern recognition on this data in MATLAB?
>> inputs = rand(3,3,10);
>> targets = ones(2,10);
>> net = patternnet(10);
>> net = train(net, inputs, targets) %error inputs must be 2D
>> nprtool %dropdown does not give 3D inputs variable as an option

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 31 Aug 2021
Edited: MathWorks Support Team on 2 Sep 2021
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.
Since ‘patternnets’ (in general, not just in MATLAB) do not take account of spatial dependencies between variables (as opposed to convolutional deep learning networks) you could try to work around this requirement by reshaping the data from a 2D matrix into a 1D vector. For example:
Instead of:
inputs = rand(3,3,10)
targets = ones(2,10);
You could use:
inputs = rand(9,10);
targets = ones(2,10);
However, depending on what your 2-D data represents, a better alternative might be to work with convolutional neural networks (CNNs). These networks are designed to model spatial dependencies between variables/features and are 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:

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!