My simple numerical Deep Learning project will not train. Get "invalid training data" message.
3 次查看(过去 30 天)
显示 更早的评论
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.
Thanks.
Thursday 6 16 22 The question is withdrawn. I no longer have the Matlab DL kit.
0 个评论
回答(1 个)
Ben
2022-6-20
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)
fullyConnectedLayer(1)
regressionLayer];
opts = trainingOptions("adam");
net = trainNetwork(cds,layers,opts);
1 个评论
Yongwon Jang
2023-9-22
编辑:Yongwon Jang
2023-9-22
xds = arrayDatastore(x,"OutputType","cell","IterationDimension",2);
yds = arrayDatastore(y,"OutputType","cell","IterationDimension",2);
cds = combine(xds,yds);
Create arrayDatastore X, Y separately and combine the two d into one.
I couldn't find any example code containing this content anywhere.
My problem was putting input arguments in the form of an arrayDatastore into the minibatchqueue.
I found this answer by chance and it helped me a lot.
Thank you.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!