如何自定义MATLAB神经网络的误差函数

发布于 2024-11-30 10:58:01 字数 900 浏览 0 评论 0原文

我想将此函数实现为训练神经网络的误差函数:

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

其中 T 是目标值,O 是输入的神经网络输出。

训练算法并不重要(显然 trainlm 的误差函数不可自定义,因此我可以使用 trainscg)。

我发现 本文建议使用template_performance.m 文件来定义新的性能函数。我说我只是复制这个文件并根据需要自定义它。

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).

显然,从 MATLAB 2010 开始,template_performance.m 已被弃用。

那么,在训练神经网络时如何改变计算/评估误差/性能的方式呢?

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/evaluated when training a neural network?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情独悲 2024-12-07 10:58:01

我也遇到了类似的问题……定制性能函数的整个过程完全是一场灾难。很多东西都在贬值,而且关于我们应该做什么的文档为零。

我最终不得不破解我不打算使用的性能函数(SSE)的核心文件。在 matlab 目录 MATLAB\R2012b\toolbox\nnet\nnet\nnperformance 下您可以找到它们。我根据 tt-1 的变化修改了 apply.m(在 SSE+ 文件夹中)函数,并使用了一些方向权重。但后来我遇到了训练算法以与 perform() 不同的方式和格式向 apply() 发送参数的问题。我最终没有使用 perform() 并为此编写了自己的代码。天啊……一团糟。

这是一个非常丑陋的黑客行为,我很想听听任何找到正确方法的人的意见。

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.

治碍 2024-12-07 10:58:01

据我了解,性能函数既用于训练又用于测试/评估(除非某种训练算法被硬编码为特定函数)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文