How to define my own performance function using fitnet besides copying the source code like mse.m?
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Saeed Khaleghi Rahimian
el 28 de Feb. de 2023
Editada: Amanjit Dulai
el 4 de Dic. de 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 comentarios
Respuesta aceptada
Amanjit Dulai
el 4 de Dic. de 2023
Editada: Amanjit Dulai
el 4 de Dic. de 2023
See this answer for a step by step guide on how to create a custom performance function:
0 comentarios
Más respuestas (1)
Shubham
el 8 de Mzo. de 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 comentario
Ver también
Categorías
Más información sobre Deep Learning Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!