Borrar filtros
Borrar filtros

Training a deep neural network with a database as input

41 visualizaciones (últimos 30 días)
giulia
giulia el 18 de Jul. de 2024 a las 17:48
Comentada: giulia el 20 de Jul. de 2024 a las 8:05
After converting my data into a combined datastore, I tried training a deep neural network with the architecture shown below but the error " Error forming mini-batch for network input "sequence_prop". Data interpreted with format "CBT". To specify a different format, use the InputDataFormats option.
Error in netPaperv4 net = trainnet(dsTrain, net, "mse", options);
Caused by:
Batch dimension of datastore must match the format batch dimension (2)." occurred.
Here a datastore preview: 1×2 cell array
{[-0.2964 -0.2723 0 0.3049 0.1613 -0.9312]} {[2.2746]}
I want to combine three different sequence inputs (the goal is time series forecasting, not image classification: my inputs are all time-depending sequences) : two of size 1 and the other of size 4 to predict a single output (size 1).
Can anyone help me solve this? I can provide code if needed.

Respuestas (1)

Ruchika Parag
Ruchika Parag el 19 de Jul. de 2024 a las 18:02
Hi Giulia, it looks like you are facing an error while training your deep neural network for time series forecasting. The error indicates that the batch dimension of your datastore does not match what the network expects.To fix this, first, ensure your datastore is set up correctly. Since you have three sequences (two of size 1 and one of size 4), they need to be the same length for batching. You can pad the shorter sequences with zeros to achieve this.Next, specify the input data format in your training options. For example, you can use the "CBT" format (Channel-Batch-Time) like this:
options = trainingOptions('adam', ...
'InputDataFormats', 'CBT', ...
'MaxEpochs', 100, ...
'MiniBatchSize', 32, ...
'Verbose', false);
Here is an example of how you might set everything up:
data = {[-0.2964 -0.2723 0 0.3049 0.1613 -0.9312], [2.2746]};
dsTrain = arrayDatastore(data, 'OutputType', 'cell');
net = trainnet(dsTrain, net, "mse", options);
By ensuring your sequences are the same length and specifying the correct input format, you should be able to resolve the error. Hope this helps!
  1 comentario
giulia
giulia el 20 de Jul. de 2024 a las 8:05
What I have done to preprocess my data is:
dsXCTrain = arrayDatastore([X,C]);
% X is a 19079x2 double array (the first column is the first input, the second column the second input)
% C is a 19079x4 double array (these are 4 covariates, that should be treated as feature input)
dsTTrain = arrayDatastore(T); % T is a 19079x1 double array (target array)
dsTrain = combine(dsXCTrain, dsTTrain);
Given the architecture of the net
I have set these options to the net:
options = trainingOptions("adam", ...
"MaxEpochs", 150, ...
"SequencePaddingDirection", "left", ...
"Shuffle", "every-epoch", ...
"Plots", "training-progress", ...
"Verbose", false, ...
"InputDataFormats", {'CBT','CBT','CBT'}, ...
"TargetDataFormats", {'CBT'});
Then I tried training the net with the command:
net = trainnet(dsTrain, net, "mse", options);
I got this error:
Error using trainnet (line 46)
Error forming mini-batch for network input "sequence_prop". Data interpreted with format "CBT".
To specify a different format, use the InputDataFormats option.
Error in netPaperv4 (line 116)
net = trainnet(dsTrain, net, "mse", options);
Caused by:
Batch dimension of datastore must match the format batch dimension (2).
What should I do to solve this?

Iniciar sesión para comentar.

Categorías

Más información sobre Deep Learning Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by