How to define my own performance function using fitnet besides copying the source code like mse.m?
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Saeed Khaleghi Rahimian
le 28 Fév 2023
Modifié(e) : Amanjit Dulai
le 4 Déc 2023
I tried to copy the mse.m function in the curret directory and other functions in +mse folder like apply.m but it did not work. Is there any other method to simply define a new performance fucntion using fitnet?
0 commentaires
Réponse acceptée
Amanjit Dulai
le 4 Déc 2023
Modifié(e) : Amanjit Dulai
le 4 Déc 2023
See this answer for a step by step guide on how to create a custom performance function:
0 commentaires
Plus de réponses (1)
Shubham
le 8 Mar 2023
Hi Saeed,
Yes, there is another way to define a new performance function in MATLAB's fitnet function. You can use the performFcn property of the fitnet object to specify the name of your custom performance function.
Here's an example:
% Define your custom performance function
function perf = myperf(y, t)
% Calculate the mean squared error
perf = mean((t-y).^2);
end
% Create a new fitnet object with 10 hidden neurons
net = fitnet(10);
% Set the performFcn property to your custom performance function
net.performFcn = 'myperf';
% Train the network with your custom performance function
net = train(net, inputs, targets);
In this example, we define a custom performance function called myperf that calculates the mean squared error between the network's output y and the target values t. We then create a fitnet object with 10 hidden neurons, and set its performFcn property to myperf. Finally, we train the network using the train function, which will use your custom performance function to evaluate the network's performance during training.
Note that your custom performance function should have the same input arguments as the built-in performance functions in MATLAB's Neural Network Toolbox, which are y (the network's output) and t (the target values). Your function should return a scalar value that represents the network's performance.
1 commentaire
Voir également
Catégories
En savoir plus sur Deep Learning Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!