How can I load 2 features XTrain and YTrain to SequenceInputyer in Deep learning toolbox?

3 views (last 30 days)
I have a two-feature dataset. The type of XTrain is 2x6000 double, while the type of YTrain is also 2x6000 double. I have transform them into arrayDatastore by
adsXTrain=arrayDatastore(XTrain,"ReadSize",2,"OutputType","same");
adsYTrain=arrayDatastore(YTrain,"ReadSize",2,"OutputType","same");
Then, I combine these two datasets by
cdsTrain=combine(adsXTrain,adsYTrain);
Unfortunately, when I import cdsTrain in Deep Network Designer as Datastore, it shows 2x12000 double not two columns of 2x6000 double
If so, Deep Network Designer can't idenfy the dataset as XTrain and YTrain during training.

Answers (1)

Ben
Ben on 20 Jun 2022
Using "OutputType" as "cell" should help this - e.g. you can do the following at the command line:
% Create fake data,
% I am assuming you have 6000 observations of 2 features.
x = randn(2,6000);
% Create arrayDatastore, use cell outputs, and iteration dimension 2.
% Note - no need to set ReadSize,
% trainNetwork and trainingOptions MiniBatchSize option will handle that.
ds = arrayDatastore(x,"OutputType","cell","IterationDimension",2);
% For this example I just duplicate x for the target data.
cds = combine(ds,ds);
testOutput = cds.read % should be a 1x2 cell where each cell contains a 2x1 vector.
% dummy network and training
layers = [featureInputLayer(2)
fullyConnectedLayer(2)
regressionLayer];
opts = trainingOptions("adam");
net = trainNetwork(cds,layers,opts);

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!