I want multiple output regression! (custom)
4 次查看(过去 30 天)
显示 更早的评论
Hi, I am working on a custom regression neural network.
Inputs size=2 and Output size=6 // Number of Data =25001
However, after a certain iteration, it was confirmed that all Data(25001) outputs are the same.
x axis=Target // y axis=output
Initially, the output is different, but it seems that the output is the same after a while.
My code is here.
--------------------------------------------------------------------------------------------
...
...
...
Inputs=transpose(Input);
Outputs=transpose(Output);
layers = [
featureInputLayer(2,'Name','in')
fullyConnectedLayer(64,'Name','fc1')
tanhLayer('Name','tanh1')
fullyConnectedLayer(32,'Name','fc2')
tanhLayer('Name','tanh2')
fullyConnectedLayer(16,'Name','fc3')
tanhLayer('Name','tanh3')
fullyConnectedLayer(8,'Name','fc4')
tanhLayer('Name','tanh4')
fullyConnectedLayer(6,'Name','fc5')
];
lgraph=layerGraph(layers);
dlnet=dlnetwork(lgraph);
iteration = 1;
averageGrad = [];
averageSqGrad = [];
learnRate = 0.005;
gradDecay = 0.75;
sqGradDecay = 0.95;
output=[];
dlX = dlarray(Inputs,'CB');
for it=1:500
iteration = iteration + 1;
[out,loss,NNgrad]=dlfeval(@gradients,dlnet,dlX,Outputs);
[dlnet.Learnables,averageGrad,averageSqGrad] = adamupdate(dlnet.Learnables,NNgrad,averageGrad,averageSqGrad,iteration,learnRate,gradDecay,sqGradDecay);
if mod(it,100)==0
disp(it);
end
end
function [out,loss,NNgrad,grad1,grad2]=gradients(dlnet,dlx,t)
out=forward(dlnet,dlx);
loss2=sum((out(1,:)-t(1,:)).^2)+sum((out(2,:)-t(2,:)).^2)+sum((out(3,:)-t(3,:)).^2)+sum((out(4,:)-t(4,:)).^2)+sum((out(5,:)-t(5,:)).^2)+sum((out(6,:)-t(6,:)).^2);
loss=loss2;
[NNgrad]=dlgradient(loss,dlnet.Learnables);
end
-------------------------------------------------------------------------------------------------------------------------------------------------
Thanks for reading my question. I hope that a great person can answer.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!