How to use a custom transfer function in neural net training
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I want to use a function similar to tansig. I don't seem to be able to find a good example, and the tansig.apply method only allows me one line! I'm wrapped around this axle, and I suspect I'm missing something simple. Any ideas? I'm using 2012b.
0 comentarios
Respuesta aceptada
Greg Heath
el 9 de Dic. de 2012
Editada: Walter Roberson
el 13 de Ag. de 2017
I cannot make sense of your post.
tanh(x) = tansig(x)
elliotsig(4*x) ~ tansig(x)
elliotsig4(x) ~ tansig(x)
function y = elliotsig4(x)
y = x./(0.25 + abs(x));
end
What do you mean by the tansig.apply method ???
Sample code would help explain.
Hope this helps.
Thank you for formally accepting my answer.
Greg
1 comentario
Greg Heath
el 9 de Dic. de 2012
Editada: DGM
el 23 de Feb. de 2023
Note the following ranks in speed
1. tanh
2. elliotsig4
3. elliotsig
4. tansig
function elliottime
clear all, clc
tic; for i = 1:1e4
y1 = tansig(1); % 0.7616
end; t1 = toc % 1.2259
tic; for i = 1:1e4
y2 = elliotsig(4*1); % 0.8000
end; t2= toc % 0.0029
tic; for i = 1:1e4
y3 = elliotsig4(1); % 0.8000
end; t3 = toc % 0.0027
tic; for i = 1:1e4
y4 = tanh(1); % 0.7616
end; t4 = toc % 5.94e-4
[ [ t1 t2 t3 t4 ]' [y1 y2 y3 y4 ]' ]
function y = elliotsig(x)
y = x./(1+abs(x));
end
function y = elliotsig4(x)
y = x./(0.25+abs(x));
end
end
Más respuestas (5)
Bob
el 27 de Mzo. de 2013
4 comentarios
Mayank Gupta
el 4 de Mayo de 2016
Can you please explain in detail how to save a custom training function to the nntool directory ? I am using Firefly algorithm for optimization.
Mehdi Jokar
el 16 de Jul. de 2018
Bob, thank you for you instructions. but, is apply the only function that needs to be modified? or we need to modify the backprop and forwardprop function in the + folder ?
Mehdi
Greg Heath
el 11 de Dic. de 2012
Editada: DGM
el 23 de Feb. de 2023
I cannot understand why you think y2 is better than y1
x = -6:0.1:6;
y1 = x./(0.25+abs(x));
y2 = x.*(1 - (0.52*abs(x/2.6))) % (for -2.5<x<2.5).
figure
hold on
plot(x,y1)
plot(x,y2,'r')
0 comentarios
mladen
el 26 de Mzo. de 2013
Could anybody upload some examples of modified tansig.m and +tansig folder? This would be very helpful for my project and for other people too. Thank You.
1 comentario
Nn Sagita
el 29 de Ag. de 2013
If you have some examples how to modify transfer function, please share for me. Thank you.
mladen
el 29 de Mzo. de 2013
Thank you Bob. Nice trick with feedforwardnet.m (good for permanent use). I've managed to do this but some new questions arise:
- How to use param in apply(n,param) ? (more info-> matlabcentral/answers/686)?
- How to use different transfer functions within the same layer?
- My apply function looks something like this:
function A = apply(n,param)
%....
A=a1.*a2;
end
now I would like to use a1 and a2 to speedup the derivative computation in da_dn.m (this has already been done with tansig.m, but with the final value (A in my code))...is it possible?
0 comentarios
Ver también
Categorías
Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!