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
显示 更早的评论
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)
% 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)
numObservations = numel(Data);
idxTrain = 1:floor(0.7*numObservations);
idxval = floor(0.7*numObservations)+1:numObservations-2
idxTest = floor(0.7*numObservations)+4:numObservations;
dataTrain = Data(idxTrain);
dataVal = Data(idxval)
dataTest = Data(idxTest);
%trainindx=(1:24)
%validindx=(25:29)
%testindx=(30:34)
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);
Here is my data
9 个评论
Cris LaPierre
2024-5-1
Could you provide a description of what your input data is?
Mo'ath
2024-5-1
Cris LaPierre
2024-5-1
Are the features captured in the rows or columns of Data? Each cell contains 7 rows, but a variable number of columns. I would expect the number of features to be constant.
Note the following about numeric feature input:
The numeric array must be an N-by-numFeatures numeric array, where N is the number of observations and numFeatures is the number of features of the input data.
Mo'ath
2024-5-1
Cris LaPierre
2024-5-1
Ok. Note in the instructions I copied from the doc that features need to be in the columns, and observations in the rows.
Mo'ath
2024-5-1
Cris LaPierre
2024-5-1
编辑:Cris LaPierre
2024-5-1
For vector sequence input, InputSize is a scalar corresponding to the number of features. (reference)
MATLAB already expects the number of columns to correspond to the number of features. You will need to update the input to inputSize so that it returns the number of columns instead of rows.
Mo'ath
2024-5-1
Cris LaPierre
2024-5-1
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
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
