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轴的网格
      

 

Matlab画激活函数sigmoid, tanh,Relu等_第1张图片

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轴的网格
      

 

Matlab画激活函数sigmoid, tanh,Relu等_第2张图片

 

你可能感兴趣的:(深度学习,matlab,深度学习)