フィルターのクリア

Error using trainNetwork. Layers argument must be an array of layers or a layer graph.

13 ビュー (過去 30 日間)
Hello,
1) I'm trying to train a regression network as per below. However, when I execute: net = trainNetwork(XTrain,TTrain,layers);
I get the error message: Error using trainNetwork. Layers argument must be an array of layers or a layer graph.
2) When I execute: net = trainNetwork(XTrain,TTrain,layers,options);
I get the error message: Error using nnet.internal.cnn.trainNetwork.DLTInputParser>iParseInputArguments Too many input arguments.
Please let me know how to resolve 1 and 2 for the following code:
XTrain=InputTrainTable(:,2:end);
TTrain=InputTrainTable(:,1);
layers = [
featureInputLayer(108,"Name","featureinput","Normalization","rescale-symmetric")
tanhLayer("Name","tanh")
fullyConnectedLayer(100,"Name","fc")
regressionLayer("Name","regressionoutput")];
options = trainingOptions('sgdm');
%Question 1: Error using trainNetwork. Layers argument must be an array of layers or a layer graph.
net = trainNetwork(XTrain,TTrain,layers);
%Question 2: Error using nnet.internal.cnn.trainNetwork.DLTInputParser>iParseInputArguments. Too many input arguments.
%net = trainNetwork(XTrain,TTrain,layers,options);

採用された回答

Noah Prisament
Noah Prisament 2023 年 12 月 26 日
Hi William, the "trainNetwork" function always requires the "options" argument, so version 2 is the correct syntax.
If you are using an older version of MATLAB, the syntax that you are using was not supported and you are likely running into the same type of error as was resolved in this thread: https://www.mathworks.com/matlabcentral/answers/499762-too-many-input-arguments
If you are using a current version of MATLAB such as R2023b, then this syntax should be supported, however the responses variable must be an array instead of a table, so you must index into it using curly braces, {}, instead of parentheses, (), to get an array instead of a sub-table. I would recommend using the syntax in which you pass in a single table with both the X data and T data instead since you already have the targets in the first index (which is the assumed default). See this example in the documentation for more details: https://www.mathworks.com/help/deeplearning/ref/trainnetwork.html#mw_fcd828cc-de80-4922-8cc2-806c07deb31a
  1 件のコメント
William Schulz
William Schulz 2023 年 12 月 30 日
Thank you for the reply. For other readers: I also noticed that a high drop in MSE can lead to this error message and requires an adjustment of the InitialLearnRate.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!