What are the possible performance functions for a Neural Network on Matlab?

조회 수: 5 (최근 30일)
NOOR
NOOR 2017년 7월 12일
답변: Amit Doshi 2017년 7월 19일
Hello, I have two questions:
firstly, whenever I try to change the performance function from 'mse' to 'mae' (mean absolute error), the neural network automatically changes it back to 'mse'. Is there any way I could assign the performance function as the mae automatically?
Secondly, if I would like to customize my own performance function, how would do that if I have not defined an output variable for my neural network during training? (i.e. how would I define the prediction to compare with the target)
Thank you!

답변 (1개)

Amit Doshi
Amit Doshi 2017년 7월 19일
Hello Noor,
For some functions like the 'trainlm' function, they not support the 'mae' performance function.
The best way to create a custom performance function is to use MSE.M and the +MSE package of functions as a template. Here are descriptions of the required package functions:
newfcn.m - Same as mse.m
+newfcn/apply.m - The main performance calculation function perfs = apply(t,y,e,param) Calculate performance for each target individually so perfs is same size as t, y and e.
+newfcn/backprop.m - Backprop derivatives function dy = backprop(t,y,e,param) Return dperf/dy, the derivative of performance with respect to each output y.
+newfcn/forwardprop.m - Forward propagate derivatives function dperf = forwardprop(dy,t,y,e,param) Return dperf/dwb given dy/dwb.
+newfcn/type.m - Indicate that "newfcn" is a performance function. function t = type t = 'performance_fcn';
+newfcn/name.m function name = name() Return the name of the function, for instance: name = 'My New Peformance Function';
+newfcn/normalize.m function flag = normalize Return true if mean performance is desired (i.e. mean squared error, mean absolute error) and false if the absolute performance is desired (i.e. sum squared error, sum absolute error).
+newfcn/parameterInfo.m function param = parameterInfo Return the same array of parameter definitions as MSE. Customer can also add additional parameters if desired.
+newfcn/perfwb.m - Regularization performance used to minimize weights and biases function perf = perfwb(wb,param) Return the performance measure for weights and biases. This performance measure is only used when net.performParam.regularization is set to a value greater than 0. If regularization is not going to be used this function can return 0.
+newfcn/dperf_dwb.m - Regularization derivatives function dperf = dperf_dwb(wb,param) If you are not doing regularization then this function can return zeros the same size as wb. Otherwise it should return a derivative of regularization performance (calculated by perfwb) with respect to each weight and bias value in wb.
*There is one more caveat when following this approach in R2012b – there is an issue that is planned to be resolved in a future release, but currently defining custom functions with this approach works only with the non-MEX version of the Neural Network code, so it is necessary to call TRAIN with a special syntax – i.e., using the nn7 option. This workaround is the following syntax for training and simulating the network:
net = train(net,x,t,nn7);
y = net(x,nn7);

Community Treasure Hunt

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

Start Hunting!

Translated by