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

What performance function do you want to implement?
What nndataset do you want to use for an example?
help nndatasets
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
Any help in this regard ?
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 Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

질문:

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