How to write custom performance function for neural network in MATLAB 2012b (neural network toolbox 8.0)

1 view (last 30 days)
Hi,
I am having problem in editing the performance function to create a customized entropy function for the neural network. The available functions are mse, mae, sse and sae. In the available tutorials, it's mentioned that I can use mse as a template and edit it according to my choice. I used the mse function and its subfunctions and renamed the function name as, say, 'myFunc' and saved it to my working directory. But when I try to incorporate this in the network by assigning net.performFcn = 'myFunc', it does not show any compilation error but the train function does not work. I think I am missing some steps in assigning 'myFunc' as a performance function. I have also found that the template is drastically different in MATLAB 2010 version.
Please provide me the solution for this problem.
Thanks in advance.
Samiul H. Choudhury

Accepted Answer

Greg Heath
Greg Heath on 12 Mar 2013
I think we should start where you left off. So, post your code. With relevant comments.
Which entropy function? Exclusive classes ( dog, cat, mouse ...) or Nonexclusive classes ( short, fat, bald, ugly,...)
Greg
P.S. I had one or two crossentropy functions working on my old machine that crashed. I don't plan to pay for it's recovery. However, I wrote quite a bit about the process in comp.ai.neural-nets. Try searching there using
greg entropy
Hope this helps.
Greg
  2 Comments
Samiul Hayder Choudhury
Samiul Hayder Choudhury on 14 Mar 2013
Thanks Greg for your answer. Actually I am trying to implement a network pruning algorithm for neural network feature selection. I have the following entropy function that needs to be minimized: f = -(sum(i=1:k) sum(p=1:c) (t_{i,p}*log(S_{i,p} + (1-t_{i,p})*log(1-S_{i,p})) + P(w) here, k = number of patterns, c = number of output units, t = target, S = network output, P(w) = penalty term added for the sake of algorithm; it is a function of the input weights.
I need to minimize this function, so I wanted to use this as the performance function that needs to be minimized.
I used 'trainscg' function as the network training function which accepts different optimization function. So I need to write the performance function.
Please inform me if you need any more information.
Thanks in advance, Samiul
Greg Heath
Greg Heath on 20 Feb 2015
Not sure why I never replied to this. However, descriptions of what someone thinks they did are no substitution for seeing the actual code and, if it runs, either the output from one of the MATLAB example data sets in
help nndatasets
doc nndatasets
or the resulting error messages.
ope this helps.
Greg

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!