Error in predicted outputs for labels in neural network

조회 수: 1 (최근 30일)
Tony Stark
Tony Stark 2022년 10월 26일
편집: Walter Roberson 2022년 11월 20일
I am having trouble trying to diagnose why my neural network is not working. I tried modifying the code since my last post. However, I am still stuck.
The following is the whole modified code:
clc;
clear;
x = rand(75,11);
y = randi(5, 5, 75);
P = x';
T = y;
net = linearlayer;
net = configure(net,P,T);
net.trainParam.epochs = 1000;
[net,tr] = train(net,P,T);
view(net)
y_labels = net(P);
The following is the code that is meant as the data. Where x is the input data, and y is the target/label data.
clc;
clear;
x = rand(75,11);
y = randi(5, 5, 75);
The following is the code that is meant to configure the linear neural network model and train the model:
P = x';
T = y;
net = linearlayer;
net = configure(net,P,T);
net.trainParam.epochs = 1000;
[net,tr] = train(net,P,T);
view(net)
The following is the code that is meant to predict the target data outputs:
y_labels = net(P);
Now for the variable, y_labels, I get all 0s, which is different from the true original y data. It's not even close. I would appreciate some guidance. I went on MATLAB documentation to see if there is anything that would help modify, but nothing has been helping.

답변 (1개)

Amanjit Dulai
Amanjit Dulai 2022년 10월 27일
편집: Walter Roberson 2022년 11월 20일
As mentioned here: https://uk.mathworks.com/matlabcentral/answers/1835423-what-s-wrong-with-my-neural-network#answer_1085378 the training will work better when the learning rate is reduced:
x = rand(75,11);
y = randi(5, 5, 75);
P = x';
T = y;
% Set the learning rate to 0.001
net = linearlayer(0,0.001);
net = configure(net,P,T);
net = train(net,P,T);

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by