Neural Network toolbox - transferFcn and transferParam

15 views (last 30 days)
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
Greg Heath
Greg Heath on 4 Dec 2014
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

George Evers
George Evers on 2 Feb 2011
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
George Evers
George Evers on 3 Feb 2011
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.
Francisco
Francisco on 3 Feb 2011
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)

Greg Heath
Greg Heath on 9 Feb 2013
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

Categories

Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!