Error when training neural network: Unable to use a value of type network as an index
5 ビュー (過去 30 日間)
古いコメントを表示
Hello I get this error when training this neural network
Unable to use a value of type network as an index.
Error in ANN (line 13)
trained_net = train(net,train,targets)
% Load the data set
data = load('data.mat');
data = struct2array(data)
% Extract the data and labels from the table
train = data(:, 1:end-1);
targets = data(:, end);
layer1 = 10
layer2 = 10
net = patternnet([layer1 layer2]);
trained_net = train(net,train,targets)
op = trained_net(train);
conf = confusion(targets,op);
Any help would be greatly appreciated.
0 件のコメント
回答 (1 件)
Amey Waghmare
2023 年 1 月 6 日
Hi,
As per my understanding, you are unable to train the neural network because of the error ‘Unable to use a value of type network as an index.’
This error occurs because the name of the variable ‘train’, created from data, matches with the MATLAB’s function ‘train’. In order to resolve the error, change the name of variable ‘train’ to any other name on line 7 of the code, as follows,
train_X = data(:, 1:end-1);
This will resolve the error.
Also, to train the network using the ‘train’ function, the data should be passed as a input size by batch size form. This can be done by using transpose as follows,
train_1 = data(:, 1:end-1)';
targets = data(:, end)';
For more information, please refer the documentation of 'train', https://in.mathworks.com/help/deeplearning/ref/network.train.html
I hope this resolves the issue.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Deep Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!