How to use a self-made loss function for a simple Neural Net ?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have been using
net = feedforwardnet(10) %or
net = fitnet(10)
for my regression problem. I am using simple networks with 1 or 2 layers and ReLU activation function (net.transferFcn = 'poslin')
But now, I have to use a self-made custom loss functions instead of 'mse' (mean squared error). Could you please let me know how can I do this.
I have found the following document regarding using custom layers and loss functions: https://www.mathworks.com/help/deeplearning/ug/define-custom-regression-output-layer.html
But this is regarding to complex Neural Networks like CNN. I could not understand how to simplify this for a normal deep neural network.
Thanks!
1 commentaire
Réponses (1)
yanqi liu
le 29 Déc 2021
Modifié(e) : yanqi liu
le 29 Déc 2021
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/846575/image.jpeg)
net=newff([0,1],[5,1],{'tansig','logsig'},'traingd')
net.performFcn
for more information,please check
2 commentaires
yanqi liu
le 31 Déc 2021
yes,sir,just as
\toolbox\nnet\nnet\nnperformance
format,we can make the same functions,such as
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/848770/image.jpeg)
then we use
clc; clear all; close all;
warning off all
net=newff([0,1],[5,1],{'tansig','logsig'},'traingd');
net.performFcn
net.performFcn = 'self_made_loss_function';
net.performFcn
can get result
ans =
'mse'
ans =
'self_made_loss_function'
>>
Voir également
Catégories
En savoir plus sur Sequence and Numeric Feature Data Workflows dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!