0

I am trying to make a QOS prediction on the QWS dataset but I have the following error:

Error using trainNetwork (line 170) Too many input arguments.

Error in lstm (line 63) net = trainNetwork(x_train,y_train,layers,options);

Caused by: Error using trainNetwork>iParseInputArguments (line 326) Too many input arguments.

data = readtable('C:\Users\Etudiant FST\Documents\études\mini_pjt\d\qws1\qws1.txt');
%test_data = readtable('C:\Users\Etudiant FST\Documents\études\mini_pjt\d\qws2\qws2.txt');

data = data(:,1:10);

x = [];
y = [];

delta_x = 1; 
delta_y = 1;
pas = 1;

while (height(data) >= delta_x + delta_y)
    
    x = [x; data(1:delta_x,:)];
    y = [y; data(delta_x + 1:delta_x + delta_y,:)];
    data(1:pas,:) = [];
end



%numObservations = height(data);
%idxTrain = 1:floor(0.8*numObservations);
%idxTest = floor(0.8*numObservations)+1:numObservations;
%dataTrain = data(idxTrain,:);
%dataTest = data(idxTest,:);

%%for n = 1:numel(dataTrain)
    %X = dataTrain{n};
   % xt{n} = X(:,1:end-1);
  %  tt{n} = X(:,2:end);
%%end

height_x = height(x);
split = fix(height_x*0.8);
x_train = x(1:split,:);
x_test = x(split:height_x,:); 
y_train = y(1:split,:);
y_test = y(split:height_x,:); 

layers = [
    sequenceInputLayer(10)
    lstmLayer(128,'OutputMode','sequence')
    fullyConnectedLayer(10)
    regressionLayer];

options = trainingOptions('adam', ...
    'MaxEpochs',maxEpochs, ...
    'MiniBatchSize',miniBatchSize, ...
    'InitialLearnRate',0.01, ...
    'GradientThreshold',1, ...
    'Shuffle','never', ...
    'Plots','training-progress',...
    'Verbose',0);

net = trainNetwork(x_train,y_train,layers,options);

enter image description here

I would like it to give me a prediction of the new QOS from the old ones thank you.

1 Answers1

0

As the error message suggests, MATLAB isn't able to detect the correct trainNetwork function to use (since the function is overloaded). This is because the correct function is selected based on the numbers of inputs and the input (types) passed to it.

If you look at the example for LSTM on the documentation for trainNetwork, you will see that XTrain is a 270 by 1 'cell array' with every cell containing a N x M array while YTrain is a 270 by 1 'categorical array'.

Shaping your Xtrain and Ytrain to these data shape and types should solve the problem. Everything else on the code seems okay to me.

A-T
  • 342
  • 2
  • 14