开发者

How to customize error function of MATLAB Neural Network

I want to implement this function as the error function for training a neural network:

function err = MyErrorFunction(T,O)
  d = T - O;
  err = -d*( exp(-d) - 1 );
end

where T is target value and O is neural network output for an input.

The training algorithm doesn't matter (apparently error function for trainlm is not customizable, so I can go with the trainscg).

I've found this article that suggests using the template_performance.m file to define a new performance function. I says I just have copy this file and customize it as I want.

But as I have understood, `template_performance.m` is a template for **performance** function, not the **error** function: `template_performance.m` gets the error values and output a performance value, for instance it could sum up the square of the errors and output them (SSE).

Apparently, template_performance.m have been deprecated starting from MATLAB 2010.

So, how I can change the way that error/performance is calculated/evalua开发者_开发技巧ted when training a neural network?


I had a similar problem ... the whole thing about customizing a performance function is a total disaster. A lot of stuff is being depreciated and there is zero documentation on what we should do.

I ended up having to hack the core files of a performance function I wasn't planning on using (SSE). Under the matlab directory MATLAB\R2012b\toolbox\nnet\nnet\nnperformance you can find them. I modified the apply.m (in the SSE+ folder) function with some directional weights based on t, t-1 change. But then I ran into the problem of training algorithms sending parameters to apply() in a different way AND format than perform(). I ended up not using perform() and writing my own code for that. Jesus... Total mess.

This was a very ugly hack and I'd love to hear from anyone who found the correct way to do this.


From what I understand, the performance function is used both for training and testing/evaluation (unless a certain training algorithm is hard-coded to a specific function)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜