How can change the performance function in neural network ?

I have Matlab versions R2013a and R2012b. I want to customize the performance function for neural network online training using 'adapt' function. The default performance function for both adapt/train functions is 'mse'. How can I change this function for adapt function.
What I tried so far: I tried changing the 'performFcn' to a .m file I wrote. Using the standard template of mse.m. I wrote all the necessary functions and the dcos function for gradient error function as well. But everything gave random errors - which mostly I traced back to the problem that latest versions of Matlab dont allow overriding 'mse' for adapt function. Is it true ?
Irrespective of that - how do I customize the performance function for neural network ?
Thanks
Anush

4 件のコメント

Greg Heath
Greg Heath 2013 年 12 月 5 日
What performance function do you want to implement?
What nndataset do you want to use for an example?
help nndatasets
Anush
Anush 2013 年 12 月 6 日
Hi Greg, Say, I will use the simple iris_dataset and I want to implement the cross entropy function. I have included my code snippet below.
load iris_dataset.mat;
netSize = [15 7];
%Dummy data for initialization - all hardcoded for this example
initData = ones([4 3]);
initLabel = [1 0 0;0 1 0;0 0 1];
neuralNet = feedforwardnet(netSize,'trainscg');
neuralNet.performFcn = 'crossEntropy';
neuralNet = configure(neuralNet,initData,initLabel);
% Adapt the network for each data
for i = 1:size(irisInputs,2)
[neuralNet,predictedOutput(:,i)] = adapt(neuralNet,irisInputs(:,i),irisTargets(:,i));
end
This code works perfectly fine for an online update of the neural network using 'mse' as performance function. Now I have mentioned the performance function to be 'crossEntropy'. How do I go about writing the crossEntropy.m file the following function:
eta.*(-irisTargets(:,i).*log(predictedOutput(:,i)))
Thanks
Anush
Anush
Anush 2013 年 12 月 27 日
Any help in this regard ?
Giorgio
Giorgio 2015 年 3 月 27 日
Hi Anush, Did you solve your problem ?? i'm working on MATLAB R2014b and i'm stuck to your same problem.
Thanks

サインインしてコメントする。

 採用された回答

Greg Heath
Greg Heath 2015 年 3 月 28 日

0 投票

The PATTERNNET default is crossentropy. There is nothing more for you to do except make sure that the target matrix columns are from eye(c) for c classes..
help crossentropy
doc crossentropy
type crossentropy
Hope this helps
Thank you for formally accepting my answer
Greg

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDeep Learning Toolbox についてさらに検索

質問済み:

2013 年 12 月 4 日

回答済み:

2015 年 3 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by