Training a deep neural network with a database as input
14 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Ruchika Parag
on 19 Jul 2024
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!
See Also
Categories
Find more on Sequence and Numeric Feature Data Workflows 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!