Error using trainNetwork. Too many output arguments

3 views (last 30 days)
Hello,
I have multiple variables in parallell timeseries, and I want to predict the next step in the timeseries. This would normaly be solved as an autoencoder, however this time I only want to predict the next timestep, not a sequence.
I have a custom datastore (mds) that reads a 1x2 cell array (totally 18741 cell arrays). The first cell has 28 variables and sequence length 100 (28x100 double) and the second cell is the next time step for the 28 variables (28x1).
>> read(mds)
ans =
1×2 cell array
{28×100 double} {28×1 double}
I want to train a lstm network by using trainnetwork. The layers is set up as follows:
layers = [ ...
sequenceInputLayer(28)
lstmLayer(256,OutputMode="last")
fullyConnectedLayer(28)
regressionLayer
];
The options is as follows:
options = trainingOptions("adam", ...
MaxEpochs=100, ...
InitialLearnRate = 0.001,...
LearnRateDropFactor=0.001, ...
LearnRateDropPeriod=100, ...
MiniBatchSize=64, ...
Verbose=1, ...
Plots="training-progress");
Then I want to train the network:
net = trainNetwork(mds,layers,options);
The model will not run, the error message is as follows:
Error using trainNetwork Too many output arguments.
Caused by: Error using MinDatastore/read Too many output arguments
If I transpose the second cell to a 1x28 vector outside the datastore, I am able to train the network on the first read and use predictAndUpdateState for the rest of the cells. However, it should be possible to run the datastore directly in trainNetwork.
I would appreciate if someone can tell me what I am doing wrong?
  3 Comments
Ji Luo
Ji Luo on 1 Jan 2023
A workaround is to reimplement the custom datastore as a fileDatastore. Save data to disk and read in again in the custom ReadFcn(partialfile mode). It's silly and runs slow but it works...
Heidi Cecilie Henriksen
Heidi Cecilie Henriksen on 2 Jan 2023
Thank you for the answer. I found out that I was missing the definition of info in the read function, as [data,info] = read(object). I sat info as empty, then it worked as planned.

Sign in to comment.

Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!