Error in predicted outputs for labels in neural network

2 次查看(过去 30 天)
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);

类别

Help CenterFile Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by