Neural Network error please help me "Inputs and targets have different numbers"
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
user0002919
am 12 Mär. 2019
Bearbeitet: Adam Danz
am 22 Jan. 2020
I'm new to Matlab. I've built the code below to classify animals with three inputs in each pattern on the neural network, I'm trying to plot the classification of two inputs after the training phase, but I'm getting an error and I don't know what to do:
net = newp([0 1; 0 1; 0 1],1);
P = [0 0 1; 1 0 1; 0 0 0; 1 1 0; 0 1 1; 1 0 0]'; %three inputs for each pattern
T = [0 1 0 1 0 1]'; %1 = animal is a mammal, 0 = animal is not mammal
net.trainParam.epochs = 2;
net = train(net,P,T);
plotpv(P,T);
plotpc(net.IW{2},net.b{1});
%Tests
NP = [1 1 1; 0 1 0]';
hold on;
plot(NP(1),NP(2)'*r');
Y = sim(net,NP)
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 12 Mär. 2019
Bearbeitet: Adam Danz
am 20 Mär. 2019
P is size [3 x 6] while T is size [6 x 1]. You need to have one T value for each column of P. To fix this, transpose T so its size becomes [1 x 6].
net = train(net,P,T); %your version
net = train(net,P,T'); %correct version
3 Kommentare
Desmond Molloy
am 22 Jan. 2020
This approach works with neither the transpose function, nor the T' notation.
Adam Danz
am 22 Jan. 2020
Bearbeitet: Adam Danz
am 22 Jan. 2020
Transposing the 2nd input variable does work if it is a column vector with n elements where n is the number of columns of the first input as was the case for the OP's data. But there are other errors with the inputs that transpose would not fix.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Deep Learning Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!