Problem building a custom transfer function for feedforward neural network

조회 수: 1 (최근 30일)
Alireza Bagheri
Alireza Bagheri 2019년 8월 20일
답변: Alireza Bagheri 2019년 8월 28일
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';

답변 (2개)

Alireza Bagheri
Alireza Bagheri 2019년 8월 20일
I appreciate a quick response!

Alireza Bagheri
Alireza Bagheri 2019년 8월 28일
I am still waiting for an asnswer!

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by