필터 지우기
필터 지우기

Error when training neural network: Unable to use a value of type network as an index

조회 수: 6 (최근 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.

답변 (1개)

Amey Waghmare
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.

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by