Clear Filters
Clear Filters

How to code my own transfer function

2 views (last 30 days)
Souma
Souma on 11 May 2011
Hello all,
I am trying to implement my own transfer function that makes the exponential function. I would like then to integrate it in my code. I was inspired by the 'purelin'transfer function present in matlab to code my own exponential function
Here is how i proceed in my main function.
...
net = newff(pn,tn,S1,[],'trainlm');
net.layers{1}.transferFcn = exponential;
net.layers{2}.transferFcn = purelin;
...
And when i do run my code i do have the following error:
??? Error using ==> boiler_transfer at 5 Not enough arguments.
Error in ==> zexponential at 63 boiler_transfer
Error in ==> CorpusParam at 28 net.layers{1}.transferFcn= exponential
Does anyone knows how to fix that problem.
Thank you ,
Souma

Answers (3)

Souma
Souma on 12 May 2011
Any suggestions??

Walter Roberson
Walter Roberson on 12 May 2011
Have another look at the documentation example for purelin
Assign this transfer function to layer i of a network.
net.layers{i}.transferFcn = 'purelin';
Notice they supplied a quoted string. Without the quotes, the code would attempt to call purelin right then and there and store the result as the transferFcn.
Likewise, since you coded exponential it is going to try to call exponential immediately and store the result -- an attempt that fails because you have no arguments. So use 'exponential' instead. (Though I suspect that using the function handle @exponential would be even better.)

Souma
Souma on 12 May 2011
Thank you Mr. Walter Roberson for your answer.
I have tried to put the name of my function in quotes ('exponential'). The element is compiled and it seems working. However, i get the following message:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at com.mathworks.toolbox.nnet.v6.diagram.nnTransfer.paint(nnTransfer.java:35) at com.mathworks.toolbox.nnet.v6.image.nnOffsetImage.paint(nnOffsetImage.java:49) at com.mathworks.toolbox.nnet.v6.image.nnLayerImage.paint(nnLayerImage.java:50) at com.mathworks.toolbox.nnet.v6.image.nnOffsetImage.paint(nnOffsetImage.java:49) at com.mathworks.toolbox.nnet.v6.image.nnLayerImage.paint(nnLayerImage.java:50)
and some 15 lines like this.
Do you know what does this mean ?
Thanks
Souma

Community Treasure Hunt

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

Start Hunting!