Matlab画激活函数sigmoid, tanh,Relu等

        x = linspace(-10.0,10.0);
relu = max(x,0);
sigmoid = 1./(1.0+exp(-1.0*x));
tanh = 2./(1.0 + exp(-2.0 * x)) - 1;


plot(x,relu,'r');
hold on;
plot(x,sigmoid,'b');
hold on;
plot(x,tanh,'g');

legend('relu','sigmoid','tanh');
title('激活函数(Activation)','FontSize',16);

hold on;
y = linspace(-2.0,5.0);
x = 0.*y;
plot(x,y,'k')
axis([-2.0 5.0 -2.0 5.0])
set(gca, 'XGrid','on');  % X轴的网格
set(gca, 'YGrid','on');  % Y轴的网格
      
v2-bdbac6c4a165fb9374af480fb8155d81_b.jpg

ReLu 与 TLU

        x = linspace(-10.0,10.0);
relu = max(x,0);
tlu = max(x-1,0)+1

plot(x,relu,'r');
hold on;
plot(x,tlu,'b');
hold on;

legend('relu','tlu');
title('激活函数(Activation)','FontSize',16);
hold on;

y = linspace(-2.0,5.0);
x = 0.*y;
plot(x,y,'k')
axis([-2.0 5.0 -2.0 5.0])
set(gca, 'XGrid','on');  % X轴的网格
set(gca, 'YGrid','on');  % Y轴的网格
      
v2-87ff795599c363eec7d404a6ce96762d_b.jpg

猜你喜欢

转载自blog.csdn.net/weixin_40519315/article/details/105466995
今日推荐