Network with custom defined Regression Layer Output
2 次查看(过去 30 天)
显示 更早的评论
Hello everybody, I'm having problems creating a neural network.
Basically, my network has one input and one output; however I have no target, but the output will be fed into a library which approximates numerically a PDE and returns a vector such that I can interpret the loss function as the sum of the elements of this vector.
From my understanding of https://it.mathworks.com/help/deeplearning/ug/define-custom-regression-output-layer.html I am able to define an output layer with my specific loss function, defining in this template the following loss function:
function loss = forwardLoss(layer,Y)
% loss = forwardLoss(layer, Y) returns the loss function
% exploiting the predictions Y.
e = C_main2D('Test1',Y);
loss = sum(e);
end
The idea would be to have a vector of inputs in order to train the network by using the trainNetwork function, but the problem arises when I get to the definition of the Layer array.
I get that the regression layer I have defined should be the last element, but I don't understand how to properly define the layers in order to be able to pass the vector of inputs, a couple of hidden layers and then the regression output layer.
Thanks in advance for helping me.
0 个评论
回答(1 个)
Srivardhan Gadila
2020-9-30
As per my knowledge and above information, I think using the custom training loop would be a good Idea. You can refer to Train Network Using Custom Training Loop & Deep Learning Custom Training Loops for more information.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Build Deep Neural Networks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!