My simple numerical Deep Learning project will not train. Get "invalid training data" message.

3 views (last 30 days)
Hello Matlab,
I am trying to use Deep Learning GUI to process 5 numerical inputs per training trial to match one numerical goal. Total of 6 entries per line.
I had this working in Excel but can't go beyond 200 variables for their solver.
My training data in Excel is a row for each trial with my "goal or correct answer" in the right column as Matlab wants.
I bring the array into matlab as a "matrix". It is around 100 rows deep, 6 across.
From there, I drag this matrix into the arrayDatastore function, then say
>> bb = arrayDatastore(athurvaluesforDL,"ReadSize", 6,"IterationDimension", 2,"OutputType", "cell")
I have tried both 1 and 2 as InterationDimension.
The simple network has an input, 2 fully connecteds separated by a relu and the regression output.
The architecture checks out as at least "viable".
It won't train. I get this message:
Training with trainNetwork failed. Invalid training data. For a network with 1 inputs and 1 output, the datastore read function must return a cell array with 2 columns, bit it returns a cell array with 1 columns.
So I am missing something. I am new to Matlab and have spent about 3 days getting to know the screen basics.
I went through the help page on arrayDatastore, but maybe I need something else.
Most of the "help" on Deep Learning is about imaging. I just want to do numerics.
Thursday 6 16 22 The question is withdrawn. I no longer have the Matlab DL kit.

Answers (1)

Ben on 20 Jun 2022
I think the issue here is you need to permute the data to NumFeatures x BatchSize for featureInputLayer when working with trainNetwork and datastores. Here's an example:
% Create fake data with 100 observations of 5 features and 1 target
xy = randn(100,6);
% split off features from targets
x = xy(:,1:5);
y = xy(:,6);
% permute for featureInputLayer
% For featureInputLayer and trainNetwork using datastores the data has to
% be shaped as NumFeatures x BatchSize
x = x.';
y = y.';
% Create datastores with cell outputs, and iterate along dimension 2 (since
% we permuted the data it is now in NumFeatures x BatchSize).
xds = arrayDatastore(x,"OutputType","cell","IterationDimension",2);
yds = arrayDatastore(y,"OutputType","cell","IterationDimension",2);
% Combine the datastores
cds = combine(xds,yds);
% Create a simple network and train.
layers = [featureInputLayer(5)
opts = trainingOptions("adam");
net = trainNetwork(cds,layers,opts);


Find more on Deep Learning with Time Series and Sequence Data in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!