Problem building a custom transfer function for feedforward neural network
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I am trying to build a custom transfer function for my feedforward neural network in Matlab R2019a. But, I face attached error. I defined my new sigmoid function as 'mytanhfunction' as following and I save it in my working directory. Then I try to go to main directory which (matlab installation directory) and I added 'mytanhfunction' just like other functions (like tansig and purelin ...). Still it gives me the same error. I appreciate any help on this.
function a = mytanhfunction(n,varargin)
if nargin > 0
n = convertStringsToChars(n);
end
if ischar(n)
a = nnet7.transfer_fcn(mfilename,n,varargin{:});
return
end
% Apply
a = 1 ./ (exp(-26*(n - .3)) + 1);
I used following two forms of commands in order to design my network. Both gave me the same error I attached to this.
nsk1 = 3; % number of first hidden layer neuron
nsk2 = 2; % number of second hidden layer neuron
% X=inputs
% T= target
nsk1=2;
nsk2=2;
net = newff(X,T,[nsk1,nsk2],{'mytanhfunction','mytanhfunction','purelin'});
net.trainParam.epochs = 50;
net = train(net,X,T);
______________________________________________
net = fitnet;
net.layers{1}.transferFcn = 'mytanhfunction';

0 Kommentare
Antworten (2)
Siehe auch
Kategorien
Mehr zu Deep Learning Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!