activation-functions.tikz 1.1 KB

123456789101112131415161718192021222324252627
  1. \begin{tikzpicture}[scale=1.0]
  2. \begin{axis}[
  3. legend pos=north west,
  4. axis x line=middle,
  5. axis y line=middle,
  6. grid = major,
  7. width=16cm,
  8. height=4cm,
  9. grid style={dashed, gray!30},
  10. xmin=-5, % start the diagram at this x-coordinate
  11. xmax= 5, % end the diagram at this x-coordinate
  12. ymin=-1, % start the diagram at this y-coordinate
  13. ymax= 1, % end the diagram at this y-coordinate
  14. %axis background/.style={fill=white},
  15. xlabel=$x$,
  16. ylabel=$y$,
  17. tick align=outside,
  18. enlargelimits=true]
  19. \addplot[green!50!black, ultra thick] coordinates {(-5,-1) (0,-1) (0, 1) (5, 1)};
  20. % \addplot[domain=-5:5, green!50!black, ultra thick,samples=500] {x < 0 ? -1 : 1};
  21. \addplot[domain=-5:5, red, ultra thick,samples=500, dash pattern=on 8pt off 2pt] {1/(1+exp(-x))};
  22. \addplot[domain=-5:5, blue, ultra thick,samples=500, dotted] {tanh(x)};
  23. \addlegendentry{sign function}
  24. \addlegendentry{$\sigmoid$}
  25. \addlegendentry{$\tanh$}
  26. \end{axis}
  27. \end{tikzpicture}