Input image data directly from Variable and not DataStore?

4 views (last 30 days)
I've got neural data that I'm using to create the 'images' for a CNN model. I have a 4 dimensional array where the first 3 dimensions are the X,Y,RGB values, and the 4th is the image index (ex 1:107,000). Can I port this directly into Matlab's CNN models? So far I have to use the data to create PNGs in test/train folders, then import using the example from 'Create simple Deep Learning Network...' provided by Matlab's documentation, but it would be so much more efficient to pipe the data directly.

Accepted Answer

Travis Meyer
Travis Meyer on 2 Oct 2022
Got it!!! It's actually easier than expected, I can pass the 4D array directly into trainNetwork, even without using arraydatastore. I typed 'edit trainNetwork' and read through the comments and this one explained a good amount of the steps:
% trainedNet = trainNetwork(X, Y, layers, options) trains and returns a
% network, trainedNet. The format of X depends on the input layer.
% - For an image input layer, X is a numeric array of images arranged
% so that the first three dimensions are the width, height and
% channels, and the last dimension indexes the individual images.
% - For a 3-D image input layer, X is a numeric array of 3-D images
% with the dimensions width, height, depth, channels, and the last
% dimension indexes the individual observations.

More Answers (1)

Walter Roberson
Walter Roberson on 1 Oct 2022

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!