MATLAB: Apply non-image data to CNN

cnnDeep Learning Toolboxneural networks

I am trying to train a CNN with a numerical data set. Once the input data is not an image format. Assuming my data has a size of 1850*11 matrix. With a 1850*1 label (for output). In libsvm I can use it directly and in the Neural Network Toolbox (nnstart) as well.
However, in case I want to use a CNN network. The only training function is "trainNetwork" it could only support image as an input. So how could I train the CNN with my data on Matlab?
Any simple example will be appreciated.
Thanks to all of in advance.
Gad

Best Answer

You can read in your data using the function "imageDatastore" with a custom read function.
For example,
nonImageData = imageDatastore(pathToDataFiles, 'IncludeSubfolders', true, 'LabelSource', 'foldernames', 'FileExtensions', '', 'ReadFcn', @customreader);
You can then use 'nonImageData' as you would normally use an "imageDatastore" - for example, as input to "splitEachlabel" or "trainNetwork".
Note: Be careful to watch for negative numbers, however, as some layers (ex. ReLULayer) will convert all negative values to zero.
For more information, see:
For more Related MATLAB Answers see: