Azzera filtri
Azzera filtri

Error using trainNetwork Invalid training data. For cell array input, responses must be an N-by-1 cell array of sequences, where N is the number of sequences. The spatial and

96 visualizzazioni (ultimi 30 giorni)
Error using trainNetwork
Invalid training data. For cell array input, responses must be an N-by-1 cell array of sequences, where N is the number of sequences. The spatial and channel dimensions of the sequences must be the same as the output size of the last layer (1).
% Edit - running code here
load CycleAgeingData.mat
numHiddenUnits = 50;
inputSize1 = size(Data{1},1)
inputSize1 = 7
% layers = [
% sequenceInputLayer(numChannels)
% lstmLayer(128)
% fullyConnectedLayer(numChannels)
% regressionLayer];
%
layers = [ ...
sequenceInputLayer(inputSize1)
lstmLayer(50, 'OutputMode', 'sequence')
fullyConnectedLayer(7)
dropoutLayer(0.011547480894612765)
fullyConnectedLayer(1)
regressionLayer];
% layersLSTM = [ ...
% sequenceInputLayer(inputSize1)
% lstmLayer(numHiddenUnits)
% fullyConnectedLayer(1)
% regressionLayer
% ];
% cell1x = num2cell(features', 1)';
% targets=cap6/cap6(1)
% cell1yB = num2cell(targets);
numChannels = size(Data{1},1)
numChannels = 7
numObservations = numel(Data);
idxTrain = 1:floor(0.7*numObservations);
idxval = floor(0.7*numObservations)+1:numObservations-2
idxval = 1x3
11 12 13
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
idxTest = floor(0.7*numObservations)+4:numObservations;
dataTrain = Data(idxTrain);
dataVal = Data(idxval)
dataVal = 3x1 cell array
{7x10 double} {7x32 double} {7x4 double}
dataTest = Data(idxTest);
%trainindx=(1:24)
trainindx = 1x24
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
%validindx=(25:29)
validindx = 1x5
25 26 27 28 29
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
%testindx=(30:34)
testindx = 1x5
30 31 32 33 34
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
traincell2yB = target(idxTrain, :);
valcell2yB = target(idxval, :);
testcell2yB = target(idxTest, :);
options = trainingOptions('rmsprop', ...
'MaxEpochs', 1500, ...
'MiniBatchSize', 50, ...
'InitialLearnRate', 0.00036008553147273947, ...
'LearnRateSchedule', 'piecewise', ...
'LearnRateDropPeriod', 125, ...
'LearnRateDropFactor', 0.02, ...
'Shuffle', 'every-epoch', ...
'ValidationData', {dataVal, valcell2yB}, ...
'ValidationFrequency', 50, ...
'Verbose', 1, ...
'Plots', 'training-progress');
% options = trainingOptions('rmsprop', ...
% 'InitialLearnRate', 0.001, ...
% 'MaxEpochs',500, ...
% 'MiniBatchSize',50, ...
% 'Plots','training-progress', 'ValidationData', {valcell1x, valcell1yB});
% options = trainingOptions('adam', ...
% 'InitialLearnRate', 0.001, ...
% 'MaxEpochs',500, ...
% 'MiniBatchSize',50, ...
% 'Plots','training-progress', 'ValidationData', {valcell1x, valcell1yB});
netLSTM1 = trainNetwork(dataTrain, traincell2yB, layers, options);
Error using trainNetwork (line 191)
Invalid training data. For cell array input, responses must be an N-by-1 cell array of sequences, where N is the number of sequences. The spatial and channel dimensions of the sequences must be the same as the output size of the last layer (1).
Here is my data
  9 Commenti
Mo'ath
Mo'ath il 1 Mag 2024
@Cris LaPierre i think Each cell has the format M x L, where M is the number of features, that remains fixed for all the cells, and L is the variable length of the training data. and the i have use number of features as inputsize
Cris LaPierre
Cris LaPierre il 1 Mag 2024
Sorry, I now understand you are trying to perform sequence-to-sequence regression. That changes some things. You might find this example useful. Sequence to Sequence Regression using Deep Learning

Accedi per commentare.

Risposta accettata

Cris LaPierre
Cris LaPierre il 1 Mag 2024
I believe the issue is because the sequence length is not the same in each sequence.
There are 2 reasons for this. First, your response vectors are Nx1, but need to be transponsed to 1xN so that the training and response sequences are the same length. Second, one of your sequences has a different response length.
  3 Commenti
Mo'ath
Mo'ath il 1 Mag 2024
@Cris LaPierre, i am try this solution and i get the same error but i am agrre with you i think the error come from the lengthsequance of the target output

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by