Absolute error instead of Mean Square Error - NN

조회 수: 5 (최근 30일)
Francesco Porretta
Francesco Porretta 2021년 11월 16일
답변: Amith 2024년 10월 13일
It is possible to change the MSE performance to a simple Error performance? So, considering the minimization of the (maximum) error in a neural network?
Thanks in advance!

답변 (1개)

Amith
Amith 2024년 10월 13일
Hi Francesco,
It is possible to change the performance function in MATLAB to minimize the maximum error instead of the mean squared error (MSE). You can achieve this by creating a custom performance function. Here’s a general approach to do this:
1. Define the Custom Performance Function: Create a new function that calculates the maximum error. Save this function as a .m file.
function perf = max_error(t, y)
% t: targets
% y: outputs
% Calculate the maximum absolute error
perf = max(abs(t - y));
end
2. Set the Custom Performance Function in Your Neural Network: Assign this custom performance function to your neural network.
% Create a feedforward neural network
net = feedforwardnet(10);
% Set the custom performance function
net.performFcn = 'max_error';
% Train the network
[x, t] = bodyfat_dataset;
% Example dataset
net = train(net, x, t);
% Evaluate the performance
y = net(x);
perf = perform(net, t, y);
This approach allows you to customize the performance evaluation to focus on minimizing the maximum error rather than the mean squared error.
Hope this helps!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by