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

4 Ansichten (letzte 30 Tage)
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 Kommentare

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Richard
Richard am 21 Jul. 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 Kommentare
Amrit
Amrit am 31 Jul. 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 am 15 Aug. 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?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Sequence and Numeric Feature Data Workflows finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by