Neural Network toolbox - transferFcn and transferParam

I am trying to define a transfer function with parameters in the Neural network toolbox but I am not able to define the parameters correctly
What I did?
1. I copied the LOGSIG Logarithmic sigmoid transfer function file -my transfer function includes a factor in the exponent
2. I defined the parameter to receive as a real scalar with default value 1.0
function param = parameters, param = ...
[nnetParamInfo( 'alpha', ...
'alpha factor in the exponent', ...
'nntype.real_scalar', ...
1.0, ...
'alpha factor in the exponent')];
end
3. I include it in the 'apply' and 'da_dn' functions
function a = apply(n,param)
% The same as logsig but with alpha factor in the exponent
a = 1 ./ (1 + exp(-n * param.alpha));
i = find(~isfinite(a));
a(i) = sign(n(i));
end
4. I create the network and establish the alpha parameter
net = feedforwardnet([10, 10]);
% ... more initializations ...
net.layers{1}.transferParam.alpha = 1.1;
The LAST LINE raise this ERROR
??? Error using ==> param
Too many input arguments.
Error in ==> network.subsasgn>setLayerTransferParam at 1214
err = nntest.param(functionInfo.parameters,transferParam, ...
Any ideas? I did not find any good documentation / example about how to define a transfer function with parameters

4 Comments

I am trying to do the same thing with another function, if I find a solution I'll let You know :)
Same issue here. If someone has any solution for this problem, please help.
There is no problem worth talking about!!!
.. . Read my answer
Greg
Guru
Guru on 4 Dec 2014
Edited: Guru on 4 Dec 2014
Actually I don't want to train the network. I'm not using any training algorithms. Instead I'm varying the control parameter of the custom transfer function that I've written. My network is not exactly for the functionality traditionally used with neural networks. So I need to initialise this parameter for the transfer function and vary it based on the output.
This is what the error I'm runnign into,
Undefined function or variable 'newSize'.
Error in network/subsasgn>setLayerTransferParam (line 1231) net.layers{i}.range = repmat(feval(net.layers{i}.transferFcn, ...
Error in network/subsasgn>network_subsasgn (line 189) if isempty(err), [net,err] = setLayerTransferParam(net,i,transferParams); end
Error in network/subsasgn (line 13) net = network_subsasgn(net,subscripts,v,netname);
Error in TestNet (line 21) net.layers{1}.transferParam.no_of_iter = 4;

Sign in to comment.

 Accepted Answer

Francisco,
Have you tried the solution methods suggested at http://www.mathworks.com/support/solutions/en/data/1-17LOK/index.html?product=NN&solution=1-17LOK ?
George

3 Comments

Francisco says: "The problem I have is not how to include the function in the library. The problem I have is how to define the parameters for the function.
Thanks anyway for your link, I guess is almost the only one talking about his issue :)"
I don't have the NN toolbox by which to help with the debbugging. If no one else has the answer, you might just click "Please provide feedback to help us improve this Solution" at the link above and request the desired instructions.
Thanks anyway George.
Till the moment I 'solved' using a global variable instead of passing the parameters in the right way -I was not able to realize how to do it.
Thanks again for your time.
Fran

Sign in to comment.

More Answers (1)

There is absolutely no reason to use parameters in the transfer function.
Training will vary the weights to minimize the error.
If you want to decrease training time , just increase the learning rate
Hope this helps.
Greg

Asked:

on 1 Feb 2011

Edited:

on 4 Dec 2014

Community Treasure Hunt

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

Start Hunting!