MATLAB: How to pass the performance parameters to the own custom performance function in the Neural Network Toolbox

customDeep Learning Toolboxfunctionnetworksneuralperformance

How can I pass the performance parameters to my own custom performance function in the Neural Network Toolbox?

Best Answer

For releases of MATLAB prior to MATLAB 8.0 (R2012b), the MSEREG function within the Neural Network Toolbox is a good example of a performance function using the performance parameters.
1) The custom performance function should have a header that looks like:
function perf= myperfFcn(e, x, pp)
where:
E - Matrix or cell array of error vector(s).
X - Vector of all weight and bias values.
PP - Performance parameter structure.
2) To specify your custom performance function:
net.performFcn = 'myperfFcn'
3) To specify your custom performance parameters:
perfStruct.varA = 1;
perfStruct.varB = 2;
net.performParam = perfStruct;
Note the "net" structure will now include:
    parameters:
         adaptParam: .passes
         initParam: (none)
         performParam: .varA, .varB
For releases of MATLAB starting in MATLAB 8.0 (R2012b), information is provided by the command,
>> help nncustom
For example, to specify a custom performance function, execute the command,
>> which mse
to locate the 'mse' function.  Copy and rename the file 'mse.m' and the folder '+mse'.  Then, use these functions as templates to write your own custom function.