Hi everyone, I am not able to figure out the "too many input arguments error" kindly help

2 vues (au cours des 30 derniers jours)
Amrit
Amrit le 21 Juil 2023
Commenté : Richard le 15 Août 2023
data = "WEDM_train_data.csv";
tbl = readtable(data);
head(tbl)
numobservation = size(tbl,1)
[trainId,valId,testId] = dividerand(size(tbl,1),0.7,0.15,0.15);
trainData = tbl(trainId,:);
valData = tbl(valId,:);
testData = tbl(testId,:);
trainDatax = trainData(1,1:14)
trainDatay = trainData(1,15:18)
valDatax = valData(1,1:14)
valDatay = valData(1,15:18)
testDatax = testData(:,1:14)
testDatay = testData(:,15:18)
numFeatures = 14
NumClasses = 4
layers = [
featureInputLayer(numFeatures,'Normalization', 'zscore')
fullyConnectedLayer(50)
batchNormalizationLayer
reluLayer
fullyConnectedLayer(NumClasses)
regressionLayer];
miniBatchSize = 16;
options = trainingOptions('adam', ...
'MiniBatchSize',miniBatchSize, ...
'ValidationData',{valDatax valDatay}, ...
'Plots','training-progress', ...
'Verbose',false);
net = trainNetwork(trainDatax,trainDatay,layers,options);
  3 commentaires
Amrit
Amrit le 21 Juil 2023
Error using trainNetwork
Too many input arguments.
Caused by:
Too many input arguments.
Amrit
Amrit le 21 Juil 2023
The features as well as responses are numerical

Connectez-vous pour commenter.

Réponses (1)

Richard
Richard le 21 Juil 2023
When you specify training data as a table, you can't pass in two separate inputs for predictors and responses. Instead you need to pass them in as part of one table in the first input, and specify the column names of the responses as the second input. This is described in the last row of the table at https://uk.mathworks.com/help/deeplearning/ref/trainnetwork.html?searchHighlight=trainNetwork&s_tid=srchtitle_support_results_1_trainNetwork#mw_199f8be9-53f8-4bac-acdf-2846778f5904
So long as there aren't additional unused columns in the data you are loading, I think this will work for your case:
net = trainNetwork(trainData,trainData.Properties.VariableNames(15:18),layers,options);
  2 commentaires
Amrit
Amrit le 31 Juil 2023
Hello Richard,
I tried your code, again some error is coming.
"Error using trainNetwork
Invalid training data. For table input, sequences must be in the first column as a cell array of file paths."
Kindly help.
Richard
Richard le 15 Août 2023
Hi Amrit, apologies for taking a bit of time to get back to you on this.
As the error indicates, trainNetork only supports sequence data in tables when the table contains a list of files to load for the data. In your case I think the table contains the data itself.
The best approach in this case is probably to convert the table contents into two cell arrays, one for the predictors and one for the responses. But looking again at your code, I suspect it is not as simple as just extracting a cell of columns: your code is trying to use multiple table variables but the network only has one input and output.
Do you have an a small example of the contents of the tables that you are reading in, and a description of their meaning or how you want to train the network with them? Maybe you actually need to concatenate multiple table columns together to form a sequence?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by