How to define my own performance function using fitnet besides copying the source code like mse.m?
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Saeed Khaleghi Rahimian
am 28 Feb. 2023
Bearbeitet: Amanjit Dulai
am 4 Dez. 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 Kommentare
Akzeptierte Antwort
Amanjit Dulai
am 4 Dez. 2023
Bearbeitet: Amanjit Dulai
am 4 Dez. 2023
See this answer for a step by step guide on how to create a custom performance function:
0 Kommentare
Weitere Antworten (1)
Shubham
am 8 Mär. 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 Kommentar
Siehe auch
Kategorien
Mehr zu Deep Learning Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!