Function to trainNetwork returns an unexpected error
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ernest Modise - Kgamane
el 7 de Jun. de 2024
Comentada: Matt J
el 9 de Jun. de 2024
My code returns the following error for this function call - What is the fix for this?
net = trainNetwork(X_train, categorical(y_train), layers, options);
Error using trainNetwork (line 191)
Too many input arguments.
Error in LSTMGomz (line 63)
net = trainNetwork(X_train, categorical(y_train), layers, options);
Caused by:
Error using nnet.internal.cnn.trainNetwork.DLTInputParser>iParseInputArguments (line 75)
Too many input arguments.
2 comentarios
Matt J
el 7 de Jun. de 2024
You would have to attach a .mat file providing inputs X_train, categorical(y_train), layers, options for us to run with.
Respuesta aceptada
Matt J
el 8 de Jun. de 2024
Editada: Matt J
el 8 de Jun. de 2024
Your X_train and y_train data were in some weird format that trainNetwork cannot recognize. Try this instead,
Xdata = num2cell(readmatrix('LSTMdataIn.xlsx')',1)';
N=200;
train_ratio=0.8;
split_index=round(train_ratio*N);
inputSize = height(Xdata{1}); % Number of features in the input data
numClasses = height(Xdata)/N; % Number of categories
Xdata=reshape(Xdata,N,numClasses);
ydata=repmat(1:numClasses,N,1);
X_train=Xdata(1:split_index,:);
y_train=ydata(1:split_index,:);
X_test=Xdata(split_index+1:end,:);
y_test=ydata(1:split_index+1:end,:);
layers = [
sequenceInputLayer(inputSize)
lstmLayer(100, 'OutputMode', 'last')
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer
];
options = trainingOptions('adam', 'MaxEpochs', 100);
net = trainNetwork(X_train(:), categorical(y_train(:)), layers, options);
3 comentarios
Matt J
el 9 de Jun. de 2024
It's just a cell array of numeric data. You had tables nested inside cells, I think.
Más respuestas (0)
Ver también
Categorías
Más información sobre Image Data Workflows en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!