Why do I meet the error when using trainNetwork, it shows too many input arguments in Table?

5 次查看(过去 30 天)
When I use the official case given in Matlab, but Matlab always tell me the message:
"Error in using trainNetwork Too many input arguments..
Reason: Incorrect use of table Too many input arguments.."
load WaveformData
Error using load
Unable to find file or directory "WaveformData". It is used in these examples:
Run Sequence Forecasting Using a GRU Layer on an FPGA
Run Sequence Forecasting on FPGA by Using Deep Learning HDL Toolbox
Detect Anomalies in Signals Using deepSignalAnomalyDetector
Sequence Classification Using Deep Learning
Train Network for Sequence Classification
Interpret Deep Learning Time-Series Classifications Using Grad-CAM
Get Started with Deep Network Designer
Pad or Truncate Both Sides of Sequence Data
Pad Sequence Data to Same Length
Train Sequence Classification Network Using Custom Training Loop
Sequence Classification Using 1-D Convolutions
Train Sequence Classification Network Using Data with Imbalanced Classes
Time Series Forecasting Using Deep Learning
Sequence-to-One Regression Using Deep Learning
Get Started with Time Series Forecasting
Time Series Anomaly Detection Using Deep Learning
Build Time Series Forecasting Network Using Deep Network Designer
numChannels = size(data{1},1);
idx = [3 4 5 12];
figure
tiledlayout(2,2)
for i = 1:4
nexttile
stackedplot(data{idx(i)}', ...
DisplayLabels="Channel " + string(1:numChannels))
xlabel("Time Step")
title("Class: " + string(labels(idx(i))))
end
numObservations = numel(data);
[idxTrain,idxTest] = trainingPartitions(numObservations, [0.9 0.1]);
XTrain = data(idxTrain);
TTrain = labels(idxTrain);
XTest = data(idxTest);
TTest = labels(idxTest);
numHiddenUnits = 120;
numClasses = numel(categories(TTrain));
layers = [ ...
sequenceInputLayer(numChannels)
lstmLayer(numHiddenUnits,OutputMode="last")
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer]
options = trainingOptions("adam", ...
MaxEpochs=150, ...
InitialLearnRate=0.01,...
Shuffle="every-epoch", ...
GradientThreshold=1, ...
Verbose=false, ...
Plots="training-progress");
net = trainNetwork(XTrain,TTrain,layers,options);
%please note that this an official case in MATLAB shown below.
% "https://ww2.mathworks.cn/help/deeplearning/ref/trainnetwork.html#mw_408bdd15-2d34-4c0d-ad91-bc83942f7493"

回答(1 个)

Omega
Omega 2024-9-20
Hi Long,
I understand that you are facing issues with the "trainNetwork" MATLAB function. I believe the reason for the issue is a version mismatch. You are using MATLAB R2022b Desktop and referring to an example mentioned in the "trainNetwork" documentation for MATLAB R2024a. The reason you are able to run the script on MATLAB Online is that MATLAB Online uses the latest version.
I suggest you refer to the following documentation link for MATLAB R2022b:
Alternatively, you can update MATLAB to the latest version. Additionally, the "trainNetwork" function is not recommended from R2024a onwards, and you might want to consider using the "trainNet" function instead. The "trainNet" function has several advantages over the "trainNetwork" function.
For further information, you can refer to the following documentation links for the latest MATLAB versions:
I hope it helps!

类别

Help CenterFile Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by