Error forming mini-batch of targets for network output "fc". Data interpreted with format "BC".

I worked on time series forecasting supportte dby Matlab. However, i first tried the sample provided by Matlab. But I got the error of Error forming mini-batch of targets for network output "fc", Data interpreted with format "BC" when I used training function -- trainnet(XTrain, TTrain, net_1,"mse",options). I appreciate for any suggestion or comment.

3 Commenti

Please share the documentation link for the example (sample) that you tried.
If you did any modification, share your code.
Yes, I selected the LSTM architecture and set last lasyer as lstmLayer. However, the problem is still persists. Thanks.

Accedi per commentare.

Risposte (1)

Hi, in the Deep Network Designer set OutputMode for lstmLayer to sequence.

4 Commenti

Thank you very much. I'll try that.
I posted all the configurationa and Code below for my previous question and sincerly look for help.
Time Series Forecasting Implementation
1 -- Define the Network Architecture
  1. Open Deep Network Design App;
  2. Select LSTM in Sequence-to-Sequence Classification Networks (Untrained) section;
  3. Set the InputSize of the Sequence Input Layer to 3;
  4. Set the OutputSize of the Fully connected layer to 3;
  5. Deleted the Softmax layer in the default LSTM structure;
  6. Ensure the lstmlayer is adopted;
  7. Export and create the network donated as net_1;
2 -- Codes
>> load WaveformData.mat
>> idx = 1;
>> figure
>> numChannels = size(data{idx},2);
>> stackedplot(data{idx},DisplayLabels="Channel"+(1:numChannels))
>> numObservations = numel(data);
>> XData=cell(numObservations,1);
>> TData=cell(numObservations,1);
>> for n = 1:numObservations
X = data{n};
XData{n}(1:end-1,:);
TData{n} = X(2:end,:);
End
>> [idxTrain,idxValidation,idxTest]=trainingPartitions(numObservations,[0.8 0.1 0.1]);
>> XTrain=XData(idxTrain);
>> TTrain=TData(idxTrain);
>> XValidation = XData(idxValidation);
>> TValidation = TData(idxValidation);
>> XTest = XData(idxTest);
>> TTest = TData(idxTest);
>> muX = mean(cell2mat(XTrain));
>> sigmax = std(cell2mat(XTrain),0);
>> muT = mean(cell2mat(TTrain));
>> sigmat = std(cell2mat(TTrain),0);
>> for n = 1:numel(XTrain)
XTrain{n} = (XTrain{n} - muX) ./sigmax;
TTrain{n} = (TTrain{n} - muT) ./sigmat;
End
>> for n = 1:numel(XValidation)
XValidation{n} = (XValidation{n}-muX)./sigmax;
TValidation{n} = (TValidation{n}-muT)./sigmat;
End
>> for n = 1:numel(XTest)
XTest{n} = (XTest{n}-muX)./sigmax;
XTest{n} = (TTest{n} -muT)./sigmat;
end
>> options = trainingOptions("adam",...
MaxEpochs = 200,...
SequencePaddingDirection = "left",...
Shuffle = "every-epoch",...
ValidationData = {XValidation,TValidation},...
Metrics = "rmse",...
Plots = "training-progress",...
Verbose = false);
3 --- Training the net_1
>> net = trainnet(XTrain,TTrain,net_1,"mse",options);
4 – Error Message from Matlab
Error using trainnet (line 54)
Error forming mini-batch of targets for network output "fc". Data interpreted with format "BC". To
specify a different format, use the TargetDataFormats option.
Caused by:
Cell array input supports sequence data only.
Hi Dan,
with your code I get some different error, but changing the line
XData{n} = X(1:end-1,:);
the code is running without error on my MATLAB R2024b System.
As I tried the matlab example time-series-forecasting-using-deep-network-designer the first time I also got the Error:
Error forming mini-batch of targets for network output "fc". Data interpreted with format "BC".
During checking the problem I observed that the analyse network output was different then the described one:
In the Activations TAB the "x 1(T)" are missing for the layer 2 to 4. But after change the OutPutMode of the lstm layer to sequence
the output of the analyze fit now the one in the sample an the code was running fine.
regards
Marcel
Hi, Marcel,
Yes, you are right. After I changed the OutPutModel to "sequence", the network works correctly. Thank you very much for your help.
Best regards,
Dan

Accedi per commentare.

Categorie

Richiesto:

Dan
il 27 Gen 2025

Commentato:

Dan
il 20 Feb 2025

Community Treasure Hunt

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

Start Hunting!

Translated by