Guest User

Untitled

a guest
Oct 17th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. rm(list=ls(all=TRUE))
  2. sigmoid <- function(x) {
  3. sig <- 1 / (exp(-x)+1)
  4. }
  5.  
  6. hardsign <- function(x) {
  7. hard <- ifelse(x<0,-1,1)
  8. }
  9.  
  10. softsign <- function(x) {
  11. sig <- 1 / (abs(x)+1)
  12. }
  13.  
  14. relu <- function(x) {
  15. r <- ifelse(x<0, 0, x)
  16. }
  17.  
  18. satlins <- function(x) {
  19. a <- ifelse(x<(-1), -1, ifelse(x>1, 1, x))
  20. }
  21.  
  22. x = (-4000:4000)/1000
  23.  
  24. plot(x,sigmoid(x),type='l')
  25. plot(x,hardsign(x),type='l')
  26. plot(x,softsign(x),type='l')
  27. plot(x,relu(x),type='l')
  28. plot(x,tanh(x),type='l')
  29. plot(x,satlins(x),type='l')
Add Comment
Please, Sign In to add comment